Bug 30714

Summary: HSSFSheet.setRowSumsBelow is not working
Product: POI Reporter: mitia <yakimovich_dm>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED DUPLICATE    
Severity: normal CC: ak.apache
Priority: P3    
Version: 2.5-FINAL   
Target Milestone: ---   
Hardware: Other   
OS: All   

Description mitia 2004-08-17 20:05:14 UTC
If i change rowSumsBelow in false value, then in Excel for outline we have the 
same result as true value. And i found, that if i will change attribute 
alternativeExpression, then it will change view of outline(It seems for me, 
that you mix up this attributes)
Comment 1 Joachim Schmidtchen 2004-10-19 13:18:34 UTC
Seems to me that 'field_1_wsbool' and 'field_2_wsbool' are mixed. After 
replacement worked fine with me

WSBoolRecord::setRowSumsBelow

public void setRowSumsBelow(boolean below)
{
  field_2_wsbool = rowsumsbelow.setByteBoolean(field_2_wsbool, below);
}
Comment 2 Douglas Atique 2006-06-26 13:10:51 UTC
Indeed, the bytes in WSBoolRecord seem to have been mixed. My workaround for
this problem was to set the same bit in the other byte. Explaining, what I
wanted was to setRowSumsBelow to false. Well, rowSumsBelow corresponds (in the
source code <a
href="http://svn.apache.org/viewvc/jakarta/poi/tags/REL_2_5_1/src/java/org/apache/poi/hssf/record/WSBoolRecord.java?revision=353578&view=markup">here</a>
) to bit 0x40 of byte 1, but it doesn't work. However, if we set bit 0x40 of
byte 2 to false (which happens to be setAlternateExpression(false)) then we get
rowSumsBelow working correctly. Coming to a conclusion, if you want to
setRowSumsBelow to false, set instead alternateExpression and you will get what
you are looking for.
Comment 3 Petr Titera 2007-08-07 02:45:47 UTC
This bug still exists even in HEAD version. Will this fix it?

--- WSBoolRecord.java	(revision 563431)
+++ WSBoolRecord.java	(working copy)
@@ -93,9 +93,9 @@
     {
        byte data[] = in.readRemainder();
         field_1_wsbool =
-            data[ 1 ];   // backwards because theoretically this is one short field
+            data[ 0 ];   // backwards because theoretically this is one short field
         field_2_wsbool =
-            data[ 0 ];   // but it was easier to implement it this way to avoid
confusion
+            data[ 1 ];   // but it was easier to implement it this way to avoid
confusion
     }                             // because the dev kit shows the masks for it
as 2 byte fields
 
     // why?  Why ask why?  But don't drink bud dry as its a really
@@ -352,8 +352,8 @@
     {
         LittleEndian.putShort(data, 0 + offset, sid);
         LittleEndian.putShort(data, 2 + offset, ( short ) 0x2);
-        data[ 5 + offset ] = getWSBool1();
-        data[ 4 + offset ] = getWSBool2();
+        data[ 4 + offset ] = getWSBool1();
+        data[ 5 + offset ] = getWSBool2();
         return getRecordSize();
     }
 
Comment 4 Nick Burch 2007-08-07 03:57:21 UTC
Any chance you could upload some sort of unit test for this? Possibly two files,
identical except for the flag being set differently, and a little unit test that
detects the flag properly on the two, and can set the flag to get from one to
the other.

That way, when the patch is applied, we can be sure it's properly fixed, and
won't get broken again in the future.
Comment 5 Yegor Kozlov 2009-04-18 02:12:50 UTC
Fixed in r766273

Yegor

*** This bug has been marked as a duplicate of bug 46174 ***