代码:
String xf = "D:/AndroidResults/Results.xls";
File outFile = new File(xf);
FileInputStream myStream1 = new FileInputStream(outFile);
HSSFWorkbook myWBook = new HSSFWorkbook (myStream1);
HSSFSheet oSheet = myWBook.getSheet("Results");
HSSFRow row = oSheet.getRow(rowNum);
HSSFCell cell = row.getCell(colNum);
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
cell.setCellValue(xlData);
FileOutputStream fOut = new FileOutputStream(outFile);
myWBook.write(fOut);
fOut.flush();
fOut.close();
例外:
java.io.FileNotFoundException: /D:/AndroidResults/Results.xls (No such file or directory)
可能是它试图在移动设备而不是计算机中查找文件。但是如何处理这种情况,我必须将数据写入计算机中的 excel。
请帮忙。
感谢:D