打印精灵,一款用于在网页中打印Office文件的软件,可以打印包括Word、PowerP oint、Excel、PDF、图片等文件。
详细信息请访问https://www.innben.com/print了解
npm:
npm install office-print --save
yarn:
yarn add office-print --save
const OfficePrint = require('office-print');
let fileUrl = 'your network excel url';
fetch(fileUrl).then(response => response.arrayBuffer()).then(arrayBuffer => {
let file = new File([arrayBuffer], filename);
const officePrint = new OfficePrint();
officePrint.print(file)
});
// script
<input type="file" id="input">
const OfficePrint = require('office-print');
const inputElement = document.getElementById("input");
inputElement.addEventListener("change", handleFiles, false);
function handleFiles() {
const fileList = this.files; /* 现在你可以处理文件列表 */
fileList.forEach(file => {
const officePrint = new OfficePrint();
officePrint.print(file)
});
}
// script
const OfficePrint = require('office-print');
let fileUrl = 'your local file system excel url';
const officePrint = new OfficePrint();
officePrint.printFile(fileUrl)