You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by sujatha kalluri <ka...@yahoo.com> on 2011/02/08 12:17:49 UTC

POI 3,7 sheet.shiftRows() corrupted the cells

we upgraded from poi 2.5 to 3.7, sheet.shiftRows() is corrupting the cells, 
until shiftting the rows, excel sheet is fine, after shifting, it is corrupting 
the cells by merging them.

 Is it a bug in 3.7??
 Do we have alternative to shiftRows() method?

This happened with .xlsm file (2007 macro enabled workbook) opened in MS office 
2007.

any advice please,
thanks,
Sujatha.


      

Re: POI 3,7 sheet.shiftRows() corrupted the cells

Posted by hartford123 <ka...@yahoo.com>.

Is there any workaround to insert rows in sheet instead of shiftRows(), if
this method is available in ss usermodel, I am wondering why it is not
working properly, it could be a bug.
-- 
View this message in context: http://apache-poi.1045710.n5.nabble.com/POI-3-7-sheet-shiftRows-corrupted-the-cells-tp3375735p3376263.html
Sent from the POI - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: POI 3,7 sheet.shiftRows() corrupted the cells

Posted by Nick Burch <ni...@alfresco.com>.
On Tue, 8 Feb 2011, hartford123 wrote:
> Nick Burch-11 wrote:
>> On Tue, 8 Feb 2011, hartford123 wrote:
>> Could you create a junit test that uses the SS usermodel, which tries the
>> shift + read trick on both HSSF and XSSF? From what you say, it should
>> work with hssf, and fail for xssf. That unit test can then be used to help
>> track down the problem, and also as a check in future to ensure it doesn't
>> get broken again
>
>  why it is failing for XSSF? is there work around for this. I will try 
> to create the junit test

I don't know why it's failing, however much of the shift logic is 
different between HSSF and XSSF because the file formats differ internally

Nick

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: POI 3,7 sheet.shiftRows() corrupted the cells

Posted by hartford123 <ka...@yahoo.com>.


Nick Burch-11 wrote:
> 
> On Tue, 8 Feb 2011, hartford123 wrote:
> 
> Could you create a junit test that uses the SS usermodel, which tries the 
> shift + read trick on both HSSF and XSSF? From what you say, it should 
> work with hssf, and fail for xssf. That unit test can then be used to help 
> track down the problem, and also as a check in future to ensure it doesn't 
> get broken again
> 
> Thanks
> Nick
> 
> 
> 

Nick,

  why it is failing for XSSF? is there work around for this. I will try to
create the junit test

-- 
View this message in context: http://apache-poi.1045710.n5.nabble.com/POI-3-7-sheet-shiftRows-corrupted-the-cells-tp3375735p3376066.html
Sent from the POI - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: POI 3,7 sheet.shiftRows() corrupted the cells

Posted by hartford123 <ka...@yahoo.com>.

This is the xml showing errors

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> 
- <recoveryLog
xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
  <logFileName>error033440_77.xml</logFileName> 
  <summary>Errors were detected in file 'D:\Documents and
Settings\xdbd138\Local Settings\Temporary Internet
Files\Content.IE5\VDHUZB60\TDPTemplate[4].xlsm'</summary> 
- <removedRecords summary="Following is a list of removed records:">
  <removedRecord>Removed Records: Merge cells from /xl/worksheets/sheet1.xml
part</removedRecord> 
  </removedRecords>
  </recoveryLog>
-- 
View this message in context: http://apache-poi.1045710.n5.nabble.com/POI-3-7-sheet-shiftRows-corrupted-the-cells-tp3375735p3376064.html
Sent from the POI - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: POI 3,7 sheet.shiftRows() corrupted the cells

Posted by Nick Burch <ni...@alfresco.com>.
On Tue, 8 Feb 2011, hartford123 wrote:
> Here is the code I am using.Suppose when shiftRows()  is done  for 2 rows
> to shift down,ie from 47 to 49, then current row is showing 49 and if I want
> to start writing the content from 47, I am not able to read the row at 47
> and it coming out as null. thus happened to create a row at 47 again.

Could you create a junit test that uses the SS usermodel, which tries the 
shift + read trick on both HSSF and XSSF? From what you say, it should 
work with hssf, and fail for xssf. That unit test can then be used to help 
track down the problem, and also as a check in future to ensure it doesn't 
get broken again

Thanks
Nick

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: POI 3,7 sheet.shiftRows() corrupted the cells

Posted by hartford123 <ka...@yahoo.com>.
Nick,

  you are right we were using HSSF and we upgraded to poi 3.7 and changed
the code to SS user model so that it takes both XSSF and HSSF.

  Here is the code I am using.Suppose when shiftRows()  is done  for 2 rows
to shift down,ie from 47 to 49, then current row is showing 49 and if I want
to start writing the content from 47, I am not able to read the row at 47
and it coming out as null. thus happened to create a row at 47 again.

if (rowsneeded > 0) { // suppose rowsneeded is 2 and row.getRowNum() is 47        
sheet.shiftRows(row.getRowNum() , sheet.getLastRowNum(), rowsneeded);
}
Above code will shift two rows , initially when sheet.getRowNum() is 47,
after shifting the rows, row is showing as 49, as I want to start writing
the content from 47, I have to go to back to 47, but when I say  row =
sheet.getRow(row.getRowNum() - rowsneeded); which is 49-2 = 47,  47th row is
coming out as null , I happen to create a row again at 47 to write the
content before starting the iterator , why 47th row is coming out as null
after shifting the rows?

                  // I added this following line before starting for loop
                 		row = sheet.createRow(row.getRowNum() - rowsneeded);
		for (Iterator it = item.getTrlEntries().iterator(); it.hasNext();) {
			
			entry = (L2DevelopmentPlan)it.next();				
			formatCells(row, entry, sheet);
                         }
			

I will post the the xml error soon which comes while loading excel.

-- 
View this message in context: http://apache-poi.1045710.n5.nabble.com/POI-3-7-sheet-shiftRows-corrupted-the-cells-tp3375735p3375934.html
Sent from the POI - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: POI 3,7 sheet.shiftRows() corrupted the cells

Posted by Nick Burch <ni...@alfresco.com>.
On Tue, 8 Feb 2011, sujatha kalluri wrote:
> we upgraded from poi 2.5 to 3.7, sheet.shiftRows() is corrupting the 
> cells, until shiftting the rows, excel sheet is fine, after shifting, it 
> is corrupting the cells by merging them.
>
> This happened with .xlsm file (2007 macro enabled workbook) opened in MS office
> 2007.

To confirm - you've gone from using HSSF in poi 2.5 to using XSSF in poi 
3.7?

Can you create a very simple unit test that shows the problem? Also, if 
you look at the resulting xml (.xlx and .xlsm are zip files of xml files), 
can you spot what's wrong?

Nick