javascript - 如何在 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();
});
}
解决方案
推荐阅读
- world-of-warcraft - 卡在“已连接”上
- python - 如何将数据框转换为 csv 并保存以返回它?
- json - 使用 Codable 解码这种 JSON
- javascript - React-Select v2 逗号分隔搜索
- c++ - C ++'getline'没有重载函数的实例与参数列表匹配
- nginx - 将 nginx 安装到 centos7 VPS 但 DNS 中断
- python - 使用 Asyncio 执行 HTTP 请求
- ruby-on-rails - has_one 关联未将方法添加到 belongs_to 类
- numpy - 从 CSV 值构造批处理 Numpy 数组的最佳方法?
- java - 具有平方距离的 2D 随机游走程序