Skip to main content

Java POI API writing ongoing rows

No replies
rileydog
Offline
Joined: 2007-10-18
Points: 0

I'm putting the finishing touches on a time management application that uses the POI API to write user information to an excel spreadsheet. I need the application to be able to write ongoing rows to the spreadsheet using information users enter into a dialog box on their desktop. I have not been able to figure out a way to write continuous rows. Anyone have any thoughts? Thanks

here's some code:

HSSFRow row = null;
short rowNum = 1;

if (row == null) {
row = sheet.createRow((short)rowNum);
row.createCell((short)0).setCellValue(currDate);
row.createCell((short)1).setCellValue(str2 + "-" + str3);
if (usrInput == "HEDDS") {
row.createCell((short)4).setCellValue(minutes);
rowNum++;
}
if (usrInput == "WDIN") {
row.createCell((short)5).setCellValue(minutes);
rowNum++;
}
if (usrInput == "Meetings") {
row.createCell((short)6).setCellValue(minutes);
rowNum++;
}
if (usrInput == "NWHC") {
row.createCell((short)7).setCellValue(minutes);
rowNum++;
}
}
else {
if (row == null) {
row = sheet.createRow((short)rowNum);
row.createCell((short)0).setCellValue(currDate);
row.createCell((short)1).setCellValue(str2 + "-" + str3);
if (usrInput == "HEDDS") {
row.createCell((short)4).setCellValue(minutes);
rowNum++;
}
if (usrInput == "WDIN") {
row.createCell((short)5).setCellValue(minutes);
rowNum++;
}
if (usrInput == "Meetings") {
row.createCell((short)6).setCellValue(minutes);
rowNum++;
}
if (usrInput == "NWHC") {
row.createCell((short)7).setCellValue(minutes);
rowNum++;
}
}