mirror of https://github.com/apache/poi.git
[bug-62181] try to handle file where shared string loading is happening twice
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1910759 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
cd5d0c3d07
commit
04442923f3
|
@ -412,7 +412,14 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Date1904Su
|
|||
if (packageReadOnly) {
|
||||
sharedStringSource = new SharedStringsTable();
|
||||
} else {
|
||||
sharedStringSource = (SharedStringsTable)createRelationship(XSSFRelation.SHARED_STRINGS, this.xssfFactory);
|
||||
List<PackagePart> matchingParts = getPackagePart().getPackage()
|
||||
.getPartsByContentType(XSSFRelation.SHARED_STRINGS.getContentType());
|
||||
if (matchingParts.isEmpty()) {
|
||||
sharedStringSource = (SharedStringsTable)
|
||||
createRelationship(XSSFRelation.SHARED_STRINGS, this.xssfFactory);
|
||||
} else {
|
||||
sharedStringSource = new SharedStringsTable(matchingParts.get(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -110,6 +110,7 @@ import org.apache.poi.xssf.XSSFITestDataProvider;
|
|||
import org.apache.poi.xssf.XSSFTestDataSamples;
|
||||
import org.apache.poi.xssf.eventusermodel.XSSFReader;
|
||||
import org.apache.poi.xssf.model.CalculationChain;
|
||||
import org.apache.poi.xssf.model.SharedStringsTable;
|
||||
import org.apache.poi.xssf.model.StylesTable;
|
||||
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
||||
import org.apache.poi.xssf.usermodel.extensions.XSSFCellFill;
|
||||
|
@ -3854,6 +3855,15 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBug62181() throws Exception {
|
||||
try (XSSFWorkbook wb = openSampleWorkbook("bug62181.xlsx")) {
|
||||
SharedStringsTable sst = wb.getSharedStringSource();
|
||||
assertNotNull(sst);
|
||||
assertEquals(0, sst.getCount());
|
||||
}
|
||||
}
|
||||
|
||||
private static void readByCommonsCompress(File temp_excel_poi) throws IOException {
|
||||
/* read by commons-compress*/
|
||||
try (ZipFile zipFile = new ZipFile(temp_excel_poi)) {
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue