List list = departReportService.excelDepartReport(params, currPage, pageSize);
String downpath = "temp_xml/user";
String filepath = getServlet().getServletContext().getRealPath(File.separator + downpath);
SimpleDateFormat fts = new SimpleDateFormat("yyyyMMddHHmmss");
String sdate = fts.format(new Date());
String filename = "用户报表" + "_" + sdate + ".xls";
String downnamepath = downpath + "/" + filename;
String linuxdownnamepath = downnamepath.replace("\\", "/");
// 判断目录是否存在,不存在创建
FileUtil.DirIsExiste(filepath);
String filenamepath = filepath + "\\" + filename;
String linuxfilenamepath = filenamepath.replace("\\", "/");
ExcelCreator creator = new ExcelCreator(linuxfilenamepath, filename,null, list);
creator.createXLS();
DownLoadFileTools.downloadFile(request,response, filename, linuxdownnamepath);
/**
* 下载excel到自定目录 <功能详细描述>
*
* @param title
* 文件标题
* @param fileContext
* 文件内容
* @param fileName
* 文件名
* @param format
* Excel格式
* @return void [返回类型说明]
* @exception throws
* [违例类型] [违例说明]
*/
public void createExcelFile(String title, List fileContext,
String fileName, SheetFormat format, String templet) {
// 导出文件路径
String filePath = PlatformConfig.getUseDataPath()
+ Constants.EXPORT_PATH;
// 判断目录是否存在,不存在创建
FileUtil.DirIsExiste(filePath);
filePath = filePath + fileName;
String linuxfilenamepath = filePath.replace("\\", "/");
ExcelCreator creator = new ExcelCreator(linuxfilenamepath, title, null,
fileContext, templet);
if (null != format) {
creator.setFormat(format);
} else {
creator.setFormat(new SheetFormat());
}
creator.createXLS();
}
分享到:
相关推荐
在本示例中,我们将深入探讨如何使用Aspose库在.NET环境中根据模板导出Excel电子表格。这个过程涉及到多个步骤和技术,包括理解Aspose的API、模板设计以及数据注入。 首先,Aspose库提供了强大的Excel操作功能,...
基于SpringBoot和POI实现单线程和多线程导出Excel.zip基于SpringBoot和POI实现单线程和多线程导出Excel.zip基于SpringBoot和POI实现单线程和多线程导出Excel.zip基于SpringBoot和POI实现单线程和多线程导出Excel.zip...
在本案例中,我们关注的是如何使用 Apache POI 库来导出 Excel 文件,特别是根据模板导出和简单列表导出。下面将详细介绍这个过程。 1. **Apache POI 概述** Apache POI 提供了 Java API 来读写 Microsoft Office ...
"pb导出excel2007"这个主题涉及到的是如何在PowerBuilder中将数据窗口(DataWindow)的内容导出到Excel 2007格式的文件中。在实际开发中,有时我们需要将PB的数据窗口数据导出到Excel以便于分析、处理或分享,而这个...
Delphi DBGrid 导出 Excel 2010 Delphi DBGrid 是一个强大的数据-grid 控件,经常用于展示大量数据。然而,在实际应用中,我们经常需要将 DBGrid 中的数据导出到其他格式,例如 Excel,以便于数据分析和处理。下面...
JavaScript 导出 Excel 文件 JavaScript 导出 Excel 文件是指使用 JavaScript 语言将 HTML 表格数据导出到 Excel 文件中的过程。在本文中,我们将探讨如何使用 JavaScript 实现 Excel 文件的导出,并介绍相关的技术...