// 取得模板文件存放的路径

ReadFilePath = ServletActionContext.getServletContext().getRealPath(ExcelTemplateFilePath);

 

// 取得临时模板文件存放的路径

SaveFilePath = ServletActionContext.getServletContext().getRealPath(TempSaveExcelTemplateFilePath);

// 创建临时模板文件存放的路径

IpFolder = new File(SaveFilePath);
if (IpFolder.exists()) {
if (deleteFile(IpFolder.toString())) {
IpFolder.mkdir();
}
} else {
IpFolder.mkdir();
}

// 复制模板文件到临时模板文件存放的路径

copyFile(new File(ReadFilePath), IpFolder);

// 读取临时路径中的模板文件到字符流里

FileInputStream fileInputStream = new FileInputStream(IpFolder);

// 创建workbook
Workbook book = WorkbookFactory.create(fileInputStream);

// 取得工作簿的第一个sheet
Sheet sheet = book.getSheetAt(0);

 

使用poi写excel文件
struts版本 需要的jar包
struts1.X poi-3.9-20121203.jar,poi-ooxml-3.9-20121203.jar,poi-ooxml-schemas-3.9-20121203.jar
struts2.3 poi-3.9-20121203.jar,poi-ooxml-3.9-20121203.jar,poi-ooxml-schemas-3.9-20121203.jar
/ooxml-lib/dom4j-1.6.1.jar,/ooxml-lib/xmlbeans-2.3.0.jar

相关文章:

  • 2022-01-14
  • 2022-12-23
  • 2021-08-12
  • 2022-12-23
  • 2022-12-23
  • 2021-09-05
  • 2021-10-25
  • 2021-04-24
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-06-27
  • 2021-06-06
  • 2022-12-23
  • 2022-12-23
  • 2021-11-18
相关资源
相似解决方案