You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Naga Raju Parsa <np...@yahoo.com> on 2004/07/09 23:04:44 UTC

out of memory problem when reading xls

Hi,
 
I'm trying to read an xls file which is 2.5 MB, and I get the following exception.
 
java.lang.OutOfMemoryError
 <<no stack trace available>>
Exception in thread "main" Process terminated with exit code 1
 
Here is the code :
 InputStream myxls = new FileInputStream(exitingXLS1FileName);
  HSSFWorkbook wbexisting     = new HSSFWorkbook(myxls);
 
If I read small size files, it works fine.  Any help is appreciated.
Running the app (stanalone) under ItelliJ IDEA.
 
Thanks,
Naga Parsa
 

		
---------------------------------
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!

null row problem when adding new row

Posted by Naga Raju Parsa <np...@yahoo.com>.
Hi,

 

I'm having the following weird problem.  Can anyone help me please?

 

I've 10 rows in my xls.

 

I add new rows programmatically using the following little add new row method that I wrote.

 

Say, I added one new row after the second row.

If I say, sh.getRow(9), I get the 9th row, which is correct because, there is a new row added.

 

When I try to read the 10th row ( HSSFRow row = sh.getRow(9); ), here the row is null.  Any help is appreciated please.

 

    /**
     * inserts a new row in the spreadsheet
     * @param sh
     * @param newRowNumber
     */
    public static final HSSFRow addNewRow(HSSFSheet sh, int newRowNumber)
    {
        // shift the cells down and make room to add new row
        sh.shiftRows(newRowNumber, sh.getLastRowNum(), 1);

 

        HSSFRow newRow = sh.createRow(newRowNumber);
        HSSFCell         c      = null;

 

        for (short cellnum = ( short ) 0; cellnum < 25; cellnum++) {
            c = newRow.createCell(cellnum, HSSFCell.CELL_TYPE_STRING);
            c.setCellValue("");
        }

 

        return newRow;
    }

 

Thanks in advance,

Naga

 

		
---------------------------------
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!

Re: out of memory problem when reading xls

Posted by Qingtian Wang <qi...@ualloyalty.com>.
I've read files larger than that without problems. Are you running 
IntelliJ on Windows? What's your virtual memory size? When Java says 
"out of memory", from the system monitor of Windows, do you really see 
all the vitual memory being used up?

Qingtian Wang



Naga Raju Parsa wrote:

> Hi,
>  
> I'm trying to read an xls file which is 2.5 MB, and I get the following exception.
>  
> java.lang.OutOfMemoryError
>  <<no stack trace available>>
> Exception in thread "main" Process terminated with exit code 1
>  
> Here is the code :
>  InputStream myxls = new FileInputStream(exitingXLS1FileName);
>   HSSFWorkbook wbexisting     = new HSSFWorkbook(myxls);
>  
> If I read small size files, it works fine.  Any help is appreciated.
> Running the app (stanalone) under ItelliJ IDEA.
>  
> Thanks,
> Naga Parsa
>  
> 
> 		
> ---------------------------------
> Do you Yahoo!?
> New and Improved Yahoo! Mail - 100MB free storage!

-- 
Qingtian Wang
WHQUL
847-466-9568 (work)
702-447-7688 (fax)

---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-user-help@jakarta.apache.org