I have a javascript
generate a PivotTable. Looking at Stack Overflow
I looked for methods to print a report from this table. In my case, when the user clicks Imprimir tabela
opens a page with the layout of the report table, my code makes the whole report correct, and so, but I do not know why this blessed undefined
appears: / p>
Partoftableimpressioncode:
functionrelatorio(){varconteudo;varlinhas;vardataFinalD2=newDate();varn=0;for(i=0;i<ContPosic;i++){//AdicionandoprimeiralinhavarRlservice=$('.Rlservice'+(i+1)).val();varRlsistema=$('.Rlsistema'+(i+1)).val();varTpf=$('.Tpf'+(i+1)).val();varProdut=$('.Produt'+(i+1)).val()varAntPraz=$('#AntPraz'+(i+1)+'option:selected').text();varQtdUteis=$('.QtdUteis'+(i+1)).text();varDtIniRes=$('.DtIniRes'+(i+1)).text();varQtdDiaCo=$('.QtdDiaCo'+(i+1)).text();varDtFinall=$('.DtFinall'+(i+1)).text();varQtdGames=$('.QtdGames'+(i+1)).text();varPfGamess=$('.PfGamess'+(i+1)).text();vardata;if(i==0){vardia=parseInt(DtIniRes.substring(0,2));varmes=parseInt(DtIniRes.substring(3,5));varano=parseInt(DtIniRes.substring((DtIniRes.length-4),(DtIniRes.length-0)));data=newDate();data.setDate(dia);data.setMonth((mes-1));data.setFullYear(ano);}if(n==1){data=dataFinalD2;}if(n>=1){data.setDate(data.getDate()+1);}vardatainicial=('0'+data.getDate()).slice(-2)+'/'+('0'+(data.getMonth()+1)).slice(-2)+'/'+data.getFullYear();//setandoprégame//datainicialdata.setDate(data.getDate()+21-1);vardatafinal=('0'+data.getDate()).slice(-2)+'/'+('0'+(data.getMonth()+1)).slice(-2)+'/'+data.getFullYear();linhas+='<tr>'+'<td>'+Rlsistema+'</td>'+'<td>Pré-game</td>'+'<td>'+datainicial+'</td>'+'<td>'+datafinal+'</td>'+'</tr>';//fordosgamesvarx=Math.round(QtdGames);for(j=0;j<x.toFixed(1);j++){vardatainicial1;vardatafinal1;//#######################################################if(i>=1){//calculosdadataparamaisde1item...dataFinalD2.setDate(dataFinalD2.getDate()+1);datainicial1=('0'+dataFinalD2.getDate()).slice(-2)+'/'+('0'+(dataFinalD2.getMonth()+1)).slice(-2)+'/'+dataFinalD2.getFullYear();//setandoprégamedataFinalD2.setDate(dataFinalD2.getDate()+14-1);datafinal1=('0'+dataFinalD2.getDate()).slice(-2)+'/'+('0'+(dataFinalD2.getMonth()+1)).slice(-2)+'/'+dataFinalD2.getFullYear();//#######################################################}else{//calculosdadataparaapenasumalinhadata.setDate(data.getDate()+1);datainicial1=('0'+data.getDate()).slice(-2)+'/'+('0'+(data.getMonth()+1)).slice(-2)+'/'+data.getFullYear();//setandoprégamedata.setDate(data.getDate()+14-1);datafinal1=('0'+data.getDate()).slice(-2)+'/'+('0'+(data.getMonth()+1)).slice(-2)+'/'+data.getFullYear();}//#######################################################linhas+='<tr>'+'<td></td>'+'<td>Game'+(j+1)+'</td>'+'<td>'+datainicial1+'</td>'+'<td>'+datafinal1+'</td>'+'</tr>'}//datafimdoprégamedata.setDate(data.getDate()+1);vardatainicial2=('0'+data.getDate()).slice(-2)+'/'+('0'+(data.getMonth()+1)).slice(-2)+'/'+data.getFullYear();//setandoprégamedata.setDate(data.getDate()+14-1);vardatafinal2=('0'+data.getDate()).slice(-2)+'/'+('0'+(data.getMonth()+1)).slice(-2)+'/'+data.getFullYear();if(j>=x){if(n==0){dataFinalD2=data;}n++;}linhas+='<tr>'+'<td></td>'+'<td>Post-Game</td>'+'<td>'+datainicial2+'</td>'+'<td>'+datafinal2+'</td>'+'</tr>';}//tabela+linhasqueforamadicionadasacimavartable='<table>'+'<thead>'+'<tr>'+'<td>ReleaseSistema</td>'+'<td>Iteração</td>'+'<td>DatadeInício</td>'+'<td>DatadeFim</td>'+'</tr>'+'</thead>'+'<tbody>'+linhas+'</tbody>'+'</table>';conteudo="<html> <head>"
+"<title>BANCO XXXXXXX- Relatório</title>"
+"<style> table {"
+"border-collapse: collapse;"
+"} "
+"table, th, td {"
+"border: 1px solid black; padding: 4px;"
+"} </style>"
+"</head>"
+"<body><header>"
+"</header><main>"
+''
+ table
+"</main></body><html>";
tela_impressao = window.open('about:blank');
tela_impressao.document.write(conteudo);
tela_impressao.window.print();
// tela_impressao.window.close();
}