问题描述
我正在做一个大项目,其中包含许多excel文件。我需要使用Apache POI修改现有的Excel工作表。我陷入了困境,无法调用现有的excel文件。不确定,如何调用excel文件。
public void modifyExcel() {
try {
//File lfFile = new File(
//requestTypeDetailMap.getRequestTypeDetails().get("icr.xls".toupperCase()).getTemplateFile());
//FileInputStream file = new FileInputStream(lfFile);
FileInputStream file= new FileInputStream(new File("C:\\Excel.xls"));
hssfWorkbook workbook = new hssfWorkbook(file);
hssfSheet sheet = workbook.getSheetAt(0);
hssfCell cell = null;
//Retrieve the row and check for null
hssfRow sheetrow = sheet.getRow(0);
//Update the value of cell
cell = sheetrow.getCell(0);
cell.setCellValue("Pass");
file.close();
FileOutputStream outFile =new FileOutputStream(new File("C:\\Excel.xls"));
workbook.write(outFile);
outFile.close();
} catch (FileNotFoundException e) {
e.printstacktrace();
} catch (IOException e) {
e.printstacktrace();
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)