RE: Retrieving numeric value using apache poi

2007-05-23 Thread Levi Strope
I believe  0.27994 is how excel stores the value 27.99%.  It
looks correct to me, so if you want the value to read 27.99 just
multiply it by 100 to get the percentage 27.99.  

-Levi

-Original Message-
From: becomp_2002 [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, May 23, 2007 8:45 AM
To: poi-user@jakarta.apache.org
Subject: Retrieving numeric value using apache poi

Hi,

When I read a numeric cell of my excel sheet using apache poi, it
returns wrong double value as described below.

The cell has value = 27.99%
when I read this cell value using apache poi it gives me
0.27994

for (short inxColumn = 0; inxColumn <
getColumnCount(); inxColumn++) {
// Add each cell to the row
iCellType = row.getCell(inxColumn).getCellType();
System.out.println("iCellType = " + iCellType);

switch (iCellType) {
case HSSFCell.CELL_TYPE_NUMERIC :
double d =
row.getCell(inxColumn).getNumericCellValue();

System.out.println("row.getCell(inxColumn).getNumericCellValue()
= "+d);
break;
.
.
.
.
.
.
.
}
}

I need the value as 27.99

Can anyone please tell what could be wrong?

Thanks


  Office firewalls, cyber cafes, college labs, don't allow you to
download CHAT? Click here:
http://in.messenger.yahoo.com/webmessengerpromo.php

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List: http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List: http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/



RE: There has got to be a way

2007-05-10 Thread Levi Strope
That would be of GREAT use. 

BTW:  what do you think the ETA is for that?   

-Original Message-
From: Nick Burch [mailto:[EMAIL PROTECTED] 
Sent: Thursday, May 10, 2007 6:05 AM
To: POI Users List
Subject: Re: There has got to be a way

On Tue, 1 May 2007, Levi Strope wrote:
> All I need to do is read in a row of data, just like the spreadsheet 
> that is attached, and parse the information reliably.  There are many 
> blank cells here, but I need to account for them.

I've got some code that might help here. Instead of registering your
HSSFListener directly, you create a MissingRecordAwareHSSFListener,
register that, and tell it to call your HSSFListener.

As it goes through, it will fire off dummy records when it notices that
your final has skipped a row or a column (or a few), and another dummy
record after the last cell of a given row.


I'll be adding MissingRecordAwareHSSFListener and friends to svn after
we do the 3.0 final release, and once I've finished writing some proper
tests for it. I can send you a copy if it'd be of use though.

Nick

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List: http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List: http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/



RE: There has got to be a way

2007-05-02 Thread Levi Strope
Forgive me for not clarifying earlier, this is using HSSF.

To answer your question Dave, Yes - I have taken that into
consideration.  I'm not saying my code is correct in looking for the
blank cells with the BlankRecord listener, but according to my limited
knowledge and the javadoc a blankrecord is any record without data that
contains styling information.  That's why I'm asking for help - I would
love it if the answer is just to use a different type of listener, but I
need someone to tell me what that would be.

So here is what I did last night:
1) I went through each and every blank cell in the row and applied a
default styling.  After running my code again it returned 1 less blank
record than it did before!  I would have expected it to return more.
2) This got me to thinking that I was completely backwards, so I went in
and removed formatting from the blank cells and ran my test again.  This
time it returned the same number of blank records, only it reported
these blank records on different columns!  

I've tried adding a MulBlank record listener - and that doesn't detect
any of my cells where there might be 3 blanks in a row.  I'm not sure
what the criteria is for this but according to the javadoc I believe it
should return at least 2 mulblank records with the excel file I
provided.  According the the javadoc it says that all MulBlank records
are converted into individual blankrecords.  I'm starting to believe
there may be something wrong with this conversion.  The reason why I
believe this is in the 2 tests that I noted above, the inconsistencies
in the columns that were reported as blanks occurred where there might
be more than 1 blank column side by side. It's almost as if HSSF sees
these columns as the same column and is reporting them as 1 blank record
when it should be more than one.

-Levi  

-Original Message-
From: David Henry [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, May 02, 2007 10:18 AM
To: POI Users List
Subject: RE: There has got to be a way

Levi,
 
I haven't dug through all your code and spreadsheet, but have you
considered what the definition of "blank" is?  In many similar
circumstances I have found that relying upon isBlank, for example, may
not be sufficient if you have a mix of true blank (i.e.  value)
cells and cells with zero length data (i.e. looks "blank" but, by
Excel's reckoning contains a value).  Sometimes something as simple as
tabbing to the cell may be sufficient to change a "blank" to a
zero-length value.  You may have already taken this into consideration,
but thought I'd mention it as a first check.
 
- David



From: Levi Strope [mailto:[EMAIL PROTECTED]
Sent: Tuesday, May 01, 2007 10:11 PM
To: POI Users List
Subject: There has got to be a way


Please look at the attached excel spreadsheet.  I would really
appreciate some input.
 
All I need to do is read in a row of data, just like the spreadsheet
that is attached, and parse the information reliably.  There are many
blank cells here, but I need to account for them.  
 
My business problem is this:  We are accepting messages where columns of
information are not required, but the column MUST be represented in the
file as we process it.  At minimum I'd like to be able to read in these
excel files and output them in a CSV format.  Essentially as I am
streaming the excel file out, I am appending comma's between the values
because our messaging system expects the values to be comma delimited.
Unfortunately we accpet XLS files so we cannot just ask them to save it
as a CSV.  This can happen in 1 of 2 ways, I can stream the file and
append the commas between the cells as I am sending it to our messaging
system, or I can stream it out to a file and build an actual CSV, and
then tell the messaging system to pick it up.
 
When I read in an excel file I am finding it very difficult to determine
when cells are blank, and account for them.  For some reason the
BlankRecordListener doesn't pickup all blank records.  I've even tried
applying formatting to all cells and running my code, it still does not
work.
 
I put code in the blank record listener code to tell me the column.
Here is what I get:
 
Blank record encounterred.  Column= 3
Blank record encounterred.  Column= 4
Blank record encounterred.  Column= 7
Blank record encounterred.  Column= 8
Blank record encounterred.  Column= 10
Blank record encounterred.  Column= 18
Blank record encounterred.  Column= 20
Blank record encounterred.  Column= 30
Blank record encounterred.  Column= 34

There is no conditional formatting in this code, all I'm doing is
listening for a blank record and doing a System.out. If you look at the
attached spreadsheet you can see that columns 21, 22, 24, 32, and 33 are
blank as well.  There are 14 blank records in this spreadsheet but the
blankrecord listener only reports 9. 
 
I need help.  I need s

There has got to be a way

2007-05-01 Thread Levi Strope
Please look at the attached excel spreadsheet.  I would really
appreciate some input.
 
All I need to do is read in a row of data, just like the spreadsheet
that is attached, and parse the information reliably.  There are many
blank cells here, but I need to account for them.  
 
My business problem is this:  We are accepting messages where columns of
information are not required, but the column MUST be represented in the
file as we process it.  At minimum I'd like to be able to read in these
excel files and output them in a CSV format.  Essentially as I am
streaming the excel file out, I am appending comma's between the values
because our messaging system expects the values to be comma delimited.
Unfortunately we accpet XLS files so we cannot just ask them to save it
as a CSV.  This can happen in 1 of 2 ways, I can stream the file and
append the commas between the cells as I am sending it to our messaging
system, or I can stream it out to a file and build an actual CSV, and
then tell the messaging system to pick it up.
 
When I read in an excel file I am finding it very difficult to determine
when cells are blank, and account for them.  For some reason the
BlankRecordListener doesn't pickup all blank records.  I've even tried
applying formatting to all cells and running my code, it still does not
work.
 
I put code in the blank record listener code to tell me the column.
Here is what I get:
 
Blank record encounterred.  Column= 3
Blank record encounterred.  Column= 4
Blank record encounterred.  Column= 7
Blank record encounterred.  Column= 8
Blank record encounterred.  Column= 10
Blank record encounterred.  Column= 18
Blank record encounterred.  Column= 20
Blank record encounterred.  Column= 30
Blank record encounterred.  Column= 34

There is no conditional formatting in this code, all I'm doing is
listening for a blank record and doing a System.out. If you look at the
attached spreadsheet you can see that columns 21, 22, 24, 32, and 33 are
blank as well.  There are 14 blank records in this spreadsheet but the
blankrecord listener only reports 9. 
 
I need help.  I need someone to tell me what kind of record listener I
need to use.  How can I account for these cells?
 
Here is my code.  At present it skips the blankcells when writing it out
to a CSV.   
 
/*
 *
 * Created on April 5, 2007, 11:49 AM
 *
 *
 *
 * @author lstrope
 */
 
package poitest;
 
import java.io.*;
 
import org.apache.poi.poifs.filesystem.*;
import org.apache.poi.hssf.eventusermodel.*;
import org.apache.poi.hssf.record.*;
 
public class PoiXLStest implements HSSFListener {
private SSTRecord sstrec;
int rowRecLen[] = new int[RowRecord.MAX_ROW_NUMBER];
PrintWriter CSV = null;
   // int rowNum = 0;
int colNum = 0;
 
public PoiXLStest()
{
this("c:\\ExceltoCSV.csv");
}

public PoiXLStest(String F)
{
try{
CSV = new PrintWriter(new BufferedWriter((new
FileWriter(F;
}
catch(FileNotFoundException E){}
catch(IOException E){}
}

public PoiXLStest(InputStream in)
{   
PoiXLStest noargs = new PoiXLStest();
HSSFRequest req = new HSSFRequest();
//req.addListener(noargs, SSTRecord.sid);
//req.addListener(noargs, LabelSSTRecord.sid);
//req.addListener(noargs, RowRecord.sid);
//req.addListener(noargs, NumberRecord.sid);
//req.addListener(noargs, BlankRecord.sid);
req.addListenerForAllRecords(noargs);
HSSFEventFactory factory = new HSSFEventFactory();
   
try{
factory.processEvents(req, in);
}
catch(IOException E){
System.out.println("Problem in constructor");
}
}

public void processRecord(Record record)  
{
short sidVal;
sidVal = record.getSid();
 
if(sidVal == RowRecord.sid){
RowRecord rowRec = (RowRecord) record;
if(rowRec.getRecordSize() > 0){
rowRecLen[rowRec.getRowNumber()] = rowRec.getLastCol();
// Setting array to hold the row at it's physical position with its
Column length.
//System.out.println(rowRec.getLastCol());
}

}
 
if(sidVal == SSTRecord.sid){
sstrec = (SSTRecord) record;
}
 
if(sidVal == LabelSSTRecord.sid){
LabelSSTRecord lrec = (LabelSSTRecord) record;
if(lrec.getColumn() < (rowRecLen[lrec.getRow()] - 1) &&
!(lrec.getColumn() < colNum)){
//System.out.print(lrec.getColumn());
CSV.print(sstrec.getString(lrec.getSSTIndex()) +
",");
colNum++;
}
else if(lrec.getColumn() < colNum){
//System.out.print(lrec.getColumn());
CSV.print("\n" +
sstrec.getString(lrec.getSSTIndex()) + ",");
colNum = 1;  
}
else{
//System.out.prin

RE: how to find style in existing workbook for cell position with no cell

2007-04-27 Thread Levi Strope
I believe it can be mapped to a BlankRecord because the cell itself
still contains cell formatting.
 

-Original Message-
From: Haggerty, Michael [mailto:[EMAIL PROTECTED] 
Sent: Friday, April 27, 2007 10:28 AM
To: poi-user@jakarta.apache.org
Subject: how to find style in existing workbook for cell position with
no cell

When a cell position (some row/column position such as 0,0) in an
existing workbook contains a cell, then its style can be found with
HSSFCell.getCellStyle().  When a cell position does not contain a cell
(HSSFRow.getCell() returns null), how can I find the style that would be
applied by Excel when a value is set into that cell position?

For example, a column can be formatted to have a specified fill color.
When working in Excel manually, a value typed into a cell in that column
will retain that fill color.  I want to use HSSF to find that column's
style, create a new style based on it, and make some changes to it.  I
cannot simply create a new style, because the default style does not
represent the column formatting, and the fill color is lost.

This question was asked by [EMAIL PROTECTED] on 22 Feb 2006 in this
mailing list, with the subject of "[Q] Excel -> HSFFCell, loosing style"
but no response was made.

Possible lead:  Will the org.apache.poi.hssf.record.BlankRecord class
help in this case?  An extended format record can be retrieved from
this, but how can a cell position be mapped to a BlankRecord?

Thank you.

--Michael



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List: http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List: http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/



RE: Is there a way to listen for cells with no formating?

2007-04-20 Thread Levi Strope
Does anyone have an example of how to use UnknownRecord() ?



From: Levi Strope 
Sent: Friday, April 20, 2007 12:36 PM
To: Levi Strope; POI Users List
Subject: RE: Is there a way to listen for cells with no formating?


Is ther a hex value for cells with nothing?



From: Levi Strope 
Sent: Friday, April 20, 2007 10:00 AM
To: POI Users List
Subject: Is there a way to listen for cells with no formating?


I need a way to listen for cells with no formatting and no values.  Is
there a way to do this?
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List: http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/

RE: Is there a way to listen for cells with no formating?

2007-04-20 Thread Levi Strope
Is ther a hex value for cells with nothing?



From: Levi Strope 
Sent: Friday, April 20, 2007 10:00 AM
To: POI Users List
Subject: Is there a way to listen for cells with no formating?


I need a way to listen for cells with no formatting and no values.  Is
there a way to do this?
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List: http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/

Is there a way to listen for cells with no formating?

2007-04-20 Thread Levi Strope
I need a way to listen for cells with no formatting and no values.  Is
there a way to do this?
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List: http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/

RE: problem with HSSF eventusermodel

2007-04-16 Thread Levi Strope
Thank you for the quick response.

I can achieve very close to what I want if I add a record listener for
blank record types.  This is preferable because I need to reproduce the
data in a delimited format for insertion into a Topic, so my output now
looks like this:

SHID; Carrier; Origin City; Origin County; Origin State; Origin Zip;
Destination City; Destination County; Destination State;
2267.0; ADTS; ; ; IL; 600; ; ; MI;
2267.0; ADTS; ; ; IL; 600; ; ; MI;
2267.0; ADTS; ; ; IL; 600; ; ; ;
2267.0; ADTS; ; ; IL; 600; ; ; MI;
2267.0; ADTS; ; ; IL; 600; ; ; MI;
2267.0; ADTS; ; ; IL; 600; ; ; MI;
; ; ; ; ; ; ; 

This is great!!!  It gives me what I need and it is pretty clean.
However, I'd like to draw your attention to the last line.  In this
situation the last line is a group of cells that I applied a format but
no data to.

I agree with you, the XLS format is .
I do think that pre-processing the excel file as another format is
prefered, but it adds an extra step with a lot of overhead.  We are
trying to implement a solution using poi as part of our asynchronus
messaging system, as such if there is any way to limit the amount of
overhead or synchronus processing of the file that would be great.

If I can just find a way to not to process that last row(s) I'll have a
good working solution.

-Levi  
 

-Original Message-
From: Andrew C. Oliver [mailto:[EMAIL PROTECTED] 
Sent: Monday, April 16, 2007 4:20 PM
To: POI Users List
Subject: Re: problem with HSSF eventusermodel

Theoretically col and row records can appear anywhere in that section
out of order (but don't when coming from excel).  You have to either
write them in some kind of better format to disk -- such as a temporary
db file -- and then read that (to avoid storing it all in memory) in a
guaranteed sort...  or keep it in memory in a map/list structure of some
sort.  Which gets you back into the memory problem.  XLS format BLOWS!

-Andy

Levi Strope wrote:
> I'm trying to read in an XLS and output the contents of each row 
> exactly as they are read in by the file.
>  
> I have to do this with the evenusermodel because of memory 
> limitations, however it is proving to be very difficult.
>  
> In short, my problem is I need to keep track of how many columns there

> are in a row, so that I can start a new line for the next row of data.
> All I am doing is outputting this to the console.  If I use 
> getLastCol() it returns the correct number, BUT if the row has 1 less 
> records there is no way for me to tell it to go to the next row and my

> ouput of the next row bleeds into the prior row.
>  
> Here is my output:
>  
> run:
> SHID; Carrier; Origin City; Origin County; Origin State; Origin Zip; 
> Destination City; Destination County; Destination State; 2267.0; ADTS;

> IL; 600; MI; 2267.0; ADTS; IL; 600; MI; 2267.0; ADTS; IL; 600; 2267.0;

> ADTS; IL; 600; MI; 2267.0; ADTS; IL; 600; MI; 2267.0; ADTS; IL; 600; 
> MI;
>  
> **  Finished Processing File  ***
>
> As you can see, the 3rd row is longer than the rest.  The third row 
> does not contain information in the last column, and so the next row 
> starts there when it should be on a new line.  This would seem simple 
> to overcome but I'm finding it difficult to do so within the 
> eventusermodel.
>  
> I am not asking for anyone to give me code.  If anyone has ideas on 
> how I could get around this I would love to hear them.
>  
> Here is my code:
>  
> [BEGIN CODE]
> import org.apache.poi.poifs.filesystem.*;
> import org.apache.poi.hssf.eventusermodel.*;
> import org.apache.poi.hssf.record.*;
> import java.io.*;
>  
> /**
>  *
>  * @author lstrope
>  */
> public class PoiXLStest implements HSSFListener {
> private SSTRecord sstrec;
> int rowRecLen[] = new int[RowRecord.MAX_ROW_NUMBER];
> int rowNum = 0;
>  
> 
> public PoiXLStest()
> {
> }
> 
> public PoiXLStest(InputStream in)
> {   
> PoiXLStest noargs = new PoiXLStest();
> HSSFRequest req = new HSSFRequest();
> req.addListener(noargs, SSTRecord.sid);
> req.addListener(noargs, LabelSSTRecord.sid);
> req.addListener(noargs, RowRecord.sid);
> req.addListener(noargs, NumberRecord.sid);
> HSSFEventFactory factory = new HSSFEventFactory();
>
> try{
> 
> factory.processEvents(req, in);
> 
> }
> catch(IOException E){
> System.out.println("Problem in constructor");
> }
> }
> 
> public void processRecord(Record record)  
> {
> short sidVal;
> sidVal = record.getSid();
> 
> if(sidVal == RowRecord.sid){
> 

problem with HSSF eventusermodel

2007-04-16 Thread Levi Strope
I'm trying to read in an XLS and output the contents of each row exactly
as they are read in by the file.
 
I have to do this with the evenusermodel because of memory limitations,
however it is proving to be very difficult.
 
In short, my problem is I need to keep track of how many columns there
are in a row, so that I can start a new line for the next row of data.
All I am doing is outputting this to the console.  If I use getLastCol()
it returns the correct number, BUT if the row has 1 less records there
is no way for me to tell it to go to the next row and my ouput of the
next row bleeds into the prior row.
 
Here is my output:
 
run:
SHID; Carrier; Origin City; Origin County; Origin State; Origin Zip;
Destination City; Destination County; Destination State;
2267.0; ADTS; IL; 600; MI;
2267.0; ADTS; IL; 600; MI;
2267.0; ADTS; IL; 600; 2267.0; ADTS; IL; 600; MI;
2267.0; ADTS; IL; 600; MI;
2267.0; ADTS; IL; 600; MI;
 
**  Finished Processing File  ***

As you can see, the 3rd row is longer than the rest.  The third row does
not contain information in the last column, and so the next row starts
there when it should be on a new line.  This would seem simple to
overcome but I'm finding it difficult to do so within the
eventusermodel.
 
I am not asking for anyone to give me code.  If anyone has ideas on how
I could get around this I would love to hear them.
 
Here is my code:
 
[BEGIN CODE]
import org.apache.poi.poifs.filesystem.*;
import org.apache.poi.hssf.eventusermodel.*;
import org.apache.poi.hssf.record.*;
import java.io.*;
 
/**
 *
 * @author lstrope
 */
public class PoiXLStest implements HSSFListener {
private SSTRecord sstrec;
int rowRecLen[] = new int[RowRecord.MAX_ROW_NUMBER];
int rowNum = 0;
 

public PoiXLStest()
{
}

public PoiXLStest(InputStream in)
{   
PoiXLStest noargs = new PoiXLStest();
HSSFRequest req = new HSSFRequest();
req.addListener(noargs, SSTRecord.sid);
req.addListener(noargs, LabelSSTRecord.sid);
req.addListener(noargs, RowRecord.sid);
req.addListener(noargs, NumberRecord.sid);
HSSFEventFactory factory = new HSSFEventFactory();
   
try{

factory.processEvents(req, in);

}
catch(IOException E){
System.out.println("Problem in constructor");
}
}

public void processRecord(Record record)  
{
short sidVal;
sidVal = record.getSid();

if(sidVal == RowRecord.sid){
RowRecord rowRec = (RowRecord) record;
rowRecLen[rowRec.getRowNumber()] = rowRec.getLastCol();  //
Setting array to hold the row at it's physical position with its Column
length.
}

if(sidVal == SSTRecord.sid){
sstrec = (SSTRecord) record;
}

if(sidVal == LabelSSTRecord.sid){
LabelSSTRecord lrec = (LabelSSTRecord) record;
if(lrec.getColumn() < (rowRecLen[lrec.getRow()] - 1)){
//using array to determine the max columns for comparison
System.out.print(sstrec.getString(lrec.getSSTIndex()) +
"; ");
}
else{
System.out.print(sstrec.getString(lrec.getSSTIndex()) +
";\n");  //if it is the last column start a new line.
}

}

if(sidVal == NumberRecord.sid){
NumberRecord nrec = (NumberRecord) record;
if(nrec.getColumn() < rowRecLen[nrec.getRow()] -1){
System.out.print(nrec.getValue() + "; ");
}
else{
System.out.print(nrec.getValue() + ";\n");
}
}
}

 public static void main(String[] args) throws IOException,
FileNotFoundException
 {  
POIFSFileSystem wbook = new POIFSFileSystem(new
FileInputStream("c:\\test.xls"));
InputStream docIn = wbook.createDocumentInputStream("Workbook");
//if the file has a 'read only recommendation' this will fail.
PoiXLStest start = new PoiXLStest(docIn);

docIn.close();

System.out.println("\n**  Finished Processing File
***");

 }
}
[END CODE]
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List: http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/

RE: What is the correct method to read a large excel file line by line?

2007-04-12 Thread Levi Strope
I just want to clarify, as my boss is asking me to look into it further.
Per the documentation is says that using the HSSF eventusermodel is much
more efficient in terms of memory.  Does this mean that I can read in an
excel document without loading the entire document into memory first?
Reading it line by line is not a requirement, but in some cases we have
files that are over 100 meg.  I need to know if I can read it in in
pieces, or iterate through the records by request without having the
entire document loaded into memory first.  Is this possible?

Thanks
-Levi 

 

-Original Message-
From: Yegor Kozlov [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, April 10, 2007 12:24 PM
To: POI Users List
Subject: Re: What is the correct method to read a large excel file line
by line?

Hi,

Current implementation reads the whole document into memory.
There is no way to read excel files line by line.

Regards,
Yegor

LS> Using HSSF, what is the correct method to read large excel files 
LS> line by line?
 
LS> In my real world situation the excel file will be very large, over 
LS> 100 megs.  I need to be able to read the file line by line so that 
LS> the large file size does not cause memory issues.
 
LS> I have tried to use a BufferedInputStream to read in the file but 
LS> that results in invalid header exceptions when I try to do a read().

LS> I can use the BufferedInputStream as is if I give the whole thing to

LS> the workbook to process.However this pretty much forces me to read 
LS> in the entire file at once does it not?
 
LS> If anyone has any examples, or can round about hint at what I need 
LS> to do I would be most appreciative.
 
LS> Thank you,
LS> Levi


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List: http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List: http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/



What is the correct method to read a large excel file line by line?

2007-04-10 Thread Levi Strope
Using HSSF, what is the correct method to read large excel files line by
line?  
 
In my real world situation the excel file will be very large, over 100
megs.  I need to be able to read the file line by line so that the large
file size does not cause memory issues.
 
I have tried to use a BufferedInputStream to read in the file but that
results in invalid header exceptions when I try to do a read().  I can
use the BufferedInputStream as is if I give the whole thing to the
workbook to process.However this pretty much forces me to read in the
entire file at once does it not?
 
If anyone has any examples, or can round about hint at what I need to do
I would be most appreciative.
 
Thank you,
Levi
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List: http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/

using HSSFRow.getLastCellNum()

2007-04-09 Thread Levi Strope
Hello,
 
In my code I'm using HSSFRow.getLastCellNum(), part of
org.apache.poi.HSSF.usermodel to fetch the last cell number contained
within the row I am currently on.  I do this so I can iterate through
each cell value and output it's contents.
 
The description for this method is as follows:
"gets the number of the last cell contained in this row PLUS ONE."
 
This seems perfect, however I'm finding the behavior to be slightly
different.  When I call this method, it appears to take into account the
row with the most defined cells.  That is if Rows 0, 1 and 2 all have 5
defined cells and row 3 has 7, then while I am on row 0 I call
getLastCellNum() and it returns 7, not 5 as I would expect.
 
Is this how it should behave?  Thats fine if it is as I can find a way
to negate the exception, but it was mis-leading based on the javadoc.
 
I am using version poi-src-3.0-rc3-20070402
 
Thanks
-Levi



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List: http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/

Outputting CSV files

2007-04-02 Thread Levi Strope
Can HSSF read in an XLS file and output a CSV?  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List: http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/



Still having problems building POI

2007-03-30 Thread Levi Strope
I'm sorry to keep pinging the list with something as rudimentary as this
- but I am having a very hard time getting this to build.

I am following the instructions on the "how to build" page, but I still
get build errors.  Can someone please take a look at the ANT build
dialogue below and give me any insight you might have? I am using ANT
1.7 and I am using Eclipse 3.2.   If anyone has built this with eclipse
is there something special I need to configure?

I made sure to put the xalan JAR file in the ANT lib directory...  but
this still does not like it. 
 

Buildfile: C:\Program Installs\poi-src-2.5.1-final-20040804\build.xml
check-jars:
fetch-jars:
init:
[mkdir] Created dir: C:\Program
Installs\poi-src-2.5.1-final-20040804\build\contrib-classes
[mkdir] Created dir: C:\Program
Installs\poi-src-2.5.1-final-20040804\build\scratchpad-classes
[mkdir] Created dir: C:\Program
Installs\poi-src-2.5.1-final-20040804\build\test-classes
[mkdir] Created dir: C:\Program
Installs\poi-src-2.5.1-final-20040804\build\contrib-test-classes
[mkdir] Created dir: C:\Program
Installs\poi-src-2.5.1-final-20040804\build\scratchpad-test-classes
[mkdir] Created dir: C:\Program
Installs\poi-src-2.5.1-final-20040804\build\test-results
[mkdir] Created dir: C:\Program
Installs\poi-src-2.5.1-final-20040804\build\scratchpad-test-results
[mkdir] Created dir: C:\Program
Installs\poi-src-2.5.1-final-20040804\build\contrib-test-results
[mkdir] Created dir: C:\Program
Installs\poi-src-2.5.1-final-20040804\build\tmp\site\build\site\junit
[mkdir] Created dir: C:\Program
Installs\poi-src-2.5.1-final-20040804\build\tmp\site\build\site\jdepend
[mkdir] Created dir: C:\Program
Installs\poi-src-2.5.1-final-20040804\build\tmp\site\src\documentation\c
ontent\jdepend
[mkdir] Created dir: C:\Program
Installs\poi-src-2.5.1-final-20040804\build\tmp\site\build\site\apidocs
[mkdir] Created dir: C:\Program
Installs\poi-src-2.5.1-final-20040804\build\dist
 [copy] Copying 174 files to C:\Program
Installs\poi-src-2.5.1-final-20040804\build\tmp\site\src\documentation
 [copy] Copying 1 file to C:\Program
Installs\poi-src-2.5.1-final-20040804\build\tmp\site
compile-main:
 [copy] Copying 1 file to C:\Program
Installs\poi-src-2.5.1-final-20040804\build\classes
[javac] Compiling 161 source files to C:\Program
Installs\poi-src-2.5.1-final-20040804\build\test-classes
[javac] Note: C:\Program
Installs\poi-src-2.5.1-final-20040804\src\testcases\org\apache\poi\hssf\
record\TestRecordFactory.java uses or overrides a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
compile-scratchpad:
[javac] Compiling 74 source files to C:\Program
Installs\poi-src-2.5.1-final-20040804\build\scratchpad-classes
[javac] C:\Program
Installs\poi-src-2.5.1-final-20040804\src\scratchpad\src\org\apache\poi\
generator\FieldIterator.java:35: package org.apache.xalan.extensions
does not exist
[javac] public void
init(org.apache.xalan.extensions.XSLProcessorContext context,
[javac] ^
[javac] C:\Program
Installs\poi-src-2.5.1-final-20040804\src\scratchpad\src\org\apache\poi\
generator\FieldIterator.java:36: package org.apache.xalan.templates does
not exist
[javac] org.apache.xalan.templates.ElemExtensionCall extElem)
[javac] ^
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 2 errors

BUILD FAILED
C:\Program Installs\poi-src-2.5.1-final-20040804\build.xml:202: Compile
failed; see the compiler error output for details.

Total time: 8 seconds



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List: http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/



RE: Re[2]: problems with POI build

2007-03-23 Thread Levi Strope
I'm using JDK 1.5.



-Original Message-
From: Yegor Kozlov [mailto:[EMAIL PROTECTED] 
Sent: Friday, March 23, 2007 3:28 AM
To: POI Users List
Subject: Re[2]: problems with POI build

I use JDK 1.4.2 and JDK 1.5.

To build POI users need JDK 1.4 or greater. It should be reflected it
the docs somehow.

Compilation under JDK 1.3 fails. I've just tried it and got 68 errors.

Does it concerns you?

Yegor

AO> Which JDK?

AO> Yegor Kozlov wrote:
>> Hi,
>>
>> I don't quite understand what's wrong with POI. I'm using Ant 1.6.2
>> and it works fine for me.
>>
>> POI build.xml is all-sufficient. It downloads the required jars if
>> they are missing. No intervention in Ant's config is required.
>>
>> Regards,
>> Yegor
>> LS> Has anyone tested this with a newer version of ANT other than
1.5.3?
>>
>>  
>>
>>  
>>
>> LS> 
>>
>> LS> From: Levi Strope [mailto:[EMAIL PROTECTED] 
>> LS> Sent: Tuesday, March 20, 2007 11:07 AM
>> LS> To: poi-user@jakarta.apache.org
>> LS> Subject: problems with POI build
>>
>>  
>>
>> LS> I'm using ANT 1.7 and there is no optional.jars - has anyone
worked
>> LS> through this before?
>>
>>  
>>
>> LS> Additionally - I did include all required .JARS per the 'How to
Build'
>> LS> instructions - but I get an error telling me org.apache.xalan
does not
>> LS> exist.  It doesn't exist but I did include it in %ANT_HOME%/lib
so I'm
>> LS> not sure what I need to do.
>>
>>
>> -
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> Mailing List: http://jakarta.apache.org/site/mail2.html#poi
>> The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/
>>   


AO>
-
AO> To unsubscribe, e-mail: [EMAIL PROTECTED]
AO> Mailing List: http://jakarta.apache.org/site/mail2.html#poi
AO> The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List: http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List: http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/



RE: Re[2]: problems with POI build

2007-03-22 Thread Levi Strope
Then I think the problem may be with Eclipse 3.2.  In Eclipse 3.2 if I
follow the build instructions the ANT build script errors out every time
because the directories it is looking for do not exist.

I manually created the directories but I'm still unable to get past the
error that says org.apache.xalan does not exist.  In my situation I've
had to place a lot of these files manually, but no matter what I do this
still causes problems. 

Could it be the version of xalan that I am pulling down?  I believe the
version was 2.7.

-Original Message-
From: Yegor Kozlov [mailto:[EMAIL PROTECTED] 
Sent: Thursday, March 22, 2007 12:59 PM
To: POI Users List
Subject: Re[2]: problems with POI build

Hi,

I don't quite understand what's wrong with POI. I'm using Ant 1.6.2
and it works fine for me.

POI build.xml is all-sufficient. It downloads the required jars if
they are missing. No intervention in Ant's config is required.

Regards,
Yegor
LS> Has anyone tested this with a newer version of ANT other than 1.5.3?

 

 

LS> ____

LS> From: Levi Strope [mailto:[EMAIL PROTECTED] 
LS> Sent: Tuesday, March 20, 2007 11:07 AM
LS> To: poi-user@jakarta.apache.org
LS> Subject: problems with POI build

 

LS> I'm using ANT 1.7 and there is no optional.jars - has anyone worked
LS> through this before?

 

LS> Additionally - I did include all required .JARS per the 'How to
Build'
LS> instructions - but I get an error telling me org.apache.xalan does
not
LS> exist.  It doesn't exist but I did include it in %ANT_HOME%/lib so
I'm
LS> not sure what I need to do.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List: http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List: http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/



RE: problems with POI build

2007-03-22 Thread Levi Strope
Has anyone tested this with a newer version of ANT other than 1.5.3?

 

 



From: Levi Strope [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, March 20, 2007 11:07 AM
To: poi-user@jakarta.apache.org
Subject: problems with POI build

 

I'm using ANT 1.7 and there is no optional.jars - has anyone worked
through this before?

 

Additionally - I did include all required .JARS per the 'How to Build'
instructions - but I get an error telling me org.apache.xalan does not
exist.  It doesn't exist but I did include it in %ANT_HOME%/lib so I'm
not sure what I need to do.

 

 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List: http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/

problems with POI build

2007-03-20 Thread Levi Strope
I'm using ANT 1.7 and there is no optional.jars - has anyone worked
through this before?

 

Additionally - I did include all required .JARS per the 'How to Build'
instructions - but I get an error telling me org.apache.xalan does not
exist.  It doesn't exist but I did include it in %ANT_HOME%/lib so I'm
not sure what I need to do.

 

 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List: http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/