jfeeChart生成图在jsp页面上,怎么把它导出到excel中 如题,哪个大哥知道啊 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 首先将jfreeChart生成的图片保存到服务器再用jxl解析输出到excel(jar包自己下载)File file = new File("D:\\2.png"); //图片路径 jxl.write.WritableImage f = new jxl.write.WritableImage(1,2,2,2,file); ws.addImage(f); //写入Exel工作表 wwb.write(); //关闭Excel工作薄对象 wwb.close(); 给你个思路,你可以先:1、String tempDirName = System.getProperty("java.io.tmpdir");//获取临时文件路径String filename1 = ParamUtils.getParameter(request, "filename","");if (!filename1.equals("")) { filename1 = tempDirName + "\\" + filename1;//图片1}ExcelParamter ep = new ExcelParamter();//这是一个Beanep.setFilename1(filename1);//把你需要的数据存入bean,把这个ep当做参数传入后台2、// 添加图片资料,到此工作簿for (int i = 0; i < ep.getImgnum(); i++) {... /* * 生成一张图片的方法 *(你根据你自己的情况设置) */ public static void getCreateImgOne(Workbook wb, Sheet sheet, Drawing drawing, CreationHelper helper, ExcelParamter ep) { try { // -----生成第一张图 byte[] bytes; InputStream is = new FileInputStream(ep.getFilename()); bytes = IOUtils.toByteArray(is); int pictureIdx = wb.addPicture(bytes, Workbook.PICTURE_TYPE_PNG); is.close(); // 添加图片形状 ClientAnchor anchor = helper.createClientAnchor(); // 设置左上角的图片,设置图片显示 anchor.setCol1(ep.getCol());// 设置距左边的距离(数字代表几个单元格) anchor.setRow1(ep.getRow());// 设置距上边的距离(数字代表几个单元格) Picture pict = drawing.createPicture(anchor, pictureIdx); pict.resize(1.3);//设置图片大小 // auto-size picture relative to its top-left corner 图片相对于左上角 //pict.resize(); // -----结束 } catch (IOException e) { e.printStackTrace(); } }不知你能看明白不,写的挺乱。 struts2 正则表达式验证不起作用。 jbpm 怎样执行当前的任务 学习方向迷失问题 求助:如何使用hibernate自带的分页功能,在jsp页面上实现分页功能。 struts+hibernate通用的分页程序(求代码) 急救:关于数据库的更新问题 赛扬1G+512内存,运行jbuliderX+weblogic,速度会不会很慢? 关于struts一个用法,不解,请教 为什么我的JB9中新建文件时,没有EJB部分 大量数据列转横,循环处理率问题 大虾来帮忙下!用Spring事务,做测试,数据没有回滚! 省和城市级联的代码
再用jxl解析输出到excel(jar包自己下载)File file = new File("D:\\2.png"); //图片路径
jxl.write.WritableImage f = new jxl.write.WritableImage(1,2,2,2,file);
ws.addImage(f);
//写入Exel工作表
wwb.write();
//关闭Excel工作薄对象
wwb.close();
1、
String tempDirName = System.getProperty("java.io.tmpdir");//获取临时文件路径
String filename1 = ParamUtils.getParameter(request, "filename","");
if (!filename1.equals("")) {
filename1 = tempDirName + "\\" + filename1;//图片1
}
ExcelParamter ep = new ExcelParamter();//这是一个Bean
ep.setFilename1(filename1);
//把你需要的数据存入bean,把这个ep当做参数传入后台
2、
// 添加图片资料,到此工作簿
for (int i = 0; i < ep.getImgnum(); i++) {...
/*
* 生成一张图片的方法
*(你根据你自己的情况设置)
*/
public static void getCreateImgOne(Workbook wb, Sheet sheet,
Drawing drawing, CreationHelper helper, ExcelParamter ep) {
try {
// -----生成第一张图
byte[] bytes;
InputStream is = new FileInputStream(ep.getFilename());
bytes = IOUtils.toByteArray(is);
int pictureIdx = wb.addPicture(bytes, Workbook.PICTURE_TYPE_PNG);
is.close();
// 添加图片形状
ClientAnchor anchor = helper.createClientAnchor();
// 设置左上角的图片,设置图片显示
anchor.setCol1(ep.getCol());// 设置距左边的距离(数字代表几个单元格)
anchor.setRow1(ep.getRow());// 设置距上边的距离(数字代表几个单元格)
Picture pict = drawing.createPicture(anchor, pictureIdx);
pict.resize(1.3);//设置图片大小
// auto-size picture relative to its top-left corner 图片相对于左上角
//pict.resize();
// -----结束
} catch (IOException e) {
e.printStackTrace();
}
}不知你能看明白不,写的挺乱。