java - Apache POI library - writing new excel file and force browser to download it -


im trying write data new excel file , force browser download it. i'm using nashorn javascript engine.

what need set headers , somehow catch outputstream? have no clue how , therefor need help.

code:

var output = (function() {  var excel = {     init: function() {         this.cell = packages.org.apache.poi.ss.usermodel.cell;         this.row = packages.org.apache.poi.ss.usermodel.row;         this.sheet = packages.org.apache.poi.xssf.usermodel.xssfsheet;         this.workbook = packages.org.apache.poi.xssf.usermodel.xssfworkbook;          this.fileexception = packages.java.io.filenotfoundexception;         this.outputstream = packages.java.io.fileoutputstream;         this.ioexception = packages.java.io.ioexception;          this.createexcel();     },      createexcel: function() {       var workbook = new this.workbook();       var sheet = workbook.createsheet("excel example");        var row = sheet.createrow(1);       var cell = row.createcell(1);        cell.setcellvalue("test 1");       cell.setcellvalue("test 2");    try {     var outputstream = new this.outputstream("excel");     workbook.write(outputstream);     workbook.close();      // download      } catch (e) {         out.print(e);     }    } };  return {     excel: excel };  })();  output.excel.init(); 

thanks in advance.


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -