ASF Bugzilla – Attachment 30792 Details for
Bug 55473
DataFormatter.formatCellValue(cell) throws IllegalArgumentException when the format is mm/dd/yyyy;;; and value is 0
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
Java File for reading excel which gives IllegalArgumentException.
PoiReadExcelFile.java (text/plain), 1.56 KB, created by
Narayan
on 2013-09-02 07:01:08 UTC
(
hide
)
Description:
Java File for reading excel which gives IllegalArgumentException.
Filename:
MIME Type:
Creator:
Narayan
Created:
2013-09-02 07:01:08 UTC
Size:
1.56 KB
patch
obsolete
>package informatica.main; > >import java.io.File; >import java.io.FileInputStream; >import java.util.Iterator; > >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.xssf.usermodel.XSSFSheet; >import org.apache.poi.xssf.usermodel.XSSFWorkbook; > >public class PoiReadExcelFile { > public static void main(String[] args) { > try { > FileInputStream file = new FileInputStream(new File("c:\\test.xlsx")); > > // Create Workbook instance holding reference to .xlsx file > XSSFWorkbook workbook = new XSSFWorkbook(file); > > // Get first/desired sheet from the workbook > XSSFSheet sheet = workbook.getSheetAt(0); > > // Iterate through each rows one by one > Iterator<Row> rowIterator = sheet.iterator(); > while (rowIterator.hasNext()) { > Row row = rowIterator.next(); > // For each row, iterate through all the columns > Iterator<Cell> cellIterator = row.cellIterator(); > > while (cellIterator.hasNext()) { > Cell cell = cellIterator.next(); > // Check the cell type and format accordingly > switch (cell.getCellType()) { > case Cell.CELL_TYPE_NUMERIC: > DataFormatter df = new DataFormatter(); > String formated = df.formatCellValue(cell); > System.out.print(formated + "\t"); > break; > case Cell.CELL_TYPE_STRING: > System.out.print(cell.getStringCellValue() + "\t"); > break; > } > } > System.out.println(""); > } > file.close(); > } 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 55473
:
30756
| 30792