Strange behaviour with table dimensions when importing table from Excel

Posted by: pavloboiko on 9 October 2023, 7:11 pm EST

    • Post Options:
    • Link

    Posted 9 October 2023, 7:11 pm EST

    This issue is reproducible in SpreadJS Designer. To reproduce it you need to:

    1. Create some kind of a table in Desginer
    2. Export it to Excel
    3. Make some change in Excel, place your cursor at some cell beyond the content (visual table dimension) and only then press Save.
    4. Try to make import this file to Designer

    Actual behaviour:

    Table is imported with all the empty columns/rows on the way to the cell where cursor was placed

    Expected behaviour:

    Table is imported only to the points where the actual content is present

    How can I achieve this kind of behaviour?

  • Posted 10 October 2023, 6:18 pm EST - Updated 10 October 2023, 6:55 pm EST

    Hi,

    This is by design. when we import an Excel file spreadJS tries to calculate how columns /rows are used since you set the active to the very last column it takes as used cell and imports the rows till that.

    To workaround this you may use the getUsedRange just after you load the file and change the rowCunt and colCount. Please refer to the following code snippet and let me know if face any issues.

     let usedRangType = GC.Spread.Sheets.UsedRangeType.data|GC.Spread.Sheets.UsedRangeType.table | GC.Spread.Sheets.UsedRangeType.style
      let usedRange=  workbook.getActiveSheet().getUsedRange( usedRangType);
      worbook.setColumnCount(usedRange.colCount);
      worbook.setRowCount(usedRange.rowCount);

    Regards,

    Avinash

Need extra support?

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

Learn More

Forum Channels