You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2003/06/24 23:57:55 UTC

DO NOT REPLY [Bug 21066] New: - Can not modify a blank spreadsheet

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21066>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21066

Can not modify a blank spreadsheet

           Summary: Can not modify a blank spreadsheet
           Product: POI
           Version: 2.0-dev
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Blocker
          Priority: Other
         Component: HSSF
        AssignedTo: poi-dev@jakarta.apache.org
        ReportedBy: tschafer@hotmail.com


I have tried:
jakarta-poi-1.8.0-dev-20020919.jar
jakarta-poi-1.10.0-dev-20030222.jar
poi-2.0-pre1-20030517.jar

In each case using POI to modify a blank (open Excel press save) spreadsheet
created using each of:
Excel 2000 (9.0.2720)
Excel 2002 (10.2614.2625)
resulted in a blank spreadsheet

Using other input spreadsheets of varying complexity would result in a corrupt
output spreadsheet
But generally the result spreadsheet appeared as if it had not been modified

This problem does not occur using jakarta-poi-1.5.1-final-20020615.jar



Code sample:

import java.io.FileInputStream;
import java.io.FileOutputStream;

import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFCell;

public class testPOI {
	public static void main(String[] args) throws java.io.IOException,
java.io.FileNotFoundException {
		// section 1
		POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream("blank.xls"));
		HSSFWorkbook wb = new HSSFWorkbook(fs);
		HSSFSheet sheet = wb.getSheetAt(0);
		
		// section 2
		//HSSFWorkbook wb = new HSSFWorkbook();
		//HSSFSheet sheet = wb.createSheet("new sheet");
		
		HSSFRow row = sheet.getRow(2);
		if(row == null)
			row = sheet.createRow((short)2);
		HSSFCell cell = row.getCell((short)3);
		if(cell == null)
			cell = row.createCell((short)3);
		cell.setCellType(HSSFCell.CELL_TYPE_STRING);
		cell.setCellValue("a test");
		
		FileOutputStream fileOut = new FileOutputStream("output.xls");
		wb.write(fileOut);
		fileOut.close();
	}
}