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 <[EMAIL PROTECTED]> 
08/25/2006 01:00 PM
Please respond to
"POI Users List" <[email protected]>


To
POI Users List <[email protected]>
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" <[EMAIL PROTECTED]> 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.

Reply via email to