xuri / excelize-wasm

A WebAssembly build of the Go Excelize library for reading and writing Microsoft Excel™ (XLAM / XLSM / XLSX / XLTM / XLTX) spreadsheets
https://xuri.me/excelize
BSD 3-Clause "New" or "Revised" License
190 stars 33 forks source link

how to read excel in browser? #17

Open jamninetyfive opened 11 months ago

jamninetyfive commented 11 months ago

Description

Steps to reproduce the issue: how to read excel in browser?

Describe the results you received:

Describe the results you expected:

Output of node -v:

Output of npm -v:

Output of go version:

(paste your output here)

Excelize version or commit ID:

(paste here)

Environment details (OS, Microsoft Excel™ version, Browser version, physical, etc.):

CapitanHeMo commented 11 months ago

Good afternoon @jamninetyfive .

Today I encountered the same problem as you.

Here is an example code for reading Excel file data from the browser, unfortunately the performance is low.

It takes 40 seconds to read a file weighing approximately 8 megabytes (190,000 lines * 6 columns).

Example code:

<html lang="en">
  <head>
    <script src="https://cdn.jsdelivr.net/npm/excelize-wasm@0.0.4/index.min.js"></script>
  </head>
  <body>
    <input type="file" id="convert-button" multiple />

    <script type="module" lang="js">
      document
        .getElementById("convert-button")
        .addEventListener("change", async function (e) {
          var excelize = await excelizeWASM.init(
            "https://cdn.jsdelivr.net/npm/excelize-wasm@0.0.4/excelize.wasm.gz"
          );
          let reader = new FileReader();
          reader.onload = function () {
            let byteArray = new Uint8Array(reader.result);
            let f = excelize.OpenReader(byteArray);
            let rows = f.GetRows("<Sheet name>");
            console.log(rows);
          };
          reader.readAsArrayBuffer(this.files[0]);
        });
    </script>
  </body>
</html>

This may not be the best use of the library, but I hope it helps you.

I would be glad for any corrections, good luck.

jamninetyfive commented 11 months ago

Thank you for your try and reply. I have gained something. I think the time-consuming part may be in buffer conversion, but thank you for trying. Can it read images? @CapitanHeMo

jamninetyfive commented 11 months ago

Thank you for your try and reply. I have gained something. I think the time-consuming part may be in buffer conversion, but thank you for trying. Can it read images? @CapitanHeMo

I've tried this, tried reading 4000 images, it took 4 hours, my chrome crashed, and I can't stop it, there doesn't seem to be a solution.