You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2006/04/24 14:27:43 UTC
DO NOT REPLY [Bug 39392] New: - Error in subsequent calls HSSFDataFormat.getFormat()
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39392>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=39392
Summary: Error in subsequent calls HSSFDataFormat.getFormat()
Product: POI
Version: 3.0-dev
Platform: Other
OS/Version: Windows 2000
Status: NEW
Severity: normal
Priority: P2
Component: HSSF
AssignedTo: poi-dev@jakarta.apache.org
ReportedBy: zdenek.hrib@seznam.cz
If the following code is executed, subsequent calls to dataFormat.getFormat()
will cause all the formated cells to have the last requested format instead of
the format that was set on them in previous call to dataFormat.getFormat()
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("new sheet");
HSSFRow row = sheet.createRow((short)0);
short iFormat = 0;
HSSFDataFormat dataFormat = wb.createDataFormat();
HSSFCell cell = row.createCell((short)0);
iFormat = dataFormat.getFormat("000000%");
cell.getCellStyle().setDataFormat(iFormat);
cell.setCellFormula("1/"+ String.valueOf(iFormat));
//cell.setCellValue("1");
//HSSFCell first_cell = cell;
cell = row.createCell((short)1);
iFormat = dataFormat.getFormat("00000%");
cell.getCellStyle().setDataFormat(iFormat);
cell.setCellFormula("1/"+ String.valueOf(iFormat));
//cell.setCellValue("1");
cell = row.createCell((short)2);
iFormat = dataFormat.getFormat("0000%");
cell.getCellStyle().setDataFormat(iFormat);
cell.setCellFormula("1/"+ String.valueOf(iFormat));
//cell.setCellValue("1");
//iFormat = dataFormat.getFormat("000000%");
//first_cell.getCellStyle().setDataFormat(iFormat);
FileOutputStream fileOut = new FileOutputStream("workbook.xls");
wb.write(fileOut);
fileOut.close();
Also using cell.setCellValue("1") looks like it is not working as it will not
cause the cell to effectivelly use any of the specified formats (set on the
cell before or after call to cell.setCellValue()), but that is another story...
Therefore in this example I am using cell.setCellFormula() with index number of
the format written into the sheet.
If the code
//HSSFCell first_cell = cell;
.
.
.
//iFormat = dataFormat.getFormat("000000%");
//first_cell.getCellStyle().setDataFormat(iFormat);
you will see format of all the touched cells set to 000000%.
--
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
---------------------------------------------------------------------
To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
Mailing List: http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/
DO NOT REPLY [Bug 39392] - Error in subsequent calls HSSFDataFormat.getFormat()
Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39392>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=39392
------- Additional Comments From zdenek.hrib@seznam.cz 2006-04-24 12:29 -------
Created an attachment (id=18162)
--> (http://issues.apache.org/bugzilla/attachment.cgi?id=18162&action=view)
example source
--
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
---------------------------------------------------------------------
To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
Mailing List: http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/
DO NOT REPLY [Bug 39392] - Error in subsequent calls HSSFDataFormat.getFormat()
Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39392>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=39392
------- Additional Comments From zdenek.hrib@seznam.cz 2006-04-24 12:31 -------
Created an attachment (id=18164)
--> (http://issues.apache.org/bugzilla/attachment.cgi?id=18164&action=view)
example result workbook file
--
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
---------------------------------------------------------------------
To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
Mailing List: http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/
DO NOT REPLY [Bug 39392] - Error in subsequent calls HSSFDataFormat.getFormat()
Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39392>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=39392
------- Additional Comments From zdenek.hrib@seznam.cz 2006-04-24 12:30 -------
Created an attachment (id=18163)
--> (http://issues.apache.org/bugzilla/attachment.cgi?id=18163&action=view)
compile and run batch file
--
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
---------------------------------------------------------------------
To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
Mailing List: http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/