ASF Bugzilla – Attachment 25467 Details for
Bug 49322
Fail to read the content of a cell after writing the file
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
The test case to reproduce the bug
TestBugPoi.java (text/x-java-source), 1.96 KB, created by
Benjamin Robin
on 2010-05-20 14:42:53 UTC
(
hide
)
Description:
The test case to reproduce the bug
Filename:
MIME Type:
Creator:
Benjamin Robin
Created:
2010-05-20 14:42:53 UTC
Size:
1.96 KB
patch
obsolete
> >import java.io.FileOutputStream; > >import org.apache.poi.ss.usermodel.Cell; >import org.apache.poi.ss.usermodel.DataFormatter; >import org.apache.poi.ss.usermodel.Row; >import org.apache.poi.ss.usermodel.Sheet; >import org.apache.poi.xssf.usermodel.XSSFCellStyle; >import org.apache.poi.xssf.usermodel.XSSFWorkbook; > > >public class TestBugPoi { > > public static void main(String[] args) { > try { > XSSFWorkbook workbook = new XSSFWorkbook(); > > //Create the sheet and the first cell > workbook.createSheet(); > Sheet sheet = workbook.getSheetAt(0); > Row row = sheet.createRow(0); > row.getCell(0, Row.CREATE_NULL_AS_BLANK); > > XSSFCellStyle style = workbook.createCellStyle(); > Cell cell = sheet.getRow(0).getCell(2, Row.CREATE_NULL_AS_BLANK); > cell.setCellStyle(style); > > cell = sheet.getRow(0).getCell(1, Row.CREATE_NULL_AS_BLANK); > cell.setCellStyle(style); > > System.out.println(new DataFormatter().formatCellValue(cell, //Success > workbook.getCreationHelper().createFormulaEvaluator())); > > FileOutputStream modTemplateOut = new FileOutputStream("BookOut.xlsx"); > workbook.write(modTemplateOut); > modTemplateOut.close(); > > if(false) { //Same behavior for true > sheet = workbook.getSheetAt(0); > cell = sheet.getRow(0).getCell(1, Row.CREATE_NULL_AS_BLANK); > } > > try { > System.out.println(new DataFormatter().formatCellValue(cell, //Fail > workbook.getCreationHelper().createFormulaEvaluator())); > } catch (Exception e) { > e.printStackTrace(); > } > > //If we open the file: BookOut.xlsx and try to read the cell again, > //it will no fail > XSSFWorkbook wb = new XSSFWorkbook("BookOut.xlsx"); > sheet = wb.getSheetAt(0); > cell = sheet.getRow(0).getCell(1, Row.CREATE_NULL_AS_BLANK); > > System.out.println(new DataFormatter().formatCellValue(cell, //Ok > wb.getCreationHelper().createFormulaEvaluator())); > > } catch (Exception e) { > e.printStackTrace(); > } > } >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 49322
: 25467