https://issues.apache.org/bugzilla/show_bug.cgi?id=50211
Summary: autoSizeColumn calculates wrong column size of formula
cells
Product: POI
Version: 3.7-dev
Platform: Sun
OS/Version: Solaris
Status: NEW
Severity: normal
Priority: P2
Component: HSSF
AssignedTo: [email protected]
ReportedBy: [email protected]
HSSFSheet.autoSizeColumn calculates the size of a cell (which contains a
formula) depending on the size of the formula, not on the size of the result of
the formula. To reproduce this error, see listing below. Cell 0 and Cell 1
should have the same column size, because they both evaluate to '1'. In the
case below, Cell 1 is much wider than Cell 0.
import org.apache.poi.hssf.usermodel.*;
import java.io.*;
public class AutosizeError
{
public static void main(String args[])
{
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet("Autosize error");
HSSFRow row = sheet.createRow(0);
HSSFCell cell0 = row.createCell(0);
HSSFCell cell1 = row.createCell(1);
cell0.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
cell0.setCellValue(1);
sheet.autoSizeColumn(0);
cell1.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
cell1.setCellFormula("A1+2*A1-2*A1");
sheet.autoSizeColumn(1);
try {
FileOutputStream out = new FileOutputStream("Autosize_Error.xls");
workbook.write(out);
out.close();
} catch (Exception e) {
e.printStackTrace();
}
} // main
}
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]