Summary: | [PATCH] Unable to open read-write excel file including forms | ||
---|---|---|---|
Product: | POI | Reporter: | Antoine Mottier <antoine.mottier> |
Component: | HSSF | Assignee: | POI Developers List <dev> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | jeyasri021291 |
Priority: | P3 | ||
Version: | 2.0-FINAL | ||
Target Milestone: | --- | ||
Hardware: | PC | ||
OS: | All | ||
Bug Depends on: | 27497 | ||
Bug Blocks: | 29802 | ||
Attachments: |
Excel basic file with a textbox
CVS diff -u against HEAD |
Description
Antoine Mottier
2004-04-05 11:57:33 UTC
Created attachment 11133 [details]
Excel basic file with a textbox
Use of 2.0-final version (see bug #27497) solve the problem I got this to work by making the following corrections to AbstractEscherHolderRecord.java (in package org.apache.poi.hssf.records). Replace the serialize() and getRecordSize() methods with the code below [CODE] public int serialize(int offset, byte[] data) { LittleEndian.putShort(data, 0 + offset, getSid()); LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4)); if (escherRecords.size() == 0 && rawData != null) { System.arraycopy( rawData, 0, data, offset + 4, rawData.length); } else { int pos = offset + 4; for ( Iterator iterator = escherRecords.iterator(); iterator.hasNext(); ) { EscherRecord r = (EscherRecord) iterator.next(); pos += r.serialize(pos, data, new NullEscherSerializationListener() ); } } return getRecordSize(); } /** * Size of record (including 4 byte header) */ public int getRecordSize() { if (escherRecords.size() == 0 && rawData != null) { return rawData.length + 4; } else { int size = 4; for ( Iterator iterator = escherRecords.iterator(); iterator.hasNext(); ) { EscherRecord r = (EscherRecord) iterator.next(); size += r.getRecordSize(); } return size; } } [/CODE] The problem is in serialization of the Escher records (MSODRAWING, MSODRAWINGGROUP, and MSODRAWINGSELECTION). Even though your spreadsheet contains no images, forms controls are positioned on the page using the Escher layer, so the new Escher code is involved. The new Escher code will not parse an the Escher records until you actually make a drawing. Until you use the ddf package, it just holds the data of each Escher record as raw bytes. But if you attempt to write these raw bytes back, there is a logic problem where the MSODRAWINGGROUP (and other) record is not reconstructed correctly -- namely, the required four byte BIFF record header is omitted. Created attachment 11955 [details]
CVS diff -u against HEAD
Resolved with many thanks to Michael. |