Skip to content
Advertisement

get all column records in excel instead of getting only last column record using apache poi

i am trying to get all column records in excel using apache poi. But i am getting only last column data in excel. Below is my code. In below code i am trying to create new row when it reaches specific number of columns. and in each row it as to put all column data.

JavaScript

above code is giving only last column data in each row.

Advertisement

Answer

In your code the call sheet.createRow(rowIndex) always creates a new empty row. So all formerly set cell values in that row get lost.

You are using CellUtil already. There is CellUtil.getRow what does the following:

Get a row from the spreadsheet, and create it if it doesn’t exist.

This not always creates a new empty row. Instead it tries to get the row at first and only creates a new row if the row does not exists already,

So do using:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement