Apache POI getRow() returns null and .createRow fails
If you want to read or edit an exist row, you can firstly do it in xssf
type, and then create the sxssf
file base on the xssf
file.
The code is something like below...
XSSFWorkbook xssfWorkbook = new XSSFWorkbook(new FileInputStream(file));
//do the read and edit operation with xssf......
......
......
SXSSFWorkbook sXSSFbook = new SXSSFWorkbook(xssfWorkbook);
//do the write operation with sxssf......
......
......
See the documentation for the SXSSFWorkbook
constructor that takes the XSSFWorkbook
as param. You cannot override or access the initial rows in the template file. You are trying to overwrite an existing row and the API does not support this. Your exception message reflects this.
https://poi.apache.org/apidocs/org/apache/poi/xssf/streaming/SXSSFWorkbook.html#SXSSFWorkbook(org.apache.poi.xssf.usermodel.XSSFWorkbook)
For your use case, you may want to try http://jxls.sourceforge.net.