Data getting overwritten in excel using apache poi.. need to get appended in next row
Hai,
How to go to next row and print the data in excel using java apache poi.. instead of overwritting existing data..
below is the code i have written pls correct
private static void excelLog(int row, int col, String value)
{
HSSFRow myRow = mySheet.getRow(row);
if (myRow == null)
{
myRow = mySheet.createRow(row);
}
/*else
{
Iterator<Row> rowIterator = mySheet.iterator();
while(rowIterator.hasNext()) {
myRow = mySheet.createRow(row);
}*/
}
HSSFCell myCell = myRow.createCell(col);
myCell.setCellValue(value);
}
public void writeDataExcel(ArrayList<String> inpList) {
int numCol = 100;
int index = 0;
for (int i = 0; i < 100; i++) {
for (int j = 0; j < numCol; j++) {
if(index < inpList.size())
excelLog(i, j, inpList.get(index++));
}
}
Re: Data getting overwritten in excel using apache poi.. need to get appended in next
Please use [code] tags [/code] when posting code in order to retain the formatting.
That code doesn't look valid to me.
Looks like too many '}'.