JExcelAPI与Apache POI两者对比
来源:互联网 发布:张国荣谭咏麟粉丝知乎 编辑:程序博客网 时间:2024/05/22 05:57
一,JExcelAPI与Apache POI两者对比
1、JExcelAPI不适合商业应用,它都是会莫名其妙的读不出来数据。
2、Apache POI是一纯Java的实现,不仅能读微软的Excel还可以读Open Office的,新版HSSF3.0还添加了读取Power Point的功能。总之是一种非常稳定,强大的实现。推荐使用。
二
Jexcelapi的使用参考:http://blog.csdn.net/yfhdsz/archive/2006/10/30/1356670.aspx
apache POI 参考:http://blog.csdn.net/yuansicau/archive/2006/08/31/1150046.aspx
关键是要理解
java读取excel文件的顺序是:
Excel文件->工作表->行->单元格 对应到POI中,为:workbook->sheet->row->cell
注意:
注意:
1.sheet, 以0开始,以workbook.getNumberOfSheets()-1结束
2.row, 以0开始(getFirstRowNum),以getLastRowNum结束
3.cell, 以0开始(getFirstCellNum),以getLastCellNum结束,
结束的数目不知什么原因与显示的长度不同,可能会偏长
如何插图片到Excel中
public static void createPicture() {
FileOutputStream fileOut = null;
BufferedImage bufferImg = null;
BufferedImage bufferImg1 = null;
try {
ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
ByteArrayOutputStream byteArrayOut1 = new ByteArrayOutputStream();
bufferImg = ImageIO.read(new File("C:/Documents and Settings/All Users/Documents/My Pictures/示例图片/Sunset.jpg"));
bufferImg1 = ImageIO.read(new File("C:/Documents and Settings/All Users/Documents/My Pictures/示例图片/Water lilies.jpg"));
ImageIO.write(bufferImg, "jpeg", byteArrayOut);
ImageIO.write(bufferImg1, "jpeg", byteArrayOut1);
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet1 = wb.createSheet("new sheet");
// HSSFRow row = sheet1.createRow(2);
HSSFPatriarch patriarch = sheet1.createDrawingPatriarch();
HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 512, 255,
(short) 0, 0, (short) 10, 10);
HSSFClientAnchor anchor1 = new HSSFClientAnchor(0, 0, 512, 255,
(short) 0, 15, (short) 10, 20);
/**
* public HSSFClientAnchor(int dx1, int dy1, int dx2, int dy2, short
* col1, int row1, short col2, int row2)
* Creates a new client anchor
* and sets the top-left and bottom-right coordinates of the anchor.
*
* Parameters: dx1 - the x coordinate within the first cell.
* dy1 - the y coordinate within the first cell.
* dx2 - the x coordinate within the second cell.
* dy2 - the y coordinate within the second cell.
* col1 - the column (0 based) of the first cell.
* row1 - the row (0 based) of the first cell.
* col2 - the column (0 based) of the second cell.
* row2 - the row (0 based) of the second cell.
* 注意:(col1,row1)表示图片左上角所在单元格
* (col2,row2)表示图片右下角所在单元格,
* 先是列,再行,顺序不要反了.
* (dx1,dy1)表示图片左上角在单元格中的坐标.
* ((dx2,dy2)表示图片右下角在单元格中的坐标.
*/
patriarch.createPicture(anchor, wb.addPicture(byteArrayOut
.toByteArray(), HSSFWorkbook.PICTURE_TYPE_JPEG));
patriarch.createPicture(anchor1, wb.addPicture(byteArrayOut1
.toByteArray(), HSSFWorkbook.PICTURE_TYPE_JPEG));
fileOut = new FileOutputStream("e:/study/workbook.xls");
wb.write(fileOut);
fileOut.close();
} catch (IOException io) {
io.printStackTrace();
System.out.println("io erorr : " + io.getMessage());
} finally {
if (fileOut != null)
try {
fileOut.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
- JExcelAPI与Apache POI两者对比
- 在Java中读取EXCEL文件 JExcelAPI与Apache POI两者对比
- InnoBD 与 MyISAM 两者之间的对比
- php和java两者的对比与取舍
- Nginx与Apache对比
- JExcelApi
- Apache FileUpload 上传以及 JExcelApi 解析
- POI与JXL的实战性能对比
- POI与JXL的实战性能对比
- Apache与ngnix的对比
- nginx与apache的对比
- Java操作Excel的2种方法--Poi,jExcelApi
- java使用JexcelApi和POI两种方法操作excel
- MyISAM与InnoDB两者之间区别与选择,详细总结,性能对比
- Volley与XUtils网络请求使用对比,心得,两者基本使用
- POI (Apache POI)
- 【POI】Apache POI
- Apache POI
- 再给自己一次机会
- goals
- 【原创】asp.net2.0动态生成静页,静态分页实例介绍
- 人生信条
- 将Excel数据批量导入oracle数据库方法
- JExcelAPI与Apache POI两者对比
- 高危的IT行业
- 台湾人在大陆应该保持谦虚和低调
- struts2中interceptor命名的新变化
- 文件读写简单实例---拷贝文件
- DotNet资源站点汇总
- 在 ASP.NET 网页中不经过回发而实现客户端回调(附Gridview无刷新代码)
- 欠薪,又见欠薪!
- C#中分割字符串的几种方法