poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lucinda_Rockem...@vwr.com
Subject Excel file too complicated?
Date Thu, 13 Mar 2003 18:54:02 GMT
Can someone look at this code and the Excel file it attempts to modify and
let me know if the Excel file is too complicated for POI/HSSF to send to
the output stream correctly?  When I run this, I open the modified file and
get a workbook with no sheets in it.

Thanks for any advice!

(See attached file: testAutoStats.xls)

import java.io.*;
import java.util.*;
import org.apache.poi.dev.*;
import org.apache.poi.hpsf.*;
import org.apache.poi.hpsf.littleendian.*;
import org.apache.poi.hpsf.wellknown.*;
import org.apache.poi.hssf.dev.*;
import org.apache.poi.hssf.eventmodel.*;
import org.apache.poi.hssf.model.*;
import org.apache.poi.hssf.record.*;
import org.apache.poi.hssf.record.aggregates.*;
import org.apache.poi.hssf.record.formula.*;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.hssf.util.*;
import org.apache.poi.poifs.common.*;
import org.apache.poi.poifs.dev.*;
import org.apache.poi.poifs.eventfilesystem.*;
import org.apache.poi.poifs.filesystem.*;
import org.apache.poi.poifs.property.*;
import org.apache.poi.poifs.storage.*;
import org.apache.poi.util.*;

public class poiTestWriter {

      public static void main(String[] args) {
         try {
            poiTestWriter writer = new poiTestWriter();

            int writeThis = 10093;

            writer.writeReport(writeThis);

         } catch ( Exception e) {
         }
      }

     private void writeReport(int writeThis)
     {
        try {
           FileInputStream in = new FileInputStream("./testAutoStats.xls");
           POIFSFileSystem poifs = new POIFSFileSystem(in);

           HSSFWorkbook wb = new HSSFWorkbook(poifs);

           FileOutputStream output = new FileOutputStream
("./testAutoStatsMod.xls");
           HSSFSheet sheet = wb.getSheetAt(0);

           HSSFRow row = sheet.createRow((short)28);
           HSSFCell cell = row.createCell((short) 6);

           cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
           cell.setCellValue(writeThis);

           wb.write(output);
           output.close();
           in.close();

         } catch (Exception e)
         {
            e.printStackTrace();
         }
     }

}


Lucinda R. Rockemore
VWR International . e-Business
e-mail: lucinda_rockemore@vwr.com
phone: 610 429 2731
fax: 610 429 5559






****************************************************************************************************************

The information contained in this e-mail message may be privileged,
confidential and protected from disclosure.
If you are not the intended recipient, any dissemination, distribution or
copying is strictly prohibited. If you think
that you have received this e-mail message in error please e-mail the
sender and delete the message. Thank you
*****************************************************************************************************************



Mime
View raw message