图片下载JAVA 博客分类: 技术应用 JavaExcelFlex工作
程序员文章站
2024-02-28 21:14:22
...
// 页面form
OptActListNewForm actListForm = (OptActListNewForm)form;
// 转换为Flex转换数据类型
List<OptActListNew> optList = optActMonitorService.getDownLoadData(actListForm, user);
OptActListNew optAct = (OptActListNew)optList.get(0);
List listData = this.buildExcelData(optList);
response.setHeader("Content-Type", "application/force-download");
response.setHeader("Content-Type", "application/vnd.ms-excel");
String fileName = new String("xxx_xx".getBytes("GBK"),
"ISO-8859-1");
response.setHeader("Content-Disposition", "attachment;filename="
+ fileName + ".xls");
ServletOutputStream out = response.getOutputStream();
//创建excel工作薄
WritableWorkbook wwb = Workbook.createWorkbook(out);
//创建excel工作表
WritableSheet ws = wwb.createSheet("xxxx", 0);
//给出标题
WritableFont titleWF = new WritableFont(WritableFont.ARIAL, 20,
WritableFont.BOLD, false, UnderlineStyle.NO_UNDERLINE,
Colour.BLACK);
WritableCellFormat titleWCF = new WritableCellFormat(titleWF);
Label tileLab = new Label(5, 0, "xxxx", titleWCF);//加入标题
ws.addCell(tileLab);
//添加图片对象
ByteArrayOutputStream bos = null;
BufferedImage chart = null;
try
{
bos = new ByteArrayOutputStream();
chart = ImageIO.read(request.getInputStream());
ImageIO.write(chart, "jpeg", bos);
WritableImage img = new WritableImage(0, ws.getRows() + 1, 15, 26,
bos.toByteArray());
ws.addImage(img);
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
bos.close();
}
wwb.write();
wwb.close();
OptActListNewForm actListForm = (OptActListNewForm)form;
// 转换为Flex转换数据类型
List<OptActListNew> optList = optActMonitorService.getDownLoadData(actListForm, user);
OptActListNew optAct = (OptActListNew)optList.get(0);
List listData = this.buildExcelData(optList);
response.setHeader("Content-Type", "application/force-download");
response.setHeader("Content-Type", "application/vnd.ms-excel");
String fileName = new String("xxx_xx".getBytes("GBK"),
"ISO-8859-1");
response.setHeader("Content-Disposition", "attachment;filename="
+ fileName + ".xls");
ServletOutputStream out = response.getOutputStream();
//创建excel工作薄
WritableWorkbook wwb = Workbook.createWorkbook(out);
//创建excel工作表
WritableSheet ws = wwb.createSheet("xxxx", 0);
//给出标题
WritableFont titleWF = new WritableFont(WritableFont.ARIAL, 20,
WritableFont.BOLD, false, UnderlineStyle.NO_UNDERLINE,
Colour.BLACK);
WritableCellFormat titleWCF = new WritableCellFormat(titleWF);
Label tileLab = new Label(5, 0, "xxxx", titleWCF);//加入标题
ws.addCell(tileLab);
//添加图片对象
ByteArrayOutputStream bos = null;
BufferedImage chart = null;
try
{
bos = new ByteArrayOutputStream();
chart = ImageIO.read(request.getInputStream());
ImageIO.write(chart, "jpeg", bos);
WritableImage img = new WritableImage(0, ws.getRows() + 1, 15, 26,
bos.toByteArray());
ws.addImage(img);
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
bos.close();
}
wwb.write();
wwb.close();
推荐阅读
-
图片下载JAVA 博客分类: 技术应用 JavaExcelFlex工作
-
图片下载JAVA 博客分类: 技术应用 JavaExcelFlex工作
-
java web开发,bean数据放在request、response还是servletcontext中? 博客分类: 技术及貌似 BeanWebJava应用服务器JVM
-
java中导入导出Excel表格(jxl的API应用) 博客分类: java ExcelJava应用服务器工作浏览器
-
java中导入导出Excel表格(jxl的API应用) 博客分类: java ExcelJava应用服务器工作浏览器
-
Nexus和Maven安装配置 博客分类: java技术mavennexus maven企业应用nexus