我需要读取Excel中的格式化单元格,其中使用Apache POI将数字作为文本存储在Java中,并将单元格的内容作为原始格式的字符串提取。
答案 0 :(得分:0)
这对我有用(使用Apache POI 3.11):
FileInputStream fileInputStream = new FileInputStream("test.xlsx");
Workbook workBook = new XSSFWorkbook(fileInputStream);
Sheet sheet = workBook.getSheetAt(0);
CellReference cellReference = new CellReference("A1");
Row row = sheet.getRow(cellReference.getRow());
Cell cell = row.getCell(cellReference.getCol());
System.out.println(cell.getStringCellValue());