Hello all,
        I made this small test class to see if I could isolate the problem I'm
having. The test class seems to work fine when it is run by itself, however
my original code still has problems. I do not understand the differences
between this test case and my production code. Perhaps its an underlying API
issue? I've also tried this with the 1.7 dev release and I get the same
behavior. Anyone got any ideas at all?

test class:
import java.util.List;
import java.util.Iterator;
import java.util.ResourceBundle;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.FileWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileInputStream;
import java.util.zip.ZipOutputStream;
import java.util.zip.ZipEntry;

import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;

class textExport{

    public static void main(String args[]) throws IOException {

        // create a new workbook
        HSSFWorkbook wb = new HSSFWorkbook();
        // create a new sheet
        HSSFSheet theSheet = wb.createSheet();
        // declare a row object reference
        HSSFRow theRow = null;
        // declare a cell object reference
        HSSFCell theCell = null;
        // create cell style
        HSSFCellStyle cs = wb.createCellStyle();
        // create font object
        HSSFFont f = wb.createFont();
        f.setFontHeightInPoints((short) 10);
        //set cell stlye
        cs.setFont(f);
        wb.setSheetName(0, "Tool Map");

        int j=0;

        theRow = theSheet.createRow((short)j);
        theRow.setHeight(( short ) 0x249);

        System.out.println("Row created at :"+j);
        System.out.println("Row is actually: "+theRow.getRowNum());

        j++;

        theCell = theRow.createCell((short)0,HSSFCell.CELL_TYPE_STRING);
        theCell.setCellStyle(cs);
        theCell.setCellValue("TOOL ID");

        theCell = theRow.createCell((short)1,HSSFCell.CELL_TYPE_STRING);
        theCell.setCellStyle(cs);
        theCell.setCellValue("OBJECT ID");

        theRow = theSheet.createRow((short)j);

        System.out.println("Row created at :"+j);
        System.out.println("Row is actually: "+theRow.getRowNum());

        j++;

        theCell = theRow.createCell((short)0,HSSFCell.CELL_TYPE_STRING);
        theCell.setCellStyle(cs);
        theCell.setCellValue(12343);

        theCell = theRow.createCell((short)1,HSSFCell.CELL_TYPE_STRING);
        theCell.setCellStyle(cs);
        theCell.setCellValue("HELLO" + 123425423);

        File file = new File("export.xls");

        file.delete();

        FileOutputStream out = new FileOutputStream(file);

        wb.write(out);

        out.close();
    }

}

thanks,
-Jared

-----Original Message-----
From: Jared Walker [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 22, 2002 4:00 PM
To: 'POI Users List'
Subject: RE: Cell content not saving


Heres the stuff:

Shamelessly ripped from the test class:
                // create a new workbook
                HSSFWorkbook wb = new HSSFWorkbook();
                // create a new sheet
                HSSFSheet theSheet = wb.createSheet();
                // declare a row object reference
                HSSFRow theRow = null;
                // declare a cell object reference
                HSSFCell theCell = null;
                // create cell style
                HSSFCellStyle cs = wb.createCellStyle();
                // create font object
                HSSFFont f = wb.createFont();
                f.setFontHeightInPoints((short) 10);
                //set cell stlye
                cs.setFont(f);

Then to write it out:
                File file = new File(fileRoot+"export.xls");
                FileOutputStream out = new FileOutputStream(file);
                wb.write(out);

Straight and simple... and probably wrong.

thanks,
-Jared

-----Original Message-----
From: Andrew C. Oliver [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 22, 2002 3:53 PM
To: POI Users List
Subject: Re: Cell content not saving


Show me the code you used to instantiate the workbook and write it back
to disk.

-Andy.

Jared Walker wrote:
<-----SNIP---->


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

Reply via email to