You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by "Kong, Yong" <Yo...@compuware.com> on 2004/09/24 19:44:38 UTC

Problem with VBScript

Hi,

I'm new to POI and I'm running into a problem that I need some help with. 
I'd like to read in an Excel template with VBScripts built in, insert/modify
some data and write out a new Excel file with the VBScripts intact. I run
the following sample program but the VBScript in Excel was corrupted. Any
ideas what caused the corruption and how to fix it? Thanks.

public class ReadWriteWorkbook
{
    public static void main(String[] args)
        throws IOException
    {
        POIFSFileSystem fs      =
                new POIFSFileSystem(new FileInputStream("c:/workbook.xls"));
        HSSFWorkbook wb = new HSSFWorkbook(fs);
        HSSFSheet sheet = wb.getSheetAt(0);
        HSSFRow row = sheet.getRow(4);
        if (row == null)
            row = sheet.createRow(4);
        HSSFCell cell = row.getCell((short)3);
        if (cell == null)
            cell = row.createCell((short)3);
        cell.setCellType(HSSFCell.CELL_TYPE_STRING);
        cell.setCellValue("test name");

        // Write the output to a file
        FileOutputStream fileOut = new FileOutputStream("c:/workbook.xls");
        wb.write(fileOut);
        fileOut.close();

    }
}


The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or disclose
it to anyone else. If you received it in error please notify us immediately
and then destroy it. 


---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-user-help@jakarta.apache.org


Re: Problem with VBScript

Posted by Danny Mui <da...@muibros.com>.
probably similar to this?
http://issues.apache.org/bugzilla/show_bug.cgi?id=18155

attach yours too please :)

Kong, Yong wrote:
> Hi,
> 
> I'm new to POI and I'm running into a problem that I need some help with. 
> I'd like to read in an Excel template with VBScripts built in, insert/modify
> some data and write out a new Excel file with the VBScripts intact. I run
> the following sample program but the VBScript in Excel was corrupted. Any
> ideas what caused the corruption and how to fix it? Thanks.
> 
> public class ReadWriteWorkbook
> {
>     public static void main(String[] args)
>         throws IOException
>     {
>         POIFSFileSystem fs      =
>                 new POIFSFileSystem(new FileInputStream("c:/workbook.xls"));
>         HSSFWorkbook wb = new HSSFWorkbook(fs);
>         HSSFSheet sheet = wb.getSheetAt(0);
>         HSSFRow row = sheet.getRow(4);
>         if (row == null)
>             row = sheet.createRow(4);
>         HSSFCell cell = row.getCell((short)3);
>         if (cell == null)
>             cell = row.createCell((short)3);
>         cell.setCellType(HSSFCell.CELL_TYPE_STRING);
>         cell.setCellValue("test name");
> 
>         // Write the output to a file
>         FileOutputStream fileOut = new FileOutputStream("c:/workbook.xls");
>         wb.write(fileOut);
>         fileOut.close();
> 
>     }
> }
> 
> 
> The contents of this e-mail are intended for the named addressee only. It
> contains information that may be confidential. Unless you are the named
> addressee or an authorized designee, you may not copy or use it, or disclose
> it to anyone else. If you received it in error please notify us immediately
> and then destroy it. 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: poi-user-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-user-help@jakarta.apache.org


AW: Problem with VBScript

Posted by "KHZ (SAW)" <ka...@sawag.com>.
Hi Yong.

Does it also happen with a file built from the scratch?

We had big Excel files which we copied and modified and had problems
hard to understand. Building the file from the scratch we didn't have
any problems any more.

Regards,	Karl-Heinz.


-----Ursprüngliche Nachricht-----
Von: Kong, Yong [mailto:Yong.Kong@compuware.com] 
Gesendet: Freitag, 24. September 2004 19:45
An: 'poi-user@jakarta.apache.org'
Betreff: Problem with VBScript

Hi,

I'm new to POI and I'm running into a problem that I need some help
with. 
I'd like to read in an Excel template with VBScripts built in,
insert/modify
some data and write out a new Excel file with the VBScripts intact. I
run
the following sample program but the VBScript in Excel was corrupted.
Any
ideas what caused the corruption and how to fix it? Thanks.

public class ReadWriteWorkbook
{
    public static void main(String[] args)
        throws IOException
    {
        POIFSFileSystem fs      =
                new POIFSFileSystem(new
FileInputStream("c:/workbook.xls"));
        HSSFWorkbook wb = new HSSFWorkbook(fs);
        HSSFSheet sheet = wb.getSheetAt(0);
        HSSFRow row = sheet.getRow(4);
        if (row == null)
            row = sheet.createRow(4);
        HSSFCell cell = row.getCell((short)3);
        if (cell == null)
            cell = row.createCell((short)3);
        cell.setCellType(HSSFCell.CELL_TYPE_STRING);
        cell.setCellValue("test name");

        // Write the output to a file
        FileOutputStream fileOut = new
FileOutputStream("c:/workbook.xls");
        wb.write(fileOut);
        fileOut.close();

    }
}


The contents of this e-mail are intended for the named addressee only.
It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or
disclose
it to anyone else. If you received it in error please notify us
immediately
and then destroy it. 


---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-user-help@jakarta.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-user-help@jakarta.apache.org