tara kantheti
tara kantheti

Reputation: 1

While using apache poi to read an excel file the thread is getting stuck after parsing the sheets

I am using apache poi for excel read and write. I am able to use it for small size files properly. But now my input file size is >150mb with 200k+ records. Now when the use the same code for reading the file my thread just keeps on stepping and never returns the workbook to perform operations

final thread run debug log:

2022-11-29 17:04:33.541 DEBUG 33576 --- [ecutor-thread-8] o.a.p.o.o.PackageRelationshipCollection  : Parsing relationship: /xl/pivotCache/_rels/pivotCacheDefinition1.xml.rels
2022-11-29 17:04:33.604 DEBUG 33576 --- [ecutor-thread-8] o.a.p.o.o.PackageRelationshipCollection  : Parsing relationship: /xl/pivotTables/_rels/pivotTable1.xml.rels
2022-11-29 17:04:33.631 DEBUG 33576 --- [ecutor-thread-8] o.a.p.o.o.PackageRelationshipCollection  : Parsing relationship: /xl/_rels/workbook.xml.rels
2022-11-29 17:04:33.646 DEBUG 33576 --- [ecutor-thread-8] o.a.p.o.o.PackageRelationshipCollection  : Parsing relationship: /xl/worksheets/_rels/sheet1.xml.rels
2022-11-29 17:04:33.657 DEBUG 33576 --- [ecutor-thread-8] o.a.p.o.o.PackageRelationshipCollection  : Parsing relationship: /xl/worksheets/_rels/sheet2.xml.rels
2022-11-29 17:04:33.672 DEBUG 33576 --- [ecutor-thread-8] o.a.p.o.o.PackageRelationshipCollection  : Parsing relationship: /_rels/.rels
2022-11-29 17:04:47.661 DEBUG 33576 --- [ecutor-thread-8] org.apache.poi.ooxml.POIXMLFactory       : using default POIXMLDocumentPart for http://schemas.openxmlformats.org/officeDocument/2006/relationships/printerSettings
2022-11-29 17:04:47.666 DEBUG 33576 --- [ecutor-thread-8] org.apache.poi.ooxml.POIXMLFactory       : using default POIXMLDocumentPart for http://schemas.openxmlformats.org/officeDocument/2006/relationships/printerSettings

dependencies used:

<dependency>
   <groupId>org.apache.poi</groupId>
   <artifactId>poi</artifactId>
   <version>5.2.3</version>
</dependency>
<dependency>
   <groupId>org.apache.poi</groupId>
   <artifactId>poi-ooxml</artifactId>
   <version>5.2.3</version>
</dependency>
<dependency>
   <groupId>org.apache.poi</groupId>
   <artifactId>poi-ooxml-schemas</artifactId>
    <version>5.2.3</version>
</dependency>

solutions tried:

Workbook workbook = new XSSFWorkbook(file);

SXSSFWorkbook workbook = new SXSSFWorkbook(new XSSFWorkbook(file));

Workbook workbook = WorkbookFactory.create(f);

cant use this solution: because of it doesnt consider the cells which are blank hence having issue in reading columns and also because of some itss company policies

InputStream is = new FileInputStream(new File(uploadfilePath.toString()));
                Workbook workbook = StreamingReader.builder().rowCacheSize(100).bufferSize(4096).open(is)

can anyone please help me with some solutions for creating the workbook successfully

Upvotes: 0

Views: 419

Answers (0)

Related Questions