< 返回版块

郭宇 发表于 2021-04-08 21:18

Tags:wasm,excel, 浏览器,rust

A template for kick starting a Rust and WebAssembly project using wasm-pack.

Built with 🦀🕸 by The Rust and WebAssembly Working Group

About

📚 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.

🚴 Usage

🐑 Use cargo generate to Clone this Template

Learn more about cargo generate here.

cargo generate --git https://gitee.com/guoyucode/excel_read.git --name my-project
cd my-project

🛠️ Build with build

wasm-pack build --target web

🔬 Test in Browsers with 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]
        /// rows_excluded: 排除多少行数据, 一行, 二行, 三行: [1,2,3]
        /// excluded_keyword: 关键字排除: 在单元格中检测到该关键字读取终止
        read_excel_file(file, [5, 6, 7], [1, 2, 3, 4, 5, 6, 7, 8], "合计").then(res => {
            console.log("res", 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>

🔋 Batteries Included


Ext Link: https://gitee.com/guoyucode/excel_read

评论区

写评论

还没有评论

1 共 0 条评论, 1 页