代码拉取完成,页面将自动刷新
wasm-pack-template
A template for kick starting a Rust and WebAssembly project using wasm-pack.
Built with 🦀🕸 by The Rust and WebAssembly Working Group
📚 Read this template tutorial! 📚
This template is designed for compiling Rust libraries into WebAssembly and publishing the resulting package to NPM.
Be sure to check out other wasm-pack
tutorials online for other
templates and usages of wasm-pack
.
cargo generate
to Clone this TemplateLearn more about cargo generate
here.
cargo generate --git https://gitee.com/guoyucode/excel_read.git --name my-project
cd my-project
build
wasm-pack build --target web
Use js
1: copy pgk dir files to html dir
2: <input type="file" id="file" multiple="multiple" onchange="read()">
3:
<script>
function read() {
var file = document.getElementById('file').files[0]//获取文件流
/// file: 前端File对象
/// title_row: 标题在第几行 组合标题: [2,3]; 单行标题: [1]
/// rows_excluded: 排除多少行数据, 一行, 二行, 三行: [1,2,3];
/// excluded_keyword: 关键字排除: 在单元格中检测到该关键字读取终止
read_excel_file(file, [1], [], "合计").then(res => {
console.log("excel_json:", res);
}).catch(e => {
alert(e);
});
}
</script>
4:
<script type="module">
// 初始化wasm里的方法
import {default as wasm, greet, read_excel_file} from "./excel_read.js";
wasm().then((module) => {
window.read_excel_file = read_excel_file;
});
</script>
run
cd pkg
cargo install miniserve
miniserve --index index.html
wasm-bindgen
for communicating
between WebAssembly and JavaScript.console_error_panic_hook
for logging panic messages to the developer console.wee_alloc
, an allocator optimized
for small code size.此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。