I must admit that I am surprised you are encountering problems with memory when you are working with a workbook of this size - we regularly use books that are in excess of 50meg and do not run into such problems. How much memory have you allocated to the jvm? Have you tried increasing the amount of memory available using the relevant command line switches - -Xms/-Xmx.
"Monga, Ashish" <[EMAIL PROTECTED]> wrote: Hi, I had used this mechanism to get to the first row. The issue is that "hssf_getSheet(book: 'January'); " loads the complete worksheet in the memory and it could result in 'OutofMemory' error if the excel sheet is big. [I tested with 21 MB excel sheet.] I tried using Event model using HSSFListener and EventExample provided but I could not figure out how to read only the first row from the excel sheet. Can the Event model be of help in this scenario? Is it possible to read row-by-row basis using the Event model? Regards Ashish -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: 25 August 2006 19:35 To: POI Users List Subject: Re: Reading 1 row from excel file All that being said, you can open the workbook/sheet and position to the 1st row, and specific cells you need to get the information. See the psudo code below // // Load an existing spreadsheet into memory // book = hssf_open('demo.xls'); // // get the HSSFCell object that needs changing // sheet = hssf_getSheet(book: 'January'); row = HSSFSheet_getRow(sheet: 5); cell = HSSFRow_GetCell(row: 1); // // See what the value of the cell in row 7, column 2 is: // row = HSSFSheet_getRow(sheet: 7); cell = HSSFRow_GetCell(row: 2); type = HSSFCell_getCellType(cell); // // you will need to test type for the type of data // strval has the data value when type = CELL_TYPE_STRING; StrVal += String_getBytes(HSSFCell_getStringCellValue(cell) when type = CELL_TYPE_FORMULA; StrVal += String_getBytes(HSSFCell_getCellFormula(cell)); when type = CELL_TYPE_NUMERIC; NumVal = HSSFCell_getNumericCellValue(cell); StrVal += %char(%dech(NumVal:15:2)); Anthony Andrews 08/25/2006 01:00 PM Please respond to "POI Users List" To POI Users List cc Subject Re: Reading 1 row from excel file Hate to say this but I do not believe that you will find a way to read one and only one row from an Excel file. As I understand it, the BIFF8 file format that is used to encode data for Excel spreadsheets has a structure that is nothing like a relational database. It is necessary to read most, if not all of the file in order to present the data correctly to the user through Excel. I am not an expert and could very well be wrong but I do not believe that the data is organised within that file in a simple line by line format nor is it structured in a manner similar to an xml data file. As a result, I think that you will be forced to use a technique that parses all of the file before you can get at the data in the first row. "Monga, Ashish" wrote: Hi, My requirement is to read the first row from the excel file as it contains header information for the data. Hence, I do not want to load the complete excel file in the memory. Can some one suggest a way to do so? I have tried using the HSSF Event model but could not figure out how to read one complete row (and only 1 row). Thanks Ashish ------------------------------------------------------------------------------ This message is intended only for the personal and confidential use of the designated recipient(s) named above. If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited. This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction, or as an official statement of Lehman Brothers. Email transmission cannot be guaranteed to be secure or error-free. Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such. All information is subject to change without notice. --------------------------------------------------------------------- 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/ --------------------------------- Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2ยข/min or less. ------------------------------------------------------------------------------ This message is intended only for the personal and confidential use of the designated recipient(s) named above. If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited. This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction, or as an official statement of Lehman Brothers. Email transmission cannot be guaranteed to be secure or error-free. Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such. All information is subject to change without notice. --------------------------------------------------------------------- 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/ --------------------------------- Do you Yahoo!? Get on board. You're invited to try the new Yahoo! Mail.
