- 浏览: 888463 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (354)
- Java学习 (122)
- jstl el表达式 (2)
- struts2 标签 (6)
- Ibatis (14)
- S2SH (3)
- struts2 json (2)
- JDK1.6-JDK1.5 (1)
- spring mvc (1)
- 工作项目开发 (8)
- jxl (3)
- jqgrid (9)
- POI (10)
- jQuery (9)
- itext (11)
- oracle (56)
- js (20)
- treegrid (1)
- myeclipse (4)
- Jforum (1)
- iphone (2)
- 角色权限 (1)
- Log4J (5)
- WebService (1)
- spring定时 (1)
- swfupload (12)
- Servlet (1)
- KindEditor (1)
- Java学习,httpclient (2)
- http (4)
- datagrid (1)
- KinSlideshow (1)
- android (7)
- html (1)
- CSS (1)
- 正则表达式 (3)
- easyui (6)
- JSONP (1)
- SQLServer (1)
- tomcat (2)
- Spring (4)
- Jquery plugins (2)
- windows7 (3)
- bootstrap (1)
- FreeMarker (1)
- flex (1)
- ExtJS (6)
- tTP-Link (1)
- MySQL (4)
- JavaScript (3)
- Notepad++ (1)
- ora (1)
- C语言 (1)
- 计算机 (1)
- DWR (2)
- 吉他 (1)
- hibernate (1)
- eclipse (1)
最新评论
-
天使建站:
这里的这篇文章写得很好:http://www.aijquery ...
jS 如何删除二维数组的重复项 -
羽翼的心动:
POI处理的格式单一,无法导出格式比较复杂的表格。POI不能使 ...
poi合并单元格同时导出excel -
zhixinhuacom:
jqgrid 按回车键默认提交数据,怎么做才能时回车不提交数据 ...
JQgrid要实现在jqGrid表格上动态的加行、删行,最后点击“保存”按钮,与后台交互,保存数据 -
w_mojian180:
nice 很多情况都是因为引入文件导入
Uncaught SyntaxError: Unexpected token < -
springdata_springmvc:
bootstrap demo实例教程源代码下载:http:// ...
bootstrap-switch开关按钮表单插件
import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import javax.swing.ImageIcon; import jxl.Workbook; import jxl.write.WritableImage; public class Test { public static void writeImageExcel(OutputStream os) throws Exception { //一定要流的形式创建这个对象 jxl.write.WritableWorkbook wwb = Workbook.createWorkbook(os); jxl.write.WritableSheet ws = wwb.createSheet("写入图片", 0); File image = new File("d:\\22.png"); // ImageIcon imageIcon = new ImageIcon(Toolkit.getDefaultToolkit().getImage("d:\\22.png")); // // int height = imageIcon.getIconHeight(); // int width = imageIcon.getIconWidth(); // System.out.println(height + " "+ width); java.awt.image.BufferedImage bi7 = null; try { bi7 = javax.imageio.ImageIO.read(image); } catch (IOException e) { e.printStackTrace(); } int picWidth = bi7.getWidth(); // 图片宽, 像素 150 int picHeight = bi7.getHeight(); // 图片高, 像素 105 //test System.out.println("--1703"); System.out.println("Width=" + picWidth ); System.out.println("Height=" + picHeight ); // 输入参数, 图片显示的位置 double picBeginCol = 1.2; double picBeginRow = 1.2; /* 实际像素: 150/105 = 2.78 cm / 3.97 cm = 4832 / 1590 实际像素: 300/210 = 2倍大小 = 9600 / 3150 比率: 32 / 15 */ // 计算参数( picCellWidth, picCellHeight ), 图片显示大小, 默认 100% 显示: begin // 图片cell宽度 = 图片实际跨越每个cell所占长度的相对各个cell ratio的和 // 方法: 根据起始位置,计算图片实际跨越的区域, 然后计算相对ratio,然后累加 // double picCellWidth = 0.0; // 是 cell的跨越个数, 可小数 double picCellHeight = 0.0; // wc = ws.getWritableCell( picBeginCol, picBeginRow ); // 列,行 // ws.getColumnView( picBeginCol ).getSize(); // ws.getRowView( picBeginRow ).getSize(); int _picWidth = picWidth * 32 ; // pic的宽度,循环递减, 是jxl的宽度单位, 32/15 for(int x=0; x< 1234; x++) { int bc = (int)Math.floor( picBeginCol + x ); // 3.6 to 3 // 本次循环所在cell位置 System.out.println("x =" + x ); //test System.out.println("bc =" + bc ); //test int v = ws.getColumnView( bc ).getSize(); //本次cell宽,jxl单位 double _offset0 = 0.0; // >= 0 // 离左边的偏移量, 仅 x = 0 的时候才用 if( 0 == x ) _offset0 = ( picBeginCol - bc ) * v ; // System.out.println("_offset0 =" + _offset0 ); //test System.out.println("_picWidth =" + _picWidth ); //test System.out.println("v =" + v ); //test System.out.println("cw 00=" + ws.getColumnView( 0 ).getSize() ); //test System.out.println("ch 00=" + ws.getRowView( 0 ).getSize() ); //test System.out.println("cw 22=" + ws.getColumnView( 2 ).getSize() ); //test System.out.println("ch 22=" + ws.getRowView( 2 ).getSize() ); //test if( 0.0 + _offset0 + _picWidth > v ) // _picWidth 剩余长度超过一个cell时 { // 计算本次cell内, pic 所占 ratio值, 累加到 picCellWidth double _ratio = 1.0; if( 0 == x ) _ratio = ( 0.0 + v - _offset0 ) / v; System.out.println("_ratio =" + _ratio ); //test // picCellWidth += 1.0; picCellWidth += _ratio; _picWidth -= (int)( 0.0 + v - _offset0 ); // int } else // _picWidth 剩余长度在一个cell内时 { double _ratio = 0.0; if( v != 0 ) _ratio = ( 0.0 + _picWidth ) / v; picCellWidth += _ratio; System.out.println("for: picCellWidth =" + picCellWidth ); //test break; } if( x >= 1233 ) {} } // for // 此时 picCellWidth 是图片实际的值了 // int _picHeight = picHeight * 15 ; // pic的高度,循环递减, 是jxl的高度单位, 32/15 for(int x=0; x< 1234; x++) { int bc = (int)Math.floor( picBeginRow + x ); // 3.6 to 3 // 本次循环所在cell位置 int v = ws.getRowView( bc ).getSize(); //本次cell高,jxl单位 double _offset0 = 0.0; // >= 0 // 离顶部的偏移量, 仅 x = 0 的时候才用 if( 0 == x ) _offset0 = ( picBeginRow - bc ) * v ; // if( 0.0 + _offset0 + _picHeight > v ) // _picHeight 剩余长度超过一个cell时 { // 计算本次cell内, pic 所占 ratio值, 累加到 picCellHeight double _ratio = 1.0; if( 0 == x ) _ratio = ( 0.0 + v - _offset0 ) / v; // picCellHeight += 1.0; picCellHeight += _ratio; _picHeight -= (int)( 0.0 + v - _offset0 ); // int } else // _picHeight 剩余长度在一个cell内时 { double _ratio = 0.0; if( v != 0 ) _ratio = ( 0.0 + _picHeight ) / v; picCellHeight += _ratio; break; } if( x >= 1233 ) {} } // for // 此时 picCellHeight 是图片实际的值了 // 计算参数( picCellWidth, picCellHeight ), 图片显示大小, 默认 100% 显示: end //test System.out.println("picBeginCol=" + picBeginCol ); System.out.println("picBeginRow=" + picBeginRow ); System.out.println("picCellWidth=" + picCellWidth ); System.out.println("picCellHeight=" + picCellHeight ); WritableImage wimage = new WritableImage(0, 0, picCellWidth, picCellHeight, image); //WritableImage wimage = new WritableImage(0, 0, 3, 2.3, image); //WritableImage wimage1 = new WritableImage(3, 0, 3, 2.3, image); ws.addImage(wimage); //ws.addImage(wimage1); // 写入Exel工作表 wwb.write(); // 关闭Excel工作薄对象 wwb.close(); } public static void main(String args[]) throws Exception { try { File f = new File("d:\\image.xls"); //这里要以流的形式,不要以文件的形式 Test.writeImageExcel(new FileOutputStream(f)); } catch (Exception e) { e.printStackTrace(); } } }
转载:
发表评论
-
Java中List Set Map 是否有序等总结
2015-05-05 11:09 680转http://blog.csdn.net/zhengqiq ... -
ava操作word宏
2015-04-29 10:44 488转:http://aa8945163.iteye.com/b ... -
System.load 和 System.loadLibrary详解
2015-04-09 10:50 583转:http://www.cnblogs.com/h ... -
(转)谈谈对Java中Unicode、编码的理解
2015-03-03 11:07 392转:http://www.cnblogs.com/newst ... -
HTTP status code 说明
2015-01-15 16:15 453200 – 服务器成功返回 ... -
JAVA邮件发送
2015-01-13 16:56 595转:http://www.cnblogs.com/codep ... -
Java排序算法 记录
2015-01-13 10:24 390转:http://www.cnblogs.com/dians ... -
java中volatile关键字
2015-01-05 14:30 457转:http://www.cnblogs.com/aigon ... -
4.1 Servlet简介
2014-12-22 16:34 396转:http://www.blogjava.net/ ... -
在 Windows 中实现 Java 本地方法
2014-12-21 15:18 428转:http://www.ibm.com/devel ... -
严重: Error listenerStart
2014-11-18 17:14 3902007-5-31 14:27:13 org.apache. ... -
java.security.AccessControlException: access denied 的解决方法
2014-11-07 22:07 3302转:http://blog.csdn.net/maomao ... -
Linux下反斜杠号"\"
2014-10-27 13:36 2446转:http://www.cnblogs.com/Muyou ... -
@override在JDK1.5和JDK1.6中用法区别
2014-10-14 22:54 370转:http://gaowenming.iteye.com/ ... -
ClientAbortException:java.io.IOException解决方案
2014-09-09 10:13 12481转:http://blog.sina.com.cn/s/bl ... -
SchedulerFactoryBean 注入
2014-08-26 10:19 787转:http://blog.csdn.net/neutro ... -
Spring 3整合Quartz 2实现定时任务二:动态添加任务
2014-08-26 09:47 794转:http://www.meiriyouke.net/?p ... -
Spring 3整合Quartz 2实现定时任务一:常规整合
2014-08-26 09:45 628转:http://www.meiriyouke.net/?p ... -
Spring 3整合Quartz 2实现定时任务三:动态暂停 恢复 修改和删除任务
2014-08-26 09:21 2206转http://my.oschina.net/u/1177 ... -
java.lang.UnsupportedClassVersionError: Bad version number in .class file
2014-08-18 16:45 353今天新建了一个基于jdk6的工程,在tomcat中部署之后, ...
相关推荐
JXL操作excel 字体 颜色 设置单元格 详解
jxl读取合并单元格
java jxl Excel 读写 合并单元格 下载 等实例
通过一个小例子了解jxl的读取,使用于java初学者。里面用到的包可以在CSDN下载得到。
这个例子介绍了如何使用jxl实现Excel的单元格自动缩小字体填充,而不是列的长度随单元格内容自动扩展,但是有一个缺点,jxl不支持图文格式的Excel展示。附件中有jxl的jar包,以及我调用的例子。欢迎大家下载。
利用jxl操作excel文件,提取exce文件数据生成txt文件。
jxl操作excel实例,jxl jar包下载 jxl操作excel实例,jxl jar包下载 jxl操作excel实例,jxl jar包下载
java使用JXL对Excel创建、修改、读取操作
JXL操作EXCEL 数据库导出EXCEL相关文件一些详细资料
JXL操作EXCEL的各个类的解析.doc
使用jxl操作Excel,可以作为一个帮助文件
jxl的excel读写操作 java操作excel的读写。
ExcelDemo_Excel导出_下载_POI读excel_JXL读写excel_java读写excel_列宽_读取合并或拆分单元格内容
java中使用jxl打印excel报表,java中使用jxl打印excel报表,java中使用jxl打印excel报表
jxl操作excel.pdf
jxl导出excel加水印 WritableWorkbook、WritableSheet、WritableCellFormat
jxl操作excel模板jar包,用于导出特定excel模板
jxl操作excel,jxl操作读写excel2003.
jxl操作excel文件示例,对于jxl的使用给出一个简单的示例,帮助大家快速入门
java操作修饰Excel字体大小单元格背景色合并单元格设置列宽