Bug 47553 - shiftRows() produce a corrupted xls file
Summary: shiftRows() produce a corrupted xls file
Status: RESOLVED INVALID
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.2-FINAL
Hardware: PC All
: P1 critical (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-07-21 02:59 UTC by Antonio Perez Garcia
Modified: 2009-07-25 04:09 UTC (History)
0 users



Attachments
Template (24.50 KB, application/vnd.ms-excel)
2009-07-21 02:59 UTC, Antonio Perez Garcia
Details
xls obtained when it is opened an error message appears (28.50 KB, application/vnd.ms-excel)
2009-07-22 00:06 UTC, Antonio Perez Garcia
Details

Note You need to log in before you can comment on or make changes to this bug.
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