FastExcel
Also try:- JExcel :http://jexcelapi.sourceforge.net/
- sjxslx :https://code.google.com/p/sjxslx/
- Apache POI : https://poi.apache.org/spreadsheet/
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 0.5.1 Release
http://sourceforge.net/projects/fastexcel/files/fastexcel/fastexcel0.5.1/
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. New Features in FastExcel 0.4
To read excel file.FastExcel parses these records and build an 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 :
Basic Read
public void testDump() throws ExcelException {
Workbook workBook;
workBook = FastExcel.createReadableWorkbook(new File("test.xls"));
workBook.setSSTType(BIFFSetting.SST_TYPE_DEFAULT);//memory storage
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();
}
Event-based Read
public void testEventDump() throws ExcelException {
Workbook workBook;
workBook = FastExcel
.createReadableWorkbook(new File("test.xls"));
workBook.open();
workBook.getSheet(0, new SheetReadAdapter() {
public void onCell(int row, int col, String content) {
System.out.println(row + "," + col + "," + content);
}
});
workBook.close();
}
Basic Write
public void testWrite() throws ExcelException{
File f=new File("write.xls");
Workbook wb=FastExcel.createWriteableWorkbook(f);
wb.open();
Sheet sheet=wb.addSheet("sheetA");
sheet.setCell(1, 2, "some string");
wb.close();
}
Stream Write
public void testStreamWrite() throws Exception{
File f=new File("write1.xls");
Workbook wb=FastExcel.createWriteableWorkbook(f);
wb.open();
Sheet sheet=wb.addStreamSheet("SheetA");
sheet.addRow(new String[]{"aaa","bbb"});
wb.close();
}
Ref:
http://fastexcel.sourceforge.net/
No comments:
Post a Comment