【发布时间】:2017-07-09 12:16:40
【问题描述】:
这是在我尝试实现时,我想将生成的数据导出到 html 表,但我认为样式已经消失,我如何打印整洁的表,而我的 html 表看起来像这样:
<button (click)="print()">print</button>
<div id="print-section">
<div class="row">
<div class="col-md-12">
<ba-card title="Result" baCardClass="with-scroll table-panel">
<!-- Hasil -->
<div class="table-responsive">
<table class="table">
<tr>
<td>No</td>
<td>Kode Claim</td>
<td>Paid/Not Paid</td>
<td>Kode Service</td>
<td>Tanggal</td>
<td>Nomor Nota</td>
<td>Kode Produk</td>
<td>Kerusakan</td>
<td>Biaya</td>
<td>Transport</td>
<td>Valid</td>
</tr>
<tr *ngFor="let claimReports of claimReport; let i=index" >
<td>{{i + 1}}</td>
<td>{{claimReports.KODE_CLAIM}}</td>
<td>{{claimReports.Paid}}</td>
<td colspan="11">
<tr *ngFor="let dt of claimReports['DETAILS']; let a=index">
<td>{{dt.Kode_Service}}</td>
<td>{{dt.Tanggal_Service | date: 'dd/MM/yyyy'}}</td>
<td>{{dt.Nomor_Nota}}</td>
<td>{{dt.Kode_Produk}}</td>
<td>{{dt.Kerusakan}}</td>
<td>{{dt.Biaya}}</td>
<td>{{dt.Transport}}</td>
<td>{{dt.Valid}}</td>
</tr>
</td>
</tr>
</table>
</div>
<!-- End Hasil -->
</ba-card>
</div>
</div>
</div>
这里是 app.component.ts :
print(): void {
let printContents, popupWin;
printContents = document.getElementById('print-section').innerHTML;
popupWin = window.open('', '_blank', 'top=0,left=0,height=100%,width=auto');
popupWin.document.open();
popupWin.document.write(`
<html>
<head>
<title>Print tab</title>
</head>
<body onload="window.print();window.close()">${printContents}</body>
</html>`
);
popupWin.document.close();
}
它好像没有格式化,我怎么能像 html 一样打印?或者至少我可以让桌子整洁,我不希望打印时显示 url
更新: 我用引导 css 更新我的代码,所以我的代码在我的 app.component.ts 中看起来像这样
print(): void {
let printContents, popupWin;
printContents = document.getElementById('print-section').innerHTML;
popupWin = window.open('', '_blank', 'top=0,left=0,height=100%,width=auto');
popupWin.document.open();
popupWin.document.write(`
<html>
<head>
<title>Print tab</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
</head>
<body onload="window.print();window.close()">${printContents}</body>
</html>`
);
popupWin.document.close();
}
第六列合并为第一、第二、第三和第四列,我怎样才能让它像我的桌子一样?
当我使用 firebug 检查 css 时,我看到我的 colspan 行是空的,这是使用 firebug 时的样子:
结果应该看起来像第一行,原始 HTML 就像我在上面发布的一样。为什么我的
【问题讨论】:
标签: javascript html css angular pdf