0

I am using an excel template to write data into it using SXSSFWorkbook. My template contains 2 rows initially (one is for column name and one more). I want to overwrite the data of first rows on some conditions (if/else). I am using below line of code to achieve this

sheet.getRow(0).getCell(2).setCellValue("Editable");

but getting Null Pointer Exception. Please help.

Please refer the attached screenshot of my excel template

How come the above statement can return Null?

I read somewhere that you can not read excel using SXSSFWorkbook. If so please provide any alternate solution.

Note - I have to use SXSSFWorkbook as I have to write huge amount of data in sheet.

Thank you.

  • 1
    [`Sheet.getRow`](https://poi.apache.org/apidocs/org/apache/poi/ss/usermodel/Sheet.html#getRow-int-) and [`Row.getCell`](https://poi.apache.org/apidocs/org/apache/poi/ss/usermodel/Row.html#getCell-int-) might return `null` if the requested object (row or cell) is not defined. Take care of that! – Seelenvirtuose Sep 27 '17 at 06:48
  • Please show more code. Especially how you are creating the `SXSSFWorkbook`. – Axel Richter Sep 27 '17 at 07:49

0 Answers0