field_5_last_column = colRelative.setBoolean( field_5_last_column, rel );
}
-
- /*public String getArea(){
- RangeAddress ra = new RangeAddress( getFirstColumn(),getFirstRow() + 1, getLastColumn(), getLastRow() + 1);
- String result = ra.getAddress();
-
- return result;
- }*/
-
- public void setArea( String ref )
- {
+ public void setArea( String ref ) {
AreaReference ar = new AreaReference( ref );
CellReference frstCell = ar.getFirstCell();
CellReference lastCell = ar.getLastCell();
- setFirstRow( (short) frstCell.getRow() );
- setFirstColumn( frstCell.getCol() );
- setLastRow( (short) lastCell.getRow() );
- setLastColumn( lastCell.getCol() );
- setFirstColRelative( !frstCell.isColAbsolute() );
- setLastColRelative( !lastCell.isColAbsolute() );
- setFirstRowRelative( !frstCell.isRowAbsolute() );
- setLastRowRelative( !lastCell.isRowAbsolute() );
+ setFirstRow(frstCell.getRow());
+ setFirstColumn(frstCell.getCol());
+ setLastRow(lastCell.getRow());
+ setLastColumn(lastCell.getCol());
+ setFirstColRelative(!frstCell.isColAbsolute());
+ setLastColRelative(!lastCell.isColAbsolute());
+ setFirstRowRelative(!frstCell.isRowAbsolute());
+ setLastRowRelative(!lastCell.isRowAbsolute());
}
/**
import org.apache.poi.hssf.model.FormulaParser.FormulaParseException;
import org.apache.poi.hssf.record.formula.AbstractFunctionPtg;
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.AttrPtg;
import org.apache.poi.hssf.record.formula.BoolPtg;
}
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());
+
+ }
+}
\ No newline at end of file