Bug 47553

Summary: shiftRows() produce a corrupted xls file
Product: POI Reporter: Antonio Perez Garcia <antonio.APG>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED INVALID    
Severity: critical    
Priority: P1    
Version: 3.2-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: All   
Attachments: Template
xls obtained when it is opened an error message appears

Description Antonio Perez Garcia 2009-07-21 02:59:04 UTC
Created attachment 24011 [details]
Template

Hi,

I prove this code and the result is a corrupted xls file.

        HSSFWorkbook wb=null;
		File plantilla = new File("/plantillas/PlantillaPrueba.xls");
        try {
			FileInputStream is=new FileInputStream(plantilla);
			wb = new HSSFWorkbook(is);

        
	        HSSFSheet hoja = wb.getSheetAt(1);
	        int i = 11;
			int j = hoja.getLastRowNum();
	        int num = 10;
	        hoja.shiftRows(i, j, num);
	
	        File resp = new File("/plantillas/prueba.xls");    

	    	OutputStream fileOut = new FileOutputStream(resp);
	    	wb.write(fileOut);
	    	fileOut.flush();
			fileOut.close();
			is.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

I think that the problem ocurred when shiftrows is called, because when I comment this line the xls is obtained well formed.

In the attachment file you can ontain the template file use for the example.

thanks.
Comment 1 Antonio Perez Garcia 2009-07-22 00:06:11 UTC
Created attachment 24019 [details]
xls obtained when it is opened an error message appears
Comment 2 Antonio Perez Garcia 2009-07-24 05:48:36 UTC
I tested version 3.5 of POI and works fine, the only problem I have is that my application has to work on java1.4 :S
Comment 3 Yegor Kozlov 2009-07-25 04:09:38 UTC
I confirmed that your test works with current trunk, so there is nothing to fix.

POI 3.5+ requires JDK 1.5. If you need to run it on 1.4, try to use RetroWeaver: 
http://retroweaver.sourceforge.net/

This tool transforms Java class files compiled by a 1.5 compiler into version 1.4 class files which can then be run on any 1.4 virtual machine.

Yegor