Default column width + auto-fit

Posted by: davide.vago on 26 May 2020, 2:22 am EST

    • Post Options:
    • Link

    Posted 26 May 2020, 2:22 am EST

    Good morning/afternoon,

    I’m writing in regards of a feature which seems to be missing, I’m currently trying to define a minimum column width in a worksheet instance and apply the autoFitColumn method across all the columns but it seems not to work as the defined column width takes over the autoFitColumn.

    Would it be possible to have a default minimum width and still having the auto fit functionality to guarantee the visibility of the cell contents when the values are longer than the defined width?

  • Posted 28 May 2020, 1:48 am EST

    Hi Davide,

    You may override the getAutoFitWidth method of the Base cell type to define minimum width for autofit. Please refer to the following code snippet:

    var _oldFn = GC.Spread.Sheets.CellTypes.Base.prototype.getAutoFitWidth;
    GC.Spread.Sheets.CellTypes.Base.prototype.getAutoFitWidth = function() {
      let minWidth = 100;
      let width = _oldFn.apply(this, arguments);
      return Math.max(minWidth, width);
    };
    

    Regards

    Sharad

  • Posted 27 March 2022, 8:20 pm EST

    Good Afternoon,

    I need some clarification regarding a feature which i am not able to find.

    i.e autoFitRow() or autoFitColumn() are not working when they are used with Formatters(General Formatter or Custom Formatter) . Could you let me know how to make both work or help me with other alternative?

  • Posted 30 March 2022, 5:10 pm EST

    Hi Rishmitha,

    You can refer to the following case that discusses the similar issues: https://www.grapecity.com/forums/spreadjs/autofitrowautofitcolumn-wi_1

    Please let us know if you need further assistance.

    Regards

    Ankit

  • Posted 9 August 2022, 8:45 pm EST

    Good Afternoon

    I wish to “replace All” cells whose value contains specific text (For Ex: “Eat”) with some other text like "Eating " even if is present inside a formula

    Like if a formula is (= [Eat]+ [Sleep]) then it should be converted into (=[Eating]+[sleep]) . How to do this in spreadjs?

  • Posted 11 August 2022, 11:22 pm EST

    Hi,

    For this, you need to implement your own search command that will do basic 2 steps first search the text for the cell and then replace it with and after that as a second step you need to search again but this time the formula and replace all the formula(using setFormula). For search, you may use the spreadJS API.

    I hope this clarifies the issue.

    search: https://www.grapecity.com/spreadjs/demos/features/workbook/search#demo_source_name

    Regards,

    Avinash

Need extra support?

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

Learn More

Forum Channels