Je suis en train de lire des données de test à partir d'Excel et a l'erreur suivante:java.lang.NumberFormatException: FloatingDecimal.readJavaFormatString
java.lang.NumberFormatException: For input string: "K1101.00"
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2043
at sun.misc.FloatingDecimal.parseDouble(FloatingDecimal.java:110)
at org.apache.poi.xssf.usermodel.XSSFCell.getNumericCellValue(XSSFCell.java:197)
at utility.excel_reader.getCellData(excel_reader.java:151)
at utility.Utility.getData(Utility.java:164)
at testCases.FinCalculator.inputValue(FinCalculator.java:85)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
row 3 or column 10 does not exist in xls
J'utilise la formule dans la cellule dans mon excel: https://www.screencast.com/t/eepp6nWy571
fonction My Excel (renvoie les données d'une cellule), si la cellule est sous forme de texte il fonctionne sans problème:
// returns the data from a cell
public String getCellData(String sheetName,int colNum,int rowNum){
try{
if(rowNum <=0)
return "";
int index = workbook.getSheetIndex(sheetName);
if(index==-1)
return "";
sheet = workbook.getSheetAt(index);
row = sheet.getRow(rowNum-1);
if(row==null)
return "";
cell = row.getCell(colNum);
if(cell==null)
return "";
if(cell.getCellType()==Cell.CELL_TYPE_STRING)
return cell.getStringCellValue();
else if(cell.getCellType()==Cell.CELL_TYPE_NUMERIC || cell.getCellType()==Cell.CELL_TYPE_FORMULA){
String cellText = String.valueOf(cell.getNumericCellValue());
if (HSSFDateUtil.isCellDateFormatted(cell)) {
// format in form of M/D/YY
double d = cell.getNumericCellValue();
Calendar cal =Calendar.getInstance();
cal.setTime(HSSFDateUtil.getJavaDate(d));
cellText =
(String.valueOf(cal.get(Calendar.YEAR))).substring(2);
cellText = cal.get(Calendar.MONTH)+1 + "/" +
cal.get(Calendar.DAY_OF_MONTH) + "/" +
cellText;
}
return cellText;
}else if(cell.getCellType()==Cell.CELL_TYPE_BLANK)
return "";
else
return String.valueOf(cell.getBooleanCellValue());
}
catch(Exception e){
e.printStackTrace();
return "row "+rowNum+" or column "+colNum +" does not exist in xls";
}
}
Je pense que le message est clair. 'K1101.00' n'est pas un nombre – Jens
Et j'utilise cette formule dans CELL = CONCATENER (" K "; B3;". 00 ") Comment est-il possible de lire cette cellule? –
Comment est-il possible de lire chaque cellule sous forme de chaîne? –