5. JXL Excel operations, 5. jxlexcel

Source: Internet
Author: User

5. JXL Excel operations, 5. jxlexcel
I. Introduction

Jxl is a Korean-written java excel tool. In the open-source world, there are two sets of influential APIs available: POI and jExcelAPI. The function is weaker than that of POI. However, jExcelAPI provides excellent support for Chinese characters. The API is pure Java and does not depend on Windows systems. Even if it runs in Linux, it can process Excel files correctly. In addition, this API has limited support for graphics and charts and only recognizes PNG formats.

Ii. Simple implementation code

Maven dependency

<dependency><groupId>net.sourceforge.jexcelapi</groupId><artifactId>jxl</artifactId><version>2.6.12</version></dependency>

 

Package com. my. utils; import java. io. file; import jxl. cell; import jxl. sheet; import jxl. workbook; import jxl. write. label; import jxl. write. writableSheet; import jxl. write. writableWorkbook; public class UseJxlCreateExcel {public static void main (String [] args) {// TODO Auto-generated method stub try {WritableWorkbook book = Workbook. createWorkbook (new File ("D: \ java \ test \ jxlTest.xls"); WritableSheet sheet = book. createSheet ("first page", 0); Label label1 = new Label (0, 0, "name"); Label label2 = new Label (1, 0, "Age "); sheet. addCell (label1); sheet. addCell (label2); book. write (); book. close (); Workbook workbook = Workbook. getWorkbook (new File ("D: \ java \ test \ jxlTest.xls"); Sheet worksheet = workbook. getSheet (0); Cell cell1 = worksheet. getCell (0, 0); String result = cell1.getContents (); System. out. println (result); workbook. close ();} catch (Exception e) {// TODO Auto-generated catch block e. printStackTrace ();}}}

 

See: http://www.cnblogs.com/raymond19840709/archive/2008/06/26/1230289.html

Iii. poi and jxl

Currently, I am responsible for two data export Methods: POI and JXL. In the initial stage of the project, the amount of data is small and JXL is generally used to meet the needs. Later, some checks were conducted,
The maximum number of sheet rows is exceeded and the heap memory is full. In the future, we will urgently transform some important functions and several modules with a large volume of data to POI.
However, it still runs slowly and does not know any other implementation method of POI. Later, I made some modifications to the tool class of POI and the export Implementation of POI to successfully complete the upgrade.

My preliminary understanding:
JXL: supports earlier versions of excel, such as Excel 95, 97,200
Because the Excel version is relatively low, the maximum row is limited and data of more than 65535 magnitude cannot be exported.
The memory and time consumption are also higher than the POI memory + disk-based method.

Technical notes for netizens
1. Read the Excel Formula (you can read the formula after Excel 97)
2. generate an Excel data table in the format of Excel 97)
3. Supports formatting of fonts, numbers, and dates
4. Supports cell shadow and color operations.
5. modify an existing data table
6. is the most basic excel api
7. reading efficiency of small files is relatively high.
8. cross-platform
POI technical description

In general, JXL is recommended for simple single-Table excel import and export requirements. The data volume is slightly smaller, the memory usage is small, and the speed is fast.
We recommend that you use POI to aggregate data from multiple tables for report types that involve the data volume in the month.

Advantages and disadvantages

I. jxl

Advantages:

Jxl provides excellent support for Chinese characters and is easy to operate. The method is well-known. Jxl is a pure Java API and performs well across platforms. The code can run on windows or Linux without having to rewrite all versions supporting Excel 95-2000, (not yet) generate Excel 2000 standard format support font, number, date operations can modify cell attributes support images and charts, but this set of APIs have limited support for graphics and charts, and only recognizes PNG format.

Disadvantages: low efficiency, incomplete image support, and less powerful format support than POI

Ii. POI

Advantages:

High efficiency (Data source: http://blog.csdn.net/jarvis_java/article/details/4924099) supports formulas, macros, some enterprise applications will be very useful to modify cell attributes support font, numbers, date operations

Disadvantages: immature and the Code cannot be cross-platform. It seems that many colleagues have encountered depressing bugs in their projects. (Some bugs have also been encountered in recent projects, however, it is not found whether it is a code issue or a POI issue. In short, the problem is very strange, and data substitution parameters always fail. I have never tried cross-platform. But isn't Java cross-platform? POI is a JAVA component. How can I avoid cross-platform access? In short, these problems still need to be practiced in future projects to compare the differences .)

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.