office-print
v1.2.3
Published
一款用于在网页中打印Office文件的软件,可以打印包括Word、PowerPoint、Excel、PDF、图片等文件。
Downloads
12
Maintainers
Readme
office-print
打印精灵,一款用于在网页中打印Office文件的软件,可以打印包括Word、PowerP oint、Excel、PDF、图片等文件。
Table of Contents
详细信息请访问https://www.innben.com/print了解
Install
npm:
npm install office-print --save
yarn:
yarn add office-print --save
Usage
一、打印网络excel、Word、PowerPoint、PDF
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
二、打印本地电脑中的excel、Word、PowerPoint、PDF
<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
三、已知本地文件路径,直接打印本地电脑中的excel、Word、PowerPoint、PDF
const OfficePrint = require('office-print');
let fileUrl = 'your local file system excel url';
const officePrint = new OfficePrint();
officePrint.printFile(fileUrl)