Columns are not getting adjusted width after importing

Posted by: fahmed on 16 June 2020, 1:49 am EST

  • Posted 16 June 2020, 1:49 am EST - Updated 3 October 2022, 1:19 am EST

    Hi,

    I am working with SpreadJS for the last few months. I got an issue with column width when importing an external xlsx file. Before importing the xlsx file I did some manual adjustment like expanded few columns and merged few cells. See the following image

    And after importing it using “excelIO.open()” and loading it with the json data the expanded columns are not being shown. When I am uploading it to google drive or S3 server they are showing it with correct adjusted widths. But spreadJS is showing with default width of the columns and not showing the adjusted widths. Like the following image

    Then I used the method “autoFitColumn(col)” for all the columns. Like following

    
    var currentSheet;
    var colCount;
    var col;
    var index;
    for (index = 0; index < spread.getSheetCount(); index++) {
      currentSheet = spread.getSheet(index);
      colCount = currentSheet.getColumnCount();
      for (col = 0; col < colCount; col++) {
        currentSheet.autoFitColumn(col);
      }
    }
    
    

    But it’s collapsing the first column of the columns merged like the following

    Is there a way to achieve what I am trying here?

    Note: I am using the version 10.2.3.

    Ths sample xlsx file is in the zip.

    width_issue.xlsx.zip

    Thanks in advance

  • Posted 17 June 2020, 12:44 am EST

    Hi,

    We are able to replicate the issue at our end using the version 10.2.3 but this issue is already fixed in the SJS Version 11.2.1. We would recommend you to update to the latest build which is 13.1.3. The new version has many significant new features, bug fixes, and performance improvements compared to the older version.

    As a workaround, you may also try to use the setColumnWidth method to set the width of the column to the desired size.

    setColumnWidth: https://help.grapecity.com/spread/SpreadSheets10/webframe.html#JavascriptLibrary~GC.Spread.Sheets.Worksheet~setColumnWidth.html

    Regards:

  • Posted 17 June 2020, 3:17 am EST

    Thank you very much for your quick response. I think I have to upgrade the version as column width will be dynamic.

    Thanks

Need extra support?

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

Learn More

Forum Channels