You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by David Hoffer <dh...@gmail.com> on 2009/10/31 14:40:32 UTC

3.5-FINAL causes corrupt cells after shiftRows()

I have a new application using POI version 3.5-FINAL and I am seeing what
appears to be a bug in POI.

Everything is fine until I call shiftRows() on a sheet.  I.e.

sheet.shiftRows(firstRow.getRowIndex(),
                lastRow.getRowIndex(),
                3 - firstRow.getRowIndex(),
                true,
                true);

The problem is that after this call some of the cells in the row(s) are
missing their data.  The cells had data before the move and now some are
just plan empty!

What I am doing here is moving a set of rows up by a few rows. (And I have
previously cleared the rows I am moving into...perhaps I did not need to.)
I immediately save the workbook after this, e.g.

workbook.write(new FileOutputStream(tempFile));

Is this a known issue?  How can I fix this?

Just let me know if you need to see examples of the error.  In my case some
cells in columns B & C are erased.

Thanks!

Re: 3.5-FINAL causes corrupt cells after shiftRows()

Posted by David Hoffer <dh...@gmail.com>.
Hi Dave,

Yeah, that's what I did...seems like a hack but it works.  (Right now there
is only one merged set of cells so that's what I un-merged.  Someone could
add more in the future and it would be broke again.)  Seems like a row
delete/move should auto do this for all cells in the row.

Thanks!
-Dave

On Sat, Oct 31, 2009 at 8:45 AM, David Fisher <df...@jmlafferty.com>wrote:

> Try unmerging the cells on your target row first.
>
> Sorry, I don't have more details to help you, but you seem to be under a
> serious deadline.
>
> Regards,
> Dave
>
>
> On Oct 31, 2009, at 7:04 AM, David Hoffer wrote:
>
>  I have more info on this issue.
>>
>> What is happening is that in the row that has the 'missing cells' the
>> old/previous row had an alignment of 'Merge cells' for columns A, B, C &
>> D.
>>
>> Before I called shiftRows() I called sheet.removeRow(hssfRow).  I did this
>> at first because I thought it would delete the row and therefore move the
>> desired data up.  Once I found that it just deleted the contents of the
>> rows
>> I left it there but then I call shiftRows() to move the rows up.
>>
>> However after calling both of these methods the original row(s) still have
>> their old/prior alignment/formatting.
>>
>> In Excel when you delete and/or move rows you don't get this mixed
>> behavior.  How can I get the desired behavior of cleaning removing all of
>> the old and moving the new rows?
>>
>> Perhaps I'm doing something wrong but this seems like a bug in POI.  I
>> need
>> a workaround for today.
>>
>> Thanks much!
>>
>>
>> On Sat, Oct 31, 2009 at 7:40 AM, David Hoffer <dh...@gmail.com> wrote:
>>
>>  I have a new application using POI version 3.5-FINAL and I am seeing what
>>> appears to be a bug in POI.
>>>
>>> Everything is fine until I call shiftRows() on a sheet.  I.e.
>>>
>>> sheet.shiftRows(firstRow.getRowIndex(),
>>>               lastRow.getRowIndex(),
>>>               3 - firstRow.getRowIndex(),
>>>               true,
>>>               true);
>>>
>>> The problem is that after this call some of the cells in the row(s) are
>>> missing their data.  The cells had data before the move and now some are
>>> just plan empty!
>>>
>>> What I am doing here is moving a set of rows up by a few rows. (And I
>>> have
>>> previously cleared the rows I am moving into...perhaps I did not need
>>> to.)
>>> I immediately save the workbook after this, e.g.
>>>
>>> workbook.write(new FileOutputStream(tempFile));
>>>
>>>
>>> Is this a known issue?  How can I fix this?
>>>
>>> Just let me know if you need to see examples of the error.  In my case
>>> some
>>> cells in columns B & C are erased.
>>>
>>> Thanks!
>>>
>>>
>>>
>>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
> For additional commands, e-mail: dev-help@poi.apache.org
>
>

Re: 3.5-FINAL causes corrupt cells after shiftRows()

Posted by David Fisher <df...@jmlafferty.com>.
Try unmerging the cells on your target row first.

Sorry, I don't have more details to help you, but you seem to be under  
a serious deadline.

Regards,
Dave

On Oct 31, 2009, at 7:04 AM, David Hoffer wrote:

> I have more info on this issue.
>
> What is happening is that in the row that has the 'missing cells' the
> old/previous row had an alignment of 'Merge cells' for columns A, B,  
> C & D.
>
> Before I called shiftRows() I called sheet.removeRow(hssfRow).  I  
> did this
> at first because I thought it would delete the row and therefore  
> move the
> desired data up.  Once I found that it just deleted the contents of  
> the rows
> I left it there but then I call shiftRows() to move the rows up.
>
> However after calling both of these methods the original row(s)  
> still have
> their old/prior alignment/formatting.
>
> In Excel when you delete and/or move rows you don't get this mixed
> behavior.  How can I get the desired behavior of cleaning removing  
> all of
> the old and moving the new rows?
>
> Perhaps I'm doing something wrong but this seems like a bug in POI.   
> I need
> a workaround for today.
>
> Thanks much!
>
>
> On Sat, Oct 31, 2009 at 7:40 AM, David Hoffer <dh...@gmail.com>  
> wrote:
>
>> I have a new application using POI version 3.5-FINAL and I am  
>> seeing what
>> appears to be a bug in POI.
>>
>> Everything is fine until I call shiftRows() on a sheet.  I.e.
>>
>> sheet.shiftRows(firstRow.getRowIndex(),
>>                lastRow.getRowIndex(),
>>                3 - firstRow.getRowIndex(),
>>                true,
>>                true);
>>
>> The problem is that after this call some of the cells in the row(s)  
>> are
>> missing their data.  The cells had data before the move and now  
>> some are
>> just plan empty!
>>
>> What I am doing here is moving a set of rows up by a few rows. (And  
>> I have
>> previously cleared the rows I am moving into...perhaps I did not  
>> need to.)
>> I immediately save the workbook after this, e.g.
>>
>> workbook.write(new FileOutputStream(tempFile));
>>
>>
>> Is this a known issue?  How can I fix this?
>>
>> Just let me know if you need to see examples of the error.  In my  
>> case some
>> cells in columns B & C are erased.
>>
>> Thanks!
>>
>>
>>


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


Re: 3.5-FINAL causes corrupt cells after shiftRows()

Posted by David Fisher <df...@jmlafferty.com>.
Try unmerging the cells on your target row first.

Sorry, I don't have more details to help you, but you seem to be under  
a serious deadline.

Regards,
Dave

On Oct 31, 2009, at 7:04 AM, David Hoffer wrote:

> I have more info on this issue.
>
> What is happening is that in the row that has the 'missing cells' the
> old/previous row had an alignment of 'Merge cells' for columns A, B,  
> C & D.
>
> Before I called shiftRows() I called sheet.removeRow(hssfRow).  I  
> did this
> at first because I thought it would delete the row and therefore  
> move the
> desired data up.  Once I found that it just deleted the contents of  
> the rows
> I left it there but then I call shiftRows() to move the rows up.
>
> However after calling both of these methods the original row(s)  
> still have
> their old/prior alignment/formatting.
>
> In Excel when you delete and/or move rows you don't get this mixed
> behavior.  How can I get the desired behavior of cleaning removing  
> all of
> the old and moving the new rows?
>
> Perhaps I'm doing something wrong but this seems like a bug in POI.   
> I need
> a workaround for today.
>
> Thanks much!
>
>
> On Sat, Oct 31, 2009 at 7:40 AM, David Hoffer <dh...@gmail.com>  
> wrote:
>
>> I have a new application using POI version 3.5-FINAL and I am  
>> seeing what
>> appears to be a bug in POI.
>>
>> Everything is fine until I call shiftRows() on a sheet.  I.e.
>>
>> sheet.shiftRows(firstRow.getRowIndex(),
>>                lastRow.getRowIndex(),
>>                3 - firstRow.getRowIndex(),
>>                true,
>>                true);
>>
>> The problem is that after this call some of the cells in the row(s)  
>> are
>> missing their data.  The cells had data before the move and now  
>> some are
>> just plan empty!
>>
>> What I am doing here is moving a set of rows up by a few rows. (And  
>> I have
>> previously cleared the rows I am moving into...perhaps I did not  
>> need to.)
>> I immediately save the workbook after this, e.g.
>>
>> workbook.write(new FileOutputStream(tempFile));
>>
>>
>> Is this a known issue?  How can I fix this?
>>
>> Just let me know if you need to see examples of the error.  In my  
>> case some
>> cells in columns B & C are erased.
>>
>> Thanks!
>>
>>
>>


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


Re: 3.5-FINAL causes corrupt cells after shiftRows()

Posted by David Hoffer <dh...@gmail.com>.
I have more info on this issue.

What is happening is that in the row that has the 'missing cells' the
old/previous row had an alignment of 'Merge cells' for columns A, B, C & D.

Before I called shiftRows() I called sheet.removeRow(hssfRow).  I did this
at first because I thought it would delete the row and therefore move the
desired data up.  Once I found that it just deleted the contents of the rows
I left it there but then I call shiftRows() to move the rows up.

However after calling both of these methods the original row(s) still have
their old/prior alignment/formatting.

In Excel when you delete and/or move rows you don't get this mixed
behavior.  How can I get the desired behavior of cleaning removing all of
the old and moving the new rows?

Perhaps I'm doing something wrong but this seems like a bug in POI.  I need
a workaround for today.

Thanks much!


On Sat, Oct 31, 2009 at 7:40 AM, David Hoffer <dh...@gmail.com> wrote:

> I have a new application using POI version 3.5-FINAL and I am seeing what
> appears to be a bug in POI.
>
> Everything is fine until I call shiftRows() on a sheet.  I.e.
>
> sheet.shiftRows(firstRow.getRowIndex(),
>                 lastRow.getRowIndex(),
>                 3 - firstRow.getRowIndex(),
>                 true,
>                 true);
>
> The problem is that after this call some of the cells in the row(s) are
> missing their data.  The cells had data before the move and now some are
> just plan empty!
>
> What I am doing here is moving a set of rows up by a few rows. (And I have
> previously cleared the rows I am moving into...perhaps I did not need to.)
> I immediately save the workbook after this, e.g.
>
> workbook.write(new FileOutputStream(tempFile));
>
>
> Is this a known issue?  How can I fix this?
>
> Just let me know if you need to see examples of the error.  In my case some
> cells in columns B & C are erased.
>
> Thanks!
>
>
>

Re: 3.5-FINAL causes corrupt cells after shiftRows()

Posted by David Hoffer <dh...@gmail.com>.
I have more info on this issue.

What is happening is that in the row that has the 'missing cells' the
old/previous row had an alignment of 'Merge cells' for columns A, B, C & D.

Before I called shiftRows() I called sheet.removeRow(hssfRow).  I did this
at first because I thought it would delete the row and therefore move the
desired data up.  Once I found that it just deleted the contents of the rows
I left it there but then I call shiftRows() to move the rows up.

However after calling both of these methods the original row(s) still have
their old/prior alignment/formatting.

In Excel when you delete and/or move rows you don't get this mixed
behavior.  How can I get the desired behavior of cleaning removing all of
the old and moving the new rows?

Perhaps I'm doing something wrong but this seems like a bug in POI.  I need
a workaround for today.

Thanks much!


On Sat, Oct 31, 2009 at 7:40 AM, David Hoffer <dh...@gmail.com> wrote:

> I have a new application using POI version 3.5-FINAL and I am seeing what
> appears to be a bug in POI.
>
> Everything is fine until I call shiftRows() on a sheet.  I.e.
>
> sheet.shiftRows(firstRow.getRowIndex(),
>                 lastRow.getRowIndex(),
>                 3 - firstRow.getRowIndex(),
>                 true,
>                 true);
>
> The problem is that after this call some of the cells in the row(s) are
> missing their data.  The cells had data before the move and now some are
> just plan empty!
>
> What I am doing here is moving a set of rows up by a few rows. (And I have
> previously cleared the rows I am moving into...perhaps I did not need to.)
> I immediately save the workbook after this, e.g.
>
> workbook.write(new FileOutputStream(tempFile));
>
>
> Is this a known issue?  How can I fix this?
>
> Just let me know if you need to see examples of the error.  In my case some
> cells in columns B & C are erased.
>
> Thanks!
>
>
>