0

This is my Util function :

// Method to write into an XL
public static void writeXL(String fPath, String fSheet, String[][] xData) throws Exception{

        File outFile = new File(fPath);
        HSSFWorkbook wb = new HSSFWorkbook();
        HSSFSheet osheet = wb.createSheet(fSheet);
        int xR_TS = xData.length;
      //  System.out.println(xR_TS);
        int xC_TS = xData[0].length;
      //  System.out.println(xC_TS);
        for (int myrow = 0; myrow < xR_TS; myrow++) {
            HSSFRow row = osheet.createRow(myrow);
            for (int mycol = 0; mycol < xC_TS; mycol++) {
                HSSFCell cell = row.createCell(mycol);
                cell.setCellType(HSSFCell.CELL_TYPE_STRING);
                cell.setCellValue(xData[myrow][mycol]);
            }
            FileOutputStream fOut = new FileOutputStream(outFile);
            wb.write(fOut);
            fOut.flush();
            fOut.close();
        }
    }

While I am trying to write into this excel using the below command :

// i is the loop value

xlActualTot[i][5]=PayAmt; // where PayAmt is the value I am capturing from website and storing it in xlActualTot[0][5] (type is String[][])

Utils.writeXL("<filepath>","TestData",xlActualTot);

I am getting the below exception at "xlActualTot[0][5]=PayAmt" this line :
java.lang.NullPointerException

Can you all please suggest why I am getting that error?

Dave2e
  • 22,192
  • 18
  • 42
  • 50
  • Please take a minute to properly format all your code and error message. – JeffC Mar 02 '17 at 22:01
  • Possible duplicate of [What is a NullPointerException, and how do I fix it?](http://stackoverflow.com/questions/218384/what-is-a-nullpointerexception-and-how-do-i-fix-it) – JeffC Mar 02 '17 at 22:02

0 Answers0