Create an excel file using Selenium with Java

package Java;
import java.io.FileOutputStream;
import java.io.IOException;
import jxl.Workbook;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.WriteException;
import org.testng.annotations.Test;

public class CreateFile {
  @Test
  public void CreateEcelFile() throws IOException,  WriteException{
  FileOutputStream fos= new FileOutputStream("E:\\lib\\testexcel.xls"); // Change your system file path
  WritableWorkbook wb=Workbook.createWorkbook(fos);
  WritableSheet ws=wb.createSheet("Result", 0);
  
  Label un= new Label(0,0,"Username");
  Label ps = new Label (1,0,"Password");
  Label rsl = new Label(2,0,"Result");
  
  ws.addCell(un);
  ws.addCell(ps);
  ws.addCell(rsl);
  wb.write();
  wb.close();
  
  }
 }

Comments