View file list in browser and open via SpreadJS

Posted by: omen1288 on 9 June 2021, 6:30 pm EST

  • Posted 9 June 2021, 6:30 pm EST

    How can I open my folder in a browser to see a list of my xlsx files, and then when I click on any file, it will open through SpreadJS?
  • Replied 10 June 2021, 7:47 pm EST

    Hi,

    SpreadJS supports the ExcelIO module by which you could import/export excel files. Please refer to the following demo which demonstrates the same.

    >> How can I open my folder in a browser to see a list of my xlsx files,

    You need to use the input element with file type by which you could select any file from the system.

    excel Import Export Demo:
    https://www.grapecity.com/spreadjs/demos/features/workbook/excel-import-export/purejs

    Regards
    Avinash
  • Replied 13 June 2021, 8:09 am EST

    Hi, I do not need to upload files, I have a page that displays a list of files from a folder in the browser, by clicking on the file I want it open through SpreadJS

    Regards
    Alex

  • Replied 13 June 2021, 4:51 pm EST

    HI,

    For this, you need to get the file path and read the file as a blob. Please refer to the following code snippet and attached sample that demonstrates the same.


    function importWorkBook(file) {
    // here is excel IO API

    excelIO.open(
    file,
    function (json) {
    var workbookObj = json;
    console.log(JSON.stringify(json));
    spread.fromJSON(workbookObj, {
    doNotRecalculateAfterLoad: true
    });
    },
    function (e) {
    // process error
    alert(e.errorMessage);
    }
    );
    }

    document.getElementById("load").addEventListener("click", () => {
    let path = "../resources/template.xlsx";
    fetch(path)
    .then((res) => {
    return res.blob();
    })
    .then((res) => {
    importWorkBook(res);
    });
    });

    sample: https://codesandbox.io/s/spread-js-starter-forked-gyqpp?file=/src/index.js


    Regards
    Avinash

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels