selenium webdriver - How to create multiple excel files in Java -
i trying below code intended create 2 excel files @ @afterclass.
string strtablepathr2 = "--path--"; string filename2 = strtablepathr2 + "results-1" + functions.getdateandhour() + ".xls"; hssfworkbook wb = new hssfworkbook(); hssfsheet sheet = wb.createsheet("new sheet"); hssfrow row = sheet.createrow((int)0); row.createcell((int)0).setcellvalue("helloworld"); fileoutputstream fileout = new fileoutputstream(filename2); wb.write(fileout); fileout.flush(); fileout.close(); //---------------------------------------------- string filename3 = strtablepathr2 + "results-2" + commonfunctions.getdateandhour() + ".xls"; hssfworkbook wb1 = new hssfworkbook(); hssfsheet sheet1 = wb.createsheet("new sheet1"); hssfrow row1 = sheet1.createrow((int)0); row1.createcell((int)0).setcellvalue("helloworld1"); fileoutputstream fileout2 = new fileoutputstream(filename3); wb.write(fileout2); fileout2.flush(); fileout2.close();
the issue 2 similar excel sheets created same content of first excel sheet. according simple example, 2 excel sheets created namely, results-1 & results-2 cell value, "helloworld". ideally in second excel cell value should "helloworld1". please me out this.
thanks in advance.
there seems typing mistake:
string filename3 = strtablepathr2 + "results-2" + commonfunctions.getdateandhour() + ".xls"; hssfworkbook wb1 = new hssfworkbook(); hssfsheet sheet1 = **wb1**.createsheet("new sheet1"); hssfrow row1 = sheet1.createrow((int)0); row1.createcell((int)0).setcellvalue("helloworld1"); fileoutputstream fileout2 = new fileoutputstream(filename3); **wb1**.write(fileout2); fileout2.flush(); fileout2.close();
Comments
Post a Comment