https://bz.apache.org/bugzilla/show_bug.cgi?id=64791

            Bug ID: 64791
           Summary: getWriteAccess() call in InternalWorkbook always
                    creates a new record (for in-memory workbooks)
           Product: POI
           Version: unspecified
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: HSSF
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: ---

The "getWriteAccess()" method in InternalWorkbook
(org.apache.poi.hssf.model.InternalWorkbook) checks if the "writeAccess" member
is non-null, and if not calls "createWriteAccess" and sets the "writeAccess"
member. 

However, "createWorkbook()" (that is, the in-memory version) just calls
"createWriteAccess" which does NOT set the "writeAccess" member, meaning that a
subsequent call to "getWriteAccess" creates a second record. This same paradigm
/ bug may apply to other records as well (I haven't checked).

Anyway, I think the best way to address this is to make this change to
"InternalWorkbook.createWorkbook()" (Apache POI 4.1.2 code):
@@ -336,7 +336,7 @@
          records.add(new InterfaceHdrRecord(CODEPAGE));
          records.add(createMMS());
          records.add(InterfaceEndRecord.instance);
-         records.add(createWriteAccess());
+         getWriteAccess();
          records.add(createCodepage());
          records.add(createDSF());
          records.add(createTabId());

which will correctly set "writeAccess" and still put the record in the correct
position in the BIFF stream.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to