openPDF(data, "DataSheet.pdf");//data is your bytearray intead of pdf try to ur file format
// ...
function openPDF(resData, fileName) {
var ieEDGE = navigator.userAgent.match(/Edge/g);
var ie = navigator.userAgent.match(/.NET/g); // IE 11+
var oldIE = navigator.userAgent.match(/MSIE/g);
var blob = new $window.Blob([resData], {
type: 'application/pdf'
});
if (ie || oldIE || ieEDGE) {
$window.navigator.msSaveBlob(blob, fileName);
} else {
var file = new Blob([resData], {
type: 'application/pdf'
});
var fileURL = URL.createObjectURL(file);
$window.open(fileURL);
}
}
2条答案
按热度按时间lzfw57am1#
您可以尝试在浏览器中读取数据,客户端使用
readAsArrayBuffer
more docs on mozilla website。但我不确定你是否能够在纯JS中解析.xlsx的内容,下面是一个库的例子:http://oss.sheetjs.com/js-xlsx/是什么
XLSX / XLSM / XLSB / XLS / SpreadsheetML(Excel Spreadsheet)/ ODS解析器和编写器
afdcj2ne2#