java - Null pointer exception with jexcel while writing -


i need append contents existing excel file using jexcel.

i trying following approach:

  1. read existing workbook

    workbook = workbook.getworkbook(new file(errorfilepath)); 
  2. create writable workbook exisitng workbook temp file

    if (!tempfile.exists()) {    tempfile.getparentfile().mkdirs();    tempfile.createnewfile(); } newcopy = workbook.createworkbook(tempfile, workbook); excelsheet = newcopy.getsheet(0); 
  3. write writable workbook(times writable cell format variable)

    label label; label = new label(column, row, stringdata, times); excelsheet .addcell(label); 
  4. close both exisitng , writable workbook->delete exisitng workbook in block -> rename temp file name existing(now deleted) workbook name

     {         if (null != newcopy) {             newcopy.write();             newcopy.close();         }         if (null != workbook) {             workbook.close();         }         if (null != errorfile && errorfile.exists()) {             errorfile.delete();         }         if (null != tempfile) {             tempfile.renameto(new file(errorfilepath));         }      } 

    the problem works fine first run(without redeploying). whenever change java code, , web application redeploys null pointer exception while closing newly created workbook(after writing).

i getting following stack trace(originating line newcopy.write())

   java.lang.nullpointerexception @ jxl.write.biff.cellvalue.getdata(cellvalue.java:259) @ jxl.write.biff.labelrecord.getdata(labelrecord.java:141) @ jxl.biff.writablerecorddata.getbytes(writablerecorddata.java:71) @ jxl.write.biff.file.write(file.java:147) @ jxl.write.biff.rowrecord.writecells(rowrecord.java:329) @ jxl.write.biff.sheetwriter.write(sheetwriter.java:479) @ jxl.write.biff.writablesheetimpl.write(writablesheetimpl.java:1514) @ jxl.write.biff.writableworkbookimpl.write(writableworkbookimpl.java:950) 

java version : 1.6

jexcel version : 2.6.10

windows 7

well, first suspicion is, in line:

label = new label(column, row, stringdata, times); 

you pass null argument(s).


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -