title: Selenium Webdriver Duplicating ExcelSheet
body: <p>I tried to copy an excel sheet containing 7 colomns named Excel.xls sheet into ExcelCopy.xls , but Getting an Java Null Exception error at @After Test and  as am very new to this selenium coding please help me  !! </p>
  
  <pre><code> package TestNG;
  
  
  import java.io.FileInputStream;
  import java.io.FileOutputStream;
  
  import jxl.Sheet;
  import jxl.Workbook;
  import jxl.write.Label;
  import jxl.write.WritableSheet;
  import jxl.write.WritableWorkbook;
  
  import org.openqa.selenium.WebDriver;
  import org.openqa.selenium.support.ui.WebDriverWait;
  import org.testng.annotations.Test;
  import org.testng.annotations.BeforeTest;
  import org.testng.annotations.AfterTest;
  
  public class DuplicateExcelSheet {
      WebDriver driver;
      WebDriverWait wait;
  
      Workbook w;
      Sheet s;
      FileInputStream fi;
      FileOutputStream fo;
      WritableWorkbook ww;
      WritableSheet ws;
    @Test
    public void f() throws Exception{
      int colCount=s.getColumns();
      System.out.println(colCount);
      ww=Workbook.createWorkbook(fo, w);
      ws=ww.createSheet("Data", 0);
  
      for (int i = 0; i &lt; colCount; i++) 
      {
      String s1=s.getCell(i, 0).getContents();
       Label l=new Label(i,0,s1);
       ws.addCell(l);
      }
       }
  
    @BeforeTest
    public void beforeTest() throws Exception{
  
        fi=new FileInputStream("E:\\selenium\\Excel.xls");
          w=Workbook.getWorkbook(fi);
          s=w.getSheet(0);
            fo=new FileOutputStream("E:\\selenium\\ExcelCopy.xls");
        }
  
    @AfterTest
    public void afterTest() throws Exception{
         ww.write();
         w.close();
        fi.close();
        fo.close();
  
  
    }
  
  }
  </code></pre>