|
|
|
Java Excel Reader API v1.0
|
|
|
| Java Excel Reader API v1.0 |
|
|
A very efficient, small memory footprint Excel Reader API. Currently
supports reading file versions 95-97, 2000, XP, 2003. Comes with an included sample application
which demonstrates the API usage by converting a spreadsheet to HTML. Using the same core
code which powers the Sidekick ExcelViewer the Excel Reader API is powerful and extremely
fast.
|
|
Purchase
|
|
All transactions are processed by 'Google Checkouts' by way of 'e-junkie.com'.
The Java Excel Reader API 1.0 sells for $99.99. Please carefully review
the end user license agreement before using the API. A link to the end user license
agreement is provided at the bottom of this page.
|
|
|
|
|
|
|
|
Code Sample
|
The following code show how easy it is to read in a spreadsheet.
This sample code reads a spreadsheet in and writes out an HTML representation of the sheet.
A link to the output created by the sample program is provided at the bottom of this page.
The output is generated by the Excel Reader API test program provided with the API.
//create an empty file that states you agree with the EULA
//this file is needed to create a new instance of the
//excelReader class.
File iAgree = new File(
".\\I_agree_with_the_ExcelReaderApi_license_agreement_from_JBCG_copyright_2007"
);
if(! iAgree.exists()) {
iAgree.createNewFile();
}
xlsr = new excelReader();
try {
if(args.length > 1) {
sheetIndex = Integer.parseInt(args[1]);
}else{
sheetIndex = 0;
}
}catch(Exception e) {
sheetIndex = 0;
}
//open the excel file
f = new File(args[0]);
b = new byte[(int)f.length()];
fr = new FileInputStream(f);
fr.read(b, 0, (int)f.length());
xlsr.setReader(b, f.getName(), f.getPath());
b = null;
//read poifs
if(! xlsr.nReadPoifsInfo()) {
xlsr = null;
System.err.println("Read Poifs Failed.");
return;
}
//read workbook BOF
if(! xlsr.nReadWorkbookBOF()) {
xlsr = null;
System.err.println("Read Workbook Failed.");
return;
}
//check version
if(xlsr.workbookBOF_version != 1536 && xlsr.workbookBOF_version != 1280) {
xlsr = null;
System.err.println("Workbook version not supported.");
return;
}
//read workbook globals
if(! xlsr.nReadWorkbookGlobals()) {
xlsr = null;
System.err.println("Read Workbook Globals.");
return;
}
//find the worksheet's name
node n = null;
boundsheetRecord bs = null;
int tmp = 0;
for(n = xlsr.boundsheet.front; n != null; n = n.Next) {
bs = (boundsheetRecord) n.Value;
if(tmp == sheetIndex) {
sheetName = bs.name;
//set the file offset for future use
sheetIndex = bs.index;
}
tmp++;
}
//load the requested worksheet
if(! xlsr.nReadWorksheetBOF(sheetIndex)) {
xlsr = null;
System.err.println("Read Worksheet BOF Falied.");
return;
}
if(! xlsr.nReadWorksheetGlobals()) {
xlsr = null;
System.err.println("Read Worksheet Globals Failed.");
return;
}
System.err.println("Table Height: " + xlsr.activeSheet.cellTable.length);
System.err.println("Table Width: " + xlsr.activeSheet.cellTable[0].length);
System.err.println("Rendering HTML File.....");
setOutput();
int len = xlsr.activeSheet.cellTable.length;
int len1 = xlsr.activeSheet.cellTable[0].length;
wr("<html>");
wr("<head>");
wr("<body>");
wr("<table border='1' cellpadding='1' cellspacing='1'>");
textFormatter tf = new textFormatter(xlsr);
tf.storeRecords();
String t;
for(int i = 0; i < len; i++) {
wr("<tr>");
for(int j = 0; j < len1; j++) {
t = tf.formatCell(xlsr.activeSheet.cellTable[i][j]);
wr("<td>");
wr(t + "<br>");
wr("</td>");
}
wr("</tr>");
}
wr("</table>");
wr("<body></html>");
|
|
|
End User License Agreement
|
|
|
|
|
Sample Code Output
|
|
|
|
|
Screen Shots
|
|
|
|
|
|
|