zoukankan      html  css  js  c++  java
  • execel 的java库

    http://fastexcel.sourceforge.net/

    Fast Excel-Yet Another Excel Read/Write Component.SourceForge.net Logo
    Abstract

    FastExcel is a pure java excel read/write component.It's FAST and TINY. We provide:

    • Reading and Writing support for Excel '97(-2003) (BIFF8) file format.
    • Low level structures for BIFF(Binary Interchange File Format).
    • Low level structures for compound document file format (also known as "OLE2 storage file format" or "Microsoft Office compatible storage file format").
    • API for creating, reading excel file.

    FastExcel is content-based,that means we just care about the content of excel. So FastExcel just read the cell string and other important information,Some Properities like color,font are not supported.Because we don't need to read,parse,store these additional information so FastExcel just need little memory.

    Table of ContentsAbout FastExcel

    FastExcel is a pure java excel read/write component.We provide reading and writing Excel[1]'97(-2003) (BIFF8[2]) file format and a low level API for compound document file format[3][4].It license under the term of LGPL. For more information contract

    How it works

    A workbook document with several sheets (BIFF5-BIFF8) is usually stored using the compound document file format (also known as "OLE2 storage file format" or "Microsoft Office compatible storage file format"). It contains several streams for different types of data.Depending on the document type, different names are used for the stream(s) they contain. BIFF5-BIFF8 workbook documents that are stored in a compound document file contain a stream in the root storage called the Workbook Stream. The name of this stream in the compound document file is "Book" for BIFF5 workbooks, and "Workbook" for BIFF8 workbooks.If a BIFF5-BIFF8 workbook document is stored as stream file, the entire stream is called the Workbook Stream. In BIFF5-BIFF8 Workbook Streams, the Workbook Globals Substream ist the leading part of the stream. It is followed by all Sheet Substreams in order of the sheets that are in the document. Common structure of a BIFF5-BIFF8 Workbook Stream:

    • Workbook Globals Substream (required)
    • First Sheet Substream (required)
    • Second Sheet Substream (optional)
    • Third Sheet Substream (optional)

    Most of the Excel streams or substreams are divided into records. Each record contains specific data for the various contents or features in a document. It consists of a header specifying the record type and size, followed by the record data. Common structure of a BIFF record:

    Offset Size Contents 0 2 Identifier 2 2 Size of the following data (sz) 4 sz Record data

    To read excel file.FastExcel parse these record and build a inner struct of excel file.The Record Parsers:

    • BOFParser
    • EOFParser
    • BoundSheetParser
    • SSTParser
    • IndexParser
    • DimensionParser
    • RowParser
    • LabelSSTParser
    • RKParser
    • MulRKParser
    • LabelParser
    • BoolerrParser
    • XFParser
    • FormatParser
    • DateModeParser
    • StyleParser
    • MulBlankParser
    • NumberParser
    • RStringParser
    Example

    public void testDump() throws ParserException, ReadException {
    Workbook workBook;
    workBook = FastExcel.createReadableWorkbook(new File("d:/write.xls"));
    workBook.open();
    Sheet s;
    s = workBook.getSheet(0);
    System.out.println("SHEET:"+s);
    for (int i = s.getFirstRow(); i <= s.getLastRow(); i++) {
    System.out.print(i+"#");
    for (int j = s.getFirstColumn(); j <=s.getLastColumn(); j++) {
    System.out.print(","+s.getCell(i, j));
    }
    System.out.println();
    }
    workBook.close();
    }Download

    click here

    References
    1. http://en.wikipedia.org/wiki/Microsoft_Excel.
    2. http://sc.openoffice.org/excelfileformat.pdf
    3. http://sc.openoffice.org/compdocfileformat.pdf
    4. http://blog.csdn.net/liangjingbo/archive/2008/09/03/2874959.aspx
  • 相关阅读:
    读《SQL优化核心思想》:你不知道的优化技巧
    MySQL 索引建立原则及注意事项
    MySQL 捕获有问题的SQL-慢查日志 实例
    MySQL 分区间进行数据展示 实例
    MySQL 删除重复数据实例
    MySql 索引优化实例
    JDK1.6 Java.lang.Null.Pointer.Exception
    关于 MySQL LEFT JOIN 不可不知的事
    搞定queryString
    数据库不得不说的陷阱
  • 原文地址:https://www.cnblogs.com/danghuijian/p/4400796.html
Copyright © 2011-2022 走看看