Partial fix for bug 45358 - parsing area refs with rows above 32767

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@690772 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Josh Micich 2008-08-31 19:44:11 +00:00
parent 908e676d57
commit a78cd8eb0a
2 changed files with 36 additions and 19 deletions

View File

@ -235,29 +235,20 @@ public final class Area3DPtg extends OperandPtg implements AreaI {
field_5_last_column = colRelative.setBoolean( field_5_last_column, rel ); field_5_last_column = colRelative.setBoolean( field_5_last_column, rel );
} }
public void setArea( String ref ) {
/*public String getArea(){
RangeAddress ra = new RangeAddress( getFirstColumn(),getFirstRow() + 1, getLastColumn(), getLastRow() + 1);
String result = ra.getAddress();
return result;
}*/
public void setArea( String ref )
{
AreaReference ar = new AreaReference( ref ); AreaReference ar = new AreaReference( ref );
CellReference frstCell = ar.getFirstCell(); CellReference frstCell = ar.getFirstCell();
CellReference lastCell = ar.getLastCell(); CellReference lastCell = ar.getLastCell();
setFirstRow( (short) frstCell.getRow() ); setFirstRow(frstCell.getRow());
setFirstColumn( frstCell.getCol() ); setFirstColumn(frstCell.getCol());
setLastRow( (short) lastCell.getRow() ); setLastRow(lastCell.getRow());
setLastColumn( lastCell.getCol() ); setLastColumn(lastCell.getCol());
setFirstColRelative( !frstCell.isColAbsolute() ); setFirstColRelative(!frstCell.isColAbsolute());
setLastColRelative( !lastCell.isColAbsolute() ); setLastColRelative(!lastCell.isColAbsolute());
setFirstRowRelative( !frstCell.isRowAbsolute() ); setFirstRowRelative(!frstCell.isRowAbsolute());
setLastRowRelative( !lastCell.isRowAbsolute() ); setLastRowRelative(!lastCell.isRowAbsolute());
} }
/** /**

View File

@ -24,6 +24,7 @@ import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.hssf.model.FormulaParser.FormulaParseException; import org.apache.poi.hssf.model.FormulaParser.FormulaParseException;
import org.apache.poi.hssf.record.formula.AbstractFunctionPtg; import org.apache.poi.hssf.record.formula.AbstractFunctionPtg;
import org.apache.poi.hssf.record.formula.AddPtg; import org.apache.poi.hssf.record.formula.AddPtg;
import org.apache.poi.hssf.record.formula.AreaI;
import org.apache.poi.hssf.record.formula.AreaPtg; import org.apache.poi.hssf.record.formula.AreaPtg;
import org.apache.poi.hssf.record.formula.AttrPtg; import org.apache.poi.hssf.record.formula.AttrPtg;
import org.apache.poi.hssf.record.formula.BoolPtg; import org.apache.poi.hssf.record.formula.BoolPtg;
@ -836,4 +837,29 @@ public final class TestFormulaParser extends TestCase {
} }
cell.setCellFormula("count(fp1)"); // plain cell ref, col is in range cell.setCellFormula("count(fp1)"); // plain cell ref, col is in range
} }
public void testParseAreaRefHighRow_bug45358() {
Ptg[] ptgs;
AreaI aptg;
HSSFWorkbook book = new HSSFWorkbook();
book.createSheet("Sheet1");
ptgs = FormulaParser.parse("Sheet1!A10:A40000", book);
aptg = (AreaI) ptgs[0];
if (aptg.getLastRow() == -25537) {
throw new AssertionFailedError("Identified bug 45358");
}
assertEquals(39999, aptg.getLastRow());
ptgs = FormulaParser.parse("Sheet1!A10:A65536", book);
aptg = (AreaI) ptgs[0];
assertEquals(65535, aptg.getLastRow());
// plain area refs should be ok too
ptgs = parseFormula("A10:A65536");
aptg = (AreaI) ptgs[0];
assertEquals(65535, aptg.getLastRow());
}
} }