Quantcast
Channel: Java Programming Forum - Learn Java Programming - Apache POI
Viewing all articles
Browse latest Browse all 120

Data getting overwritten in excel using apache poi.. need to get appended in next row

$
0
0
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++));
}
}

Viewing all articles
Browse latest Browse all 120

Trending Articles