首页 > 解决方案 > 如何在 Angular 2 中打印 Excel 文件?

问题描述

贝娄我附上了我的代码。

我正在尝试使用 angular 打印 excel 文件,而无需用户按 ctrl+P。我确实在下面的链接中找到了相关代码,我可以打开打印弹出窗口,但只有空白的白页,上面没有任何内容。提前感谢您的建议。

printListXcel() {
  this.listService.getListExcel(this.ListId).subscribe(data => {
  const blobData = new Blob([data], { 
type:'application/vnd.openxmlformatsofficedocument.spreadsheetml.sheet'});
   const blobUrl =  URL.createObjectURL(blobData);
   const iframexcel = document.createElement('iframe');
   iframexcel.style.display = 'none';
   iframexcel.src = blobUrl;
   document.body.appendChild(iframexcel);
   iframexcel.contentWindow.print();
});
}

如何在Angular 2中打印pdf

标签: javascriptangular

解决方案


推荐阅读