[英]How to read the excel file from java code which is external to the system?
[英]How to read TRUE/FALSE value from Excel file through Java code
我正在通過Java代碼從Excel中讀取true
/ false
作為值。 閱讀后,我得到1/0作為輸出。
OPCPackage pkg = OPCPackage.open(fileURL);
System.out.println(pkg);
XSSFReader reader = new XSSFReader(pkg);
System.out.println(reader);
SharedStringsTable sst = reader.getSharedStringsTable();
System.out.println(sst);
InputStream workbookData = reader.getWorkbookData();
我應該怎么做才能將true
視為true
並將false
視為false
。
我通常有一段看起來像這樣的代碼:
Workbook workbook = WorkboookFactory.create(...); // File, InputStream, etc
Cell cell = workbook.getSheet("foo").getRow(x).getCell(y);
Object value;
int cellType = cell.getCellType() == Cell.CELL_TYPE_FORMULA
? cell.getCachedFormulaResultType() : cell.getCellType();
switch (cellType) {
case Cell.CELL_TYPE_BOOLEAN:
value = cell.getBooleanCellValue();
break;
case Cell.CELL_TYPE_NUMERIC:
value = cell.getNumericCellValue();
break;
...
}
doStuff(value);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.