I'm working on an application which get data from excel file and output one excel after few operations. I got 2 issues, the first one is that one :
On my main excel file, I have this value 170299024773
and in Excel it's appear like that 1.703E+11
and then on the output file I get 1.70299E+11
and the exact value is 170299000000
.
So as you see, it's not the value of the main file.
Morever, for this cell, I have the error "Number stored as text", and then I fix this error from Excel I got 1.70E+11
.
I saw few tips about the Nember stored a text and in particular DataFormatter but it's doesn't change anything in my case
The code I use to get data of excel sheet to array :
private static String[][] sheetToArray(org.apache.poi.ss.usermodel.Sheet sheet, int nbCol){
String[][] tmp = new String[sheet.getLastRowNum()+1][nbCol];
for (int i = 0; i < sheet.getLastRowNum()+1; i++) { //Config1 to array
Row row = sheet.getRow(i);
DataFormatter df = new DataFormatter();
for (int j = 0; j < nbCol; j++) {
Cell cellC1 = row.getCell(j);
tmp[i][j] = df.formatCellValue(cellC1);
}
}
return tmp;
}
Many thanks in advance guys...
Edit : I fix the wrong value adding
switch (cellD2.getCellTypeEnum()){
case STRING:
tmp[i][j] = df.formatCellValue(cellC1);
break;
case NUMERIC:
tmp[i][j] = String.valueOf(cellC1.getNumericCellValue());
}
}
But now, I have some decimal value added to my numeric state... To solve it I should use DataFormatter but in that case I will lost the right data