I get the same exception if I try to read the excel file that you sent. However if I 
remove the list in the excel sheet, I can read the excel sheet correctly.
Probably it is the list that is causing the problem. I am using POI version 2.5

Rahul Phadnis



--- ORIGINAL MESSAGE ---
From:[EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject:Re: AW: does poi 2.5  support lists
Date: 04/26/2004 08:07:34 AM
hi Karl-Heinz,

Thanks for the prompt reply.Iam trying to read a simple excel file that 
contians a list.Iam using POI to read the excel file.I get exception.I 
wnat to read the fiel and add then write to that file.I need this 
functionality in my project.I tried doing it to a sample excel file.You 
said you have not used POI ?do u mean u have not used it to even read the 
excel file?Even iam using the latest POI version 2.5.
Iam sending you the client code and the sample excel fiel.coudl you help 
me out with this.
Thanks for the help
Kamala

-----------------------------------------------------------------------------
POIFSFileSystem fs  =new POIFSFileSystem(new 
FileInputStream("c:/excels/trialworkbook.xls"));
 
                HSSFWorkbook wb = new HSSFWorkbook(fs);
                HSSFSheet sheet = wb.getSheetAt(0);
                HSSFRow row = sheet.getRow(5);
                HSSFCell cell = row.getCell((short)1);
                System.out.println("cell : "+cell);
                if (cell == null)
                {
                          System.out.println("inside if"); 
                  cell = row.createCell((short)1);
                  cell.setCellType(HSSFCell.CELL_TYPE_STRING);
                  cell.setCellValue("test");
                }
                else
                        cell.setCellValue("test");
                System.out.println(cell.getStringCellValue()); 
                FileOutputStream fileOut = new 
FileOutputStream("c:/excels/trialworkbook.xls");
                wb.write(fileOut);
                fileOut.close();
                }catch(Exception e)
                { 
                         System.out.println("Exception : "+e);
                         e.printStackTrace(); 
                }
        }
<br><font size=2 face="Courier New">hi Karl-Heinz,</font>
<br>
<br><font size=2 face="Courier New">Thanks for the prompt reply.Iam trying to read a 
simple excel file that contians a list.Iam using POI to read the excel file.I get 
exception.I wnat to read the fiel and add then write to that file.I need this 
functionality in my project.I tried doing it to a sample excel file.You said you have 
not used POI ?do u mean u have not used it to even read the excel file?Even iam using 
the latest POI version 2.5.</font>
<br><font size=2 face="Courier New">Iam sending you the client code and the sample 
excel fiel.coudl you help me out with this.</font>
<br><font size=2 face="Courier New">Thanks for the help</font>
<br><font size=2 face="Courier New">Kamala</font>
<br>
<br><font size=2 face="Courier 
New">-----------------------------------------------------------------------------</font>
<br><font size=2 face="Courier New">POIFSFileSystem fs �=</font><font size=2 
color=#820040 face="Courier New"><b>new</b></font><font size=2 face="Courier New"> 
POIFSFileSystem(</font><font size=2 color=#820040 face="Courier 
New"><b>new</b></font><font size=2 face="Courier New"> FileInputStream(</font><font 
size=2 color=#4200ff face="Courier New">"c:/excels/trialworkbook.xls"</font><font 
size=2 face="Courier New">));</font>
<br><font size=2 face="Courier New">� � � � � � � � � � � � </font>
<br><font size=2 face="Courier New">� � � � � � � � HSSFWorkbook wb = </font><font 
size=2 color=#820040 face="Courier New"><b>new</b></font><font size=2 face="Courier 
New"> HSSFWorkbook(fs);</font>
<br><font size=2 face="Courier New">� � � � � � � � HSSFSheet sheet = 
wb.getSheetAt(0);</font>
<br><font size=2 face="Courier New">� � � � � � � � HSSFRow row = 
sheet.getRow(5);</font>
<br><font size=2 face="Courier New">� � � � � � � � HSSFCell cell = 
row.getCell((</font><font size=2 color=#820040 face="Courier 
New"><b>short</b></font><font size=2 face="Courier New">)1);</font>
<br><font size=2 face="Courier New">� � � � � � � � System.out.println(</font><font 
size=2 color=#4200ff face="Courier New">"cell : "</font><font size=2 face="Courier 
New">+cell);</font>
<br><font size=2 face="Courier New">� � � � � � � � </font><font size=2 color=#820040 
face="Courier New"><b>if</b></font><font size=2 face="Courier New"> (cell == 
</font><font size=2 color=#820040 face="Courier New"><b>null</b></font><font size=2 
face="Courier New">)</font>
<br><font size=2 face="Courier New">� � � � � � � � {</font>
<br><font size=2 face="Courier New">� � � � � � � � � � � � � 
System.out.println(</font><font size=2 color=#4200ff face="Courier New">"inside 
if"</font><font size=2 face="Courier New">); � � � �</font>
<br><font size=2 face="Courier New">� � � � � � � � � cell = 
row.createCell((</font><font size=2 color=#820040 face="Courier 
New"><b>short</b></font><font size=2 face="Courier New">)1);</font>
<br><font size=2 face="Courier New">� � � � � � � � � 
cell.setCellType(HSSFCell.CELL_TYPE_STRING);</font>
<br><font size=2 face="Courier New">� � � � � � � � � cell.setCellValue(</font><font 
size=2 color=#4200ff face="Courier New">"test"</font><font size=2 face="Courier 
New">);</font>
<br><font size=2 face="Courier New">� � � � � � � � }</font>
<br><font size=2 face="Courier New">� � � � � � � � </font><font size=2 color=#820040 
face="Courier New"><b>else</b></font>
<br><font size=2 face="Courier New">� � � � � � � � � � � � 
cell.setCellValue(</font><font size=2 color=#4200ff face="Courier 
New">"test"</font><font size=2 face="Courier New">);</font>
<br><font size=2 face="Courier New">� � � � � � � � � � � 
System.out.println(cell.getStringCellValue()); </font>
<br><font size=2 face="Courier New">� � � � � � � � � � � FileOutputStream fileOut = 
</font><font size=2 color=#820040 face="Courier New"><b>new</b></font><font size=2 
face="Courier New"> FileOutputStream(</font><font size=2 color=#4200ff face="Courier 
New">"c:/excels/trialworkbook.xls"</font><font size=2 face="Courier New">);</font>
<br><font size=2 face="Courier New">� � � � � � � � wb.write(fileOut);</font>
<br><font size=2 face="Courier New">� � � � � � � � fileOut.close();</font>
<br><font size=2 face="Courier New">� � � � � � � � }</font><font size=2 color=#820040 
face="Courier New"><b>catch</b></font><font size=2 face="Courier New">(Exception 
e)</font>
<br><font size=2 face="Courier New">� � � � � � � � { </font>
<br><font size=2 face="Courier New">� � � � � � � � � � � � 
�System.out.println(</font><font size=2 color=#4200ff face="Courier New">"Exception : 
"</font><font size=2 face="Courier New">+e);</font>
<br><font size=2 face="Courier New">� � � � � � � � � � � � �e.printStackTrace(); � � 
� � � �</font>
<br><font size=2 face="Courier New">� � � � � � � � }</font>
<br><font size=2 face="Courier New">� � � � 
}</font>---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Tip the world over on its side and everything loose will land in Los Angeles.. - Frank 
Lloyd Wright
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to