Hey! I'm sorry! I didn't specify the problem:
Nothing appears in A1 of the first sheet of the resultant xls.
;)
-- Mauro

On Wed, 19 Nov 2003, Mauro Daniel Ardolino wrote:

> Hello!
> 
> I'm having a problem when I try to read/write an excel workbook with 2
> sheets.
> 
> In the A1 of the second sheet I have a formula (cross sheet one!).
> 
> The first sheet is empty.
> 
> The program must set "hello" in A1 of the first sheet.  And then save.
> 
> Environment:
> - Linux RH73
> - JSDK 1.4.1_02
> - POI-VERSION: 1.10.0-dev-20030222
> 
> Here's the code...do you see anything wrong?
> 
> package ar.com.altersoft.msexcel.testing;
> 
> import java.io.File;
> import java.io.FileInputStream;
> import java.io.FileNotFoundException;
> import java.io.FileOutputStream;
> import java.io.IOException;
> 
> import org.apache.poi.hssf.usermodel.HSSFCell;
> import org.apache.poi.hssf.usermodel.HSSFRow;
> import org.apache.poi.hssf.usermodel.HSSFSheet;
> import org.apache.poi.hssf.usermodel.HSSFWorkbook;
> import org.apache.poi.poifs.filesystem.POIFSFileSystem;
> 
> 
> public class WritingAnExistingXlsTest {
>       public static void main(String[] args) {
>               try {
>                       FileInputStream fin = new 
> FileInputStream("templateDemoTesting.xls");
>                       POIFSFileSystem poifs = new POIFSFileSystem(fin);
>                       HSSFWorkbook wb= new HSSFWorkbook(poifs);
>                       //
>                       HSSFSheet sheet=wb.getSheetAt(wb.getSheetIndex("page1"));
>                       //sheet.setSelected(true);
>                       HSSFRow row= sheet.getRow(0);
>                       if(row==null){
>                               row= sheet.createRow(0);
>                       }
>                       HSSFCell cell= row.getCell((short)0);
>                       if(cell==null){
>                               cell= row.createCell((short)0);
>                       }
>                       cell.setCellType(HSSFCell.CELL_TYPE_STRING);
>                       cell.setCellValue("hello");
>                       //
>                       FileOutputStream fileOut = new 
> FileOutputStream("templateDemoTestingResult.xls");
>                       wb.write(fileOut);
>                       fileOut.close();
>               } catch (FileNotFoundException e) {
>                       e.printStackTrace();
>               } catch (IOException e) {
>                       e.printStackTrace();                    
>               }               
>       }
>       
> }// END CLASS
> 
> 
> 
> Thanks in advance. Regards,
> 
> -- Mauro
> 
> 
> 
> 

-- 
Ing.Mauro Daniel Ardolino
Departamento de Desarrollo y Servicios
Altersoft
mailto: [EMAIL PROTECTED]
website: http://www.altersoft.com.ar

   .~.
   /v\ 
  // \\ "In Linux we trust"
 /(   )\ 
  ^^-^^


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to