我有一个科学计数法数字,表示
科学符号编号存储在Excel工作表中,我需要将2.97112E + 13转换为其原始编号。我尝试了两个都不起作用:
int val = new BigDecimal().intValue();
ouput -1383753728
和
String val = new BigDecimal("2.97112E+13").toPlainString();
output 29711200000000
这是我的代码:
Workbook workbook = WorkbookFactory.create(new File(SAMPLE_XLSX_FILE_PATH));
int trys=0;
Boolean flag=true;
// 1. You can obtain a sheetIterator and iterate over it
Iterator<Sheet> sheetIterator = workbook.sheetIterator();
while (sheetIterator.hasNext()) {
Sheet sheet = sheetIterator.next();
// System.out.println("=> " + sheet.getSheetName());
}
Sheet sheet = workbook.getSheetAt(0);
String cellValue=" ";
// Create a DataFormatter to format and get each cell's value as String
DataFormatter dataFormatter = new DataFormatter();
// 1. You can obtain a rowIterator and columnIterator and iterate over them
// System.out.println("\n\nIterating over Rows and Columns using Iterator\n");
Iterator<Row> rowIterator = sheet.rowIterator();
while (rowIterator.hasNext()) {
Row row = rowIterator.next();
// Now let's iterate over the columns of the current row
Iterator<Cell> cellIterator = row.cellIterator();
while (cellIterator.hasNext()) {
Cell cell = cellIterator.next();
Boolean h=true;
String cellValue = dataFormatter.formatCellValue(cell);
此处cellValue是存储单元格值的字符串