62,614
社区成员
发帖
与我相关
我的任务
分享
List<VCloTemplate> templates = ts.selectCloTemplate(record); //查询模版记录, 按年份月份
ExcelFactoryTemplateCost<List<VCloTemplate>> excelInstance = new ExcelFactoryTemplateCost<>(templates);
File file = FileUtil.getFile(request.getSession().getServletContext().getRealPath("/")+"xls/" + excelInstance.getExcelAllName()); //创建文件
//创建OutputSream, 写入Excel文件
OutputStream output= null;
try {
output = new FileOutputStream(file);
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("1");
sheet.createRow(0).createCell(0).setCellValue("1");
wb.write(output);
// ??????????????????????????????????????excelInstance.getWorkbook().write();
//返回访问路径
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getContextPath()+"/";
String path = basePath+"xls/" + excelInstance.getExcelAllName();
response.setCharacterEncoding("UTF-8");
response.getWriter().write(path);
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
output.close();
} catch (IOException e) {
e.printStackTrace();
}
}
for(int i=0;i<[sheet的行数];i++){
for (int j=9;j<[这一行的列数];j++){
this.wb.getSheet(this.excelName).createRow(i).createCell(j).setCellValue("OK");
}
System.out.println();
}
for(int i=0;i<10;i++){
for (int j=9;j<20;j++){
this.wb.getSheet(this.excelName).createRow(i).createCell(j).setCellValue("OK");
}
System.out.println();
}