如何运行: 需要发布在服务器 如Tomcat
实例图片:
需要展示的文件:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>excel预览</title>
<link rel="stylesheet" href="js-preview-lib/excel.css" />
<script src="js-preview-lib/excel.umd.js"></script>
</head>
<body>
<div id="excel" style="width: 100vw; height: 100vh"></div>
<script>
const myExcelPreviewer = jsPreviewExcel.init(document.getElementById('excel'));
myExcelPreviewer .preview('./文件名.xlsx').then(()=>{
console.log('预览完成');
}).catch(e=>{
console.log('预览失败', e);
})
</script>
</body>
</html>