diff --git a/src/java/org/apache/poi/hssf/record/HeaderFooterBase.java b/src/java/org/apache/poi/hssf/record/HeaderFooterBase.java index 53d5f4692..d0e23c73b 100644 --- a/src/java/org/apache/poi/hssf/record/HeaderFooterBase.java +++ b/src/java/org/apache/poi/hssf/record/HeaderFooterBase.java @@ -36,6 +36,13 @@ public abstract class HeaderFooterBase extends StandardRecord { protected HeaderFooterBase(RecordInputStream in) { if (in.remaining() > 0) { int field_1_footer_len = in.readShort(); + //61287 -- if the footer_len == 0, there may not be a multibyte flag + if (field_1_footer_len == 0) { + field_3_text = ""; + if (in.remaining() == 0) { + return; + } + } field_2_hasMultibyte = in.readByte() != 0x00; if (field_2_hasMultibyte) { diff --git a/src/java/org/apache/poi/hssf/record/WriteProtectRecord.java b/src/java/org/apache/poi/hssf/record/WriteProtectRecord.java index 14afeedc3..e958adb5e 100644 --- a/src/java/org/apache/poi/hssf/record/WriteProtectRecord.java +++ b/src/java/org/apache/poi/hssf/record/WriteProtectRecord.java @@ -37,6 +37,9 @@ public final class WriteProtectRecord extends StandardRecord { */ public WriteProtectRecord(RecordInputStream in) { + if (in.remaining() == 2) { + in.readShort(); + } } public String toString() diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java index d4abaf59a..54b8f4a96 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java @@ -26,6 +26,7 @@ import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import javax.imageio.ImageIO; import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -43,8 +44,6 @@ import java.util.List; import java.util.Locale; import java.util.TimeZone; -import javax.imageio.ImageIO; - import org.apache.poi.EncryptedDocumentException; import org.apache.poi.hssf.HSSFITestDataProvider; import org.apache.poi.hssf.HSSFTestDataSamples; @@ -3096,4 +3095,14 @@ public final class TestBugs extends BaseTestBugzillaIssues { wb.getCreationHelper().createFormulaEvaluator().evaluateAll(); wb.close(); } + + @Test + public void test61287() throws IOException { + final Workbook wb = HSSFTestDataSamples.openSampleWorkbook("61287.xls"); + ExcelExtractor ex = new ExcelExtractor((HSSFWorkbook)wb); + String text = ex.getText(); + assertContains(text, "资产负债表"); + wb.close(); + } + } diff --git a/test-data/spreadsheet/61287.xls b/test-data/spreadsheet/61287.xls new file mode 100644 index 000000000..4d35295e3 Binary files /dev/null and b/test-data/spreadsheet/61287.xls differ