Can your problem be related to the fact that you read and write on the
same file with two different streams ("c:/workbook.xls")?> -----Original Message----- > From: Kong, Yong [mailto:[EMAIL PROTECTED] > Sent: 24 September, 2004 21:55 > To: '[EMAIL PROTECTED]' > Subject: 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: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
