I think there is problem with following line...
row = sheet.getRow(i); -> row = sheet.getRow(j);
Also following code with give you the contents:
===================================================
Workbook excelDoc = Workbook.getWorkbook(new FileInputStream(
file));
String content = "";
for (int i = 0; i < excelDoc.getNumberOfSheets(); i++) {
Sheet sheet = excelDoc.getSheet(i);
Cell[] row = null;
for (int j = 0; j < sheet.getRows(); j++) {
row = sheet.getRow(j);
for (int rows = 0; rows < row.length; rows++) {
content = row[rows].getContents();
System.err.println("content inside loop is ::: "
+ content);
}
}
}
===========================================
Regards
Rajan
-----Original Message-----
From: spinergywmy <spinergywmy@gmail.com>
To: java-user@lucene.apache.org
Date: Wed, 13 Dec 2006 19:10:30 -0800 (PST)
Subject: Re: Index Excel File
>
> Hi,
>
> I did use jexcelapi to extract the contents out of excel file,
> however, I
> couldn't get the content when I sysout. Below are the codes that I
> wrote,
> perhaps you can point out where I have done wrong. Thanks.
>
>
> Workbook excelDoc = Workbook.getWorkbook(new FileInputStream(file));
> String content = "";
>
> for(int i = 0; i < excelDoc.getNumberOfSheets(); i++)
> {
> Sheet sheet = excelDoc.getSheet(i);
>
> Cell[] row = null;
>
> for(int j = 0; j < sheet.getRows(); j++)
> {
> row = sheet.getRow(i);
>
> System.err.println("row is ::: " +row.length);
>
> if(row.length > 0)
> {
> content = row[i].getContents();
> System.err.println("content inside loop is ::: " +content);
> }
> }
> }
>
> System.err.println("content is ::: " +content);
>
> doc.add(new Field(DsConstant.idxFileContent, content,
> Field.Store.YES,
> Field.Index.TOKENIZED));
> doc.add(new Field(DsConstant.idxFileName, file.getName(),
> Field.Store.YES,
> Field.Index.UN_TOKENIZED));
> doc.add(new Field(DsConstant.idxPath, file.getPath(),
> Field.Store.YES,
> Field.Index.UN_TOKENIZED));
>
> excelDoc.close();
>
> regards,
> Wooi Meng
> --
> View this message in context:
> http://www.nabble.com/Index-Excel-File-tf2817920.html#a7866165
> Sent from the Lucene - Java Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
|