Soft sail bulk export the report to excel

Because the project and business needs, and sometimes there will be a page n Zhang reports, so this time we need a key export function (to facilitate easy)

First, the project will certainly be reporting tool integrated soft sail, sail a variety of soft jar package and static resources (js, css), etc. can also be integrated into the project.

Directly on the code (there are two main methods)

function printReport(name, sex, age ){
 var params="";
 if(""!=name){
  params+=",NAME:"+name;
 }
 if(""!=sex){
  params+=",SEX:"+sex;
 }
 if(""!=age){
  params+=",AGE:"+age;
 }
 var items="{reportlet:zxt/test/test1.cpt"+params+"}" 
          +",{reportlet:zxt/test/test2.cpt"+params+"}";
 doExport(items);
}

function doExport(items){
     var form =$("<form>");   
    form.attr('style','display:none'); 
    form.attr('target', '');
    form.attr('method', 'post');
    form.attr('action',"${bmw}/ReportServer");
    var input1 = $('<input>');
    input1.attr('type', 'hidden');
    input1.attr('name', 'reportlets');
    input1.attr('value',FR.cjkEncode("("+items+")"));   
     var input2 = $('<input>');
    input2.attr('type', 'hidden');
    input2.attr('name', 'extype');
    input2.attr('value', 'simple');
    var input3 = $('<input>');
    input3.attr('type', 'hidden');
    input3.attr('name', 'format');
    input3.attr('value', 'excel');
    var input4 = $('<input>');
    input4.attr('type', 'hidden');
    input4.attr('name','__filename__');
    input4.attr('value', '报表批量导出'); 
    $('body').append(form);   
    form.append(input1);  
    form.append(input2);
    form.append(input3);
    form.append(input4);
    form.submit();
}

 

$ {Bmw} refers to the access path of the project, further FR.cjkEncode () statements using a soft sail carrying method, js files need to import two soft sail provided

${bmw}/ReportServer?op=emb&resource=finereport.js&inter=zh_CN&__fr_locale__=&__v__=2017.01.20.14.49.47.271

${bmw}/ReportServer?op=emb&resource=finereport.chart.js&__v__=2017.01.20.14.49.47.271

Then call printReport () method can be achieved to export multiple reports into an Excel file of multiple sheet.

 

Guess you like

Origin www.cnblogs.com/lovefaner/p/11890515.html