mirror of https://github.com/apache/poi.git
DV related fixes from Pierre Lavignotte
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@691017 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
028dc760f7
commit
dc0f66c44e
|
@ -34,7 +34,14 @@ import org.apache.poi.ddf.EscherRecord;
|
|||
import org.apache.poi.hssf.model.FormulaParser;
|
||||
import org.apache.poi.hssf.model.Sheet;
|
||||
import org.apache.poi.hssf.model.Workbook;
|
||||
import org.apache.poi.hssf.record.*;
|
||||
import org.apache.poi.hssf.record.CellValueRecordInterface;
|
||||
import org.apache.poi.hssf.record.DVRecord;
|
||||
import org.apache.poi.hssf.record.EscherAggregate;
|
||||
import org.apache.poi.hssf.record.Record;
|
||||
import org.apache.poi.hssf.record.RowRecord;
|
||||
import org.apache.poi.hssf.record.SCLRecord;
|
||||
import org.apache.poi.hssf.record.WSBoolRecord;
|
||||
import org.apache.poi.hssf.record.WindowTwoRecord;
|
||||
import org.apache.poi.hssf.record.aggregates.DataValidityTable;
|
||||
import org.apache.poi.hssf.record.formula.Ptg;
|
||||
import org.apache.poi.hssf.record.formula.RefPtg;
|
||||
|
@ -367,6 +374,22 @@ public final class HSSFSheet {
|
|||
dvt.addDataValidation(dvRecord);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the DVRecords objects that are associated to this sheet
|
||||
* @return a list of DVRecord instances
|
||||
*/
|
||||
public List getDVRecords() {
|
||||
List dvRecords = new ArrayList();
|
||||
List records = sheet.getRecords();
|
||||
|
||||
for(int index=0; index<records.size(); index++) {
|
||||
if(records.get(index) instanceof DVRecord) {
|
||||
dvRecords.add(records.get(index));
|
||||
}
|
||||
}
|
||||
return dvRecords;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the visibility state for a given column.
|
||||
|
@ -1254,11 +1277,9 @@ public final class HSSFSheet {
|
|||
// Since it's a formula cell, process the
|
||||
// formula string, and look to see if
|
||||
// it contains any references
|
||||
FormulaParser fp = new FormulaParser(c.getCellFormula(), workbook);
|
||||
fp.parse();
|
||||
|
||||
// Look for references, and update if needed
|
||||
Ptg[] ptgs = fp.getRPNPtg();
|
||||
Ptg[] ptgs = FormulaParser.parse(c.getCellFormula(), workbook);
|
||||
boolean changed = false;
|
||||
for(int i=0; i<ptgs.length; i++) {
|
||||
if(ptgs[i] instanceof RefPtg) {
|
||||
|
@ -1275,7 +1296,7 @@ public final class HSSFSheet {
|
|||
// re-create the formula string
|
||||
if(changed) {
|
||||
c.setCellFormula(
|
||||
fp.toFormulaString(ptgs)
|
||||
FormulaParser.toFormulaString(workbook, ptgs)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue