cancel
Showing results for 
Search instead for 
Did you mean: 

Null pointer exception while exporting more than 300 products to excel

0 Kudos
313

Dear Experts,

We are working on Hybris 1808 patch 3. In backoffice productcockpit I am trying to use "Export Excel" functionality.

We have 700 product attributes. When I am trying to select 300 or less attributes to export to excel, the functionality is working fine. But when I select more than 300 attributes I am getting Null Pointer Exception. This is coming from the file "DefaultExcelHeaderService.class". This is basically OOTB code that is in backoffice.jar. But to be able to put log statements and see I have decompiled the jar file and copied the mentioned java file to my custom extension.

Below is the code snippet. NPE is coming from line 12. In line 11 I have put log statement. Until 300 attributes line 11 is printing. But for 301 th attribute line 11 is printing null and line 12 is throwing NPE.

1 public void insertAttributeHeader(Sheet sheet, ExcelAttribute excelAttribute, int columnIndex)

2 {

3 String nameToDisplay = this.attributeNameFormatter.format(

4 DefaultExcelAttributeContext.ofExcelAttribute((ExcelAttributeDescriptorAttribute) excelAttribute));

5 Row row = sheet.getRow(this.headerRowIndex.getIndex());

6 Cell cell = row.createCell(row.getFirstCellNum() + columnIndex);

7 this.excelCellService.insertAttributeValue(cell, nameToDisplay);

8 Row patternRow = sheet.getRow(this.referencePatternRowIndex.getIndex());

9 LOG.info("***** columnIndex : " + columnIndex);

10 Cell patternCell = patternRow.getCell(row.getFirstCellNum() + columnIndex);

11 LOG.info("***** patternCell : " + patternCell);

12 patternCell.setCellFormula(patternCell.getCellFormula());

13 }

Output:

***** columnIndex: 299

***** patternCell : IFERROR(VLOOKUP(KN$1,HeaderPrompt!$B$1:$C$1048576,2,FALSE),"")

***** columnIndex : 300

***** patternCell : null

Not able to figure-out why error is coming only when we export more than 300 attributes. Why "patternCell" value is becoming null when columnIndex is null. Can someone please help me with this.

Thanks,

Kishore.

Accepted Solutions (0)

Answers (0)