Get Filename of imported File (Designer Components)

Posted by: m.holland-moritz on 10 February 2022, 12:34 am EST

  • Posted 10 February 2022, 12:34 am EST

    Hey guys.

    Is there a way to get the filename of imported files? No matter which import is used?

    I am using the file import from the designer ribbon. Can i add some lines of code to this functions?

    Best regards

  • Replied 13 February 2022, 3:45 pm EST


    We are sorry but spreadJS does not provide the fileName information However you could override the importExcel_online method and write your own logic to import the file have total control on the file object. Please refer to the following code snippet and attached sample that explains the same.

    GC.Spread.Sheets.Designer.FileMenuHandler.importExcel_online = function(){
    let input = document.createElement('input');
    input.type = 'file';
    input.onchange = _ => {

    let files = Array.from(input.files);
    /*import the excel file*/
    var excelIo = new GC.Spread.Excel.IO();
    function (json) {
    var workbookObj = json;
    spread.fromJSON(workbookObj, {
    doNotRecalculateAfterLoad: true
    function (e) {
    /* process error*/



  • Replied 24 February 2022, 10:07 pm EST

    Hey Avinash,

    Thanks! this helps for Excel files, but i also would need it for every kind of file like the ssjson or csv.
    Is there somewhere a documentation about the FileMenuHandler or something i am missing? I can't find it on your page.

  • Replied 27 February 2022, 7:29 pm EST

    Hi Maik,

    Currently, there is no documentation available for FileMenuHandler as it is used internally by SpreadJS. However, you can follow the similar steps as defined above to get the file names for every kind of import.

    Please refer to the sample that I have created for you and let us know if you face any further issues:


  • Marked as Answer

    Replied 10 April 2022, 10:05 pm EST

    Hey Ankit,

    Thanks for the help! That worked totally fine for my case.

  • Replied 13 April 2022, 7:23 pm EST


    and sorry for reopen this post, but i investigated that i can't use the options, which are provided by the Designer Components.
    Is there a way to check which options are active in the excel import and which separator the client has set for the csv?

  • Replied 18 April 2022, 4:52 pm EST

    Hi Maik,

    Sorry for the delayed response. We have tested at our end and it seems to be working fine at our end. Some designer options might be unavailable if the sheet is protected and it depends on the protection options applied. Try unlocking the sheet to access the Designer Component Options.

    You can check if the sheet is protected using sheet.options.isProtected and the protection options using sheet.options.protectionOptions.allowDeleteRow and so on.

    Protect WorkSheet and Lock Cells:

    If the issue still persists for you, please share a working sample so that we can investigate it at our end and assist you accordingly.

  • Replied 1 May 2022, 8:10 pm EST

    Hey Ankit,

    i think you misunderstood me. The options i mean are in the attached pictures

    I can't really use them since for example in csv the code is setting it to a fixed one:

    spread.getSheet(spread.getActiveSheetIndex()).setCsv(0, 0, res, "\r", ",");

    And i am investigating, that i can load xlsx first and load a csv afterwards they get mixed instead of creating a completly new workbook.
    How can i fix that?

  • Replied 3 May 2022, 9:19 pm EST

    Hi Maik,

    You need to get the status of checkboxes selected and the input parameters from the corresponding elements, and then set it to fromJSON/setCsv methods when importing the files.

    I have also fixed the issue when loading csv files after xlsx file and vice versa. It will no longer get mixed.

    Please refer to the following sample that I have created for you:

    Please let us know if you need further assistance on this query? We would be happy to help you.

Need extra support?

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

Learn More

Forum Channels