--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webdriver+...@googlegroups.com.
To post to this group, send email to webd...@googlegroups.com.
Visit this group at http://groups.google.com/group/webdriver?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
public void writePOI(String flag, String fieldname, String fvalue,
String desc) throws Exception {
try {
if (!isHeaderFileCreated) {
createHeadersInXLS();
}
HSSFWorkbook sampleWorkbook = null;
HSSFSheet sampleDataSheet = null;
FileInputStream fi = new FileInputStream(resultsFileName);
sampleWorkbook = new HSSFWorkbook(fi);
sampleDataSheet = sampleWorkbook.getSheet("Results");
// get the last row/UsedRange.Rows
int lastRow = sampleDataSheet.getLastRowNum();
if (lastRow > RESULTS_EXCEL_ROW) {
RESULTS_EXCEL_ROW = lastRow + 1;
}
HSSFRow dataRow = sampleDataSheet.createRow(RESULTS_EXCEL_ROW);
HSSFCell firstHeaderCell = dataRow.createCell(2);
firstHeaderCell.setCellValue(flag);
HSSFCell secondHeaderCell = dataRow.createCell(3);
// NEED TO ENTER PAGENAME INTHE BELOW LINE
secondHeaderCell.setCellValue("");
HSSFCell thirdHeaderCell = dataRow.createCell(4);
thirdHeaderCell.setCellValue(fieldname);
HSSFCell fourthHeaderCell = dataRow.createCell(5);
fourthHeaderCell.setCellValue(fvalue);
HSSFCell fifthHeaderCell = dataRow.createCell(6);
fifthHeaderCell.setCellValue(desc);
HSSFCellStyle style = sampleWorkbook.createCellStyle();
HSSFFont font = sampleWorkbook.createFont();
font.setFontName(HSSFFont.FONT_ARIAL);
font.setFontHeightInPoints((short) 10);
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
font.setColor(HSSFColor.BLACK.index);
style.setFont(font);
style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
style.setBorderTop(HSSFCellStyle.BORDER_THIN);
style.setBorderRight(HSSFCellStyle.BORDER_THIN);
style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
firstHeaderCell.setCellStyle(style);
secondHeaderCell.setCellStyle(style);
thirdHeaderCell.setCellStyle(style);
fourthHeaderCell.setCellStyle(style);
fifthHeaderCell.setCellStyle(style);
sampleDataSheet.autoSizeColumn((int) 1);
sampleDataSheet.autoSizeColumn((int) 2);
sampleDataSheet.autoSizeColumn((int) 3);
sampleDataSheet.autoSizeColumn((int) 4);
sampleDataSheet.autoSizeColumn((int) 5);
sampleDataSheet.autoSizeColumn((int) 6);
FileOutputStream fo = new FileOutputStream(resultsFileName);
sampleWorkbook.write(fo);
fo.flush();
fo.close();
RESULTS_EXCEL_ROW
+= 1;
} catch (Exception e) { System.out.println(e.toString());