Ich versuche Testdaten aus Excel zu lesen und bekam folgende Fehlermeldung: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
ich in Zelle in meinem Excel unter Verwendung der Formel: https://www.screencast.com/t/eepp6nWy571
Mein Excel-Funktion (gibt die Daten aus einer Zelle), wenn die Zelle als Text ist dann funktioniert es ohne Problem:
// 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";
}
}
Ich denke, die Nachricht ist klar. 'K1101.00' ist keine Nummer – Jens
Und ich verwende diese Formel in CELL = CONCATENATE (" K "; B3;". 00 ") Wie es möglich ist, diese Zelle zu lesen? –
Wie es möglich ist, jede Zelle als String zu lesen? –