From ca33983388632012cc3f7e381e6375ca68f0b1c5 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Thu, 22 Jan 2015 11:45:40 +0000 Subject: [PATCH] Unit test from Isao Kadowaki from bug #57482 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1653814 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/xssf/usermodel/TestXSSFBugs.java | 58 +++++++++++++++++- test-data/spreadsheet/57482-OnlyNumeric.xlsx | Bin 0 -> 8601 bytes 2 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 test-data/spreadsheet/57482-OnlyNumeric.xlsx diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java index b6fe4433f..32f707a53 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java @@ -18,7 +18,13 @@ package org.apache.poi.xssf.usermodel; import static org.hamcrest.core.IsEqual.equalTo; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -38,6 +44,7 @@ import org.apache.poi.hssf.HSSFTestDataSamples; import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.openxml4j.opc.OPCPackage; +import org.apache.poi.openxml4j.opc.PackageAccess; import org.apache.poi.openxml4j.opc.PackagePart; import org.apache.poi.openxml4j.opc.PackagingURIHelper; import org.apache.poi.poifs.filesystem.NPOIFSFileSystem; @@ -47,7 +54,26 @@ import org.apache.poi.ss.formula.eval.ErrorEval; import org.apache.poi.ss.formula.eval.NumberEval; import org.apache.poi.ss.formula.eval.ValueEval; import org.apache.poi.ss.formula.functions.Function; -import org.apache.poi.ss.usermodel.*; +import org.apache.poi.ss.usermodel.BaseTestBugzillaIssues; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.ss.usermodel.CellValue; +import org.apache.poi.ss.usermodel.ClientAnchor; +import org.apache.poi.ss.usermodel.Comment; +import org.apache.poi.ss.usermodel.CreationHelper; +import org.apache.poi.ss.usermodel.DataFormatter; +import org.apache.poi.ss.usermodel.DateUtil; +import org.apache.poi.ss.usermodel.Drawing; +import org.apache.poi.ss.usermodel.Font; +import org.apache.poi.ss.usermodel.FormulaError; +import org.apache.poi.ss.usermodel.FormulaEvaluator; +import org.apache.poi.ss.usermodel.Hyperlink; +import org.apache.poi.ss.usermodel.IndexedColors; +import org.apache.poi.ss.usermodel.Name; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.usermodel.WorkbookFactory; import org.apache.poi.ss.util.AreaReference; import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.ss.util.CellReference; @@ -2052,4 +2078,32 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { wb.close(); } } + + /** + * A .xlsx file with no Shared Strings table should open fine + * in read-only mode + */ + @Ignore + @Test + public void bug57482() throws Exception { + for (PackageAccess access : new PackageAccess[] { + PackageAccess.READ_WRITE, PackageAccess.READ + }) { + File file = HSSFTestDataSamples.getSampleFile("57482-OnlyNumeric.xlsx"); + OPCPackage pkg = OPCPackage.open(file, access); + try { + XSSFWorkbook wb = new XSSFWorkbook(pkg); + assertNotNull(wb.getSharedStringSource()); + assertEquals(0, wb.getSharedStringSource().getCount()); + + DataFormatter fmt = new DataFormatter(); + XSSFSheet s = wb.getSheetAt(0); + assertEquals("1", fmt.formatCellValue(s.getRow(0).getCell(0))); + assertEquals("11", fmt.formatCellValue(s.getRow(0).getCell(1))); + assertEquals("5", fmt.formatCellValue(s.getRow(4).getCell(0))); + } finally { + pkg.close(); + } + } + } } diff --git a/test-data/spreadsheet/57482-OnlyNumeric.xlsx b/test-data/spreadsheet/57482-OnlyNumeric.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..fd1c4214db7d87d2408133f05ff77c41632e1a20 GIT binary patch literal 8601 zcmeHM1ys~+mnVh>3F+=0x&)-V1tcY;W5^*y1ZkvOkx)`WIz+k!qy&*18YHEq8QcNC zU6Aj6-S6z4vuDqqy>ll1XXd$c|M&i$d!PHe8p?<=iF zR9ze2t+gc019D8zJ5qe4p8n90=DlMV9~4#$L0wKiKB7E3#K8Hl;^W5dx8!aml`nD3(dC4_6S@_64oZ*S&X5mbX> zfK3P-ZR_PvR9OY1KKy7t;L(g_o2x(@z~F&!l5`#wm{SZw5Mz<0Npg{N494!NA z;Hi5Jt}KP)b{x$dW-2lZxq=y>3)lw**c!?xsB2%b@t0sXuZ{o*r}4M$xefb;p|q2u zo28?hiME%sCD@4Lkprkt+ep2Y3*Tp1m)(co5dOA#WFU$-WfI^FKDWUf%Lr0Q6!dg! zL*h0LRyciQp?!bNa+-JDzDKp4N>vcf`wE720;A{tNouwtY~wwP+)Y;cG7pou`lUV< znzuG~cY-Hv8&7 z4K0_o_3J28B+b^BGtx9Ts?c(MdDG2~=PKB=mKNWY&6PheA|W+0`-wzc%uLG~!#S^6 zo~HFEXz|&{XPTT~J@gr@Dl|2#DNR%6selP~ExZmLF<=YzM&}M%FhPJK%?7?I^*BSc z(wUQuo#n^nt>tyvMHdfad;>-Qxx_O$MeBw>uG$BR1Cdp#gaKC6uhUxjV@MocfEa^A zB5-dt5Vuxvbf10t_|@{tjy!N6^eIrFyEL zaA7DM@`^{TrB818B2SZfEJ%`%em0*m|FJ&4r+yL2`i?#CC|D>(5&slQ-0PtoP+E9ika^+W781E&&YV3@T5S&KjK&xpbrF|jl`UC(Lj98IT;!fC{ z!oE$76avqeOw0vjKJS;?7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