Add Parameter to autofitColumns() for Aligning to Current or Widest Cell Width
The current implementation of the autofitColumns() function adjusts the column width based on the widest cell in the entire column. This behavior is designed to ensure visibility for all elements within that column. However, there is confusion because when executing the command ctx.workbook.worksheets.getActiveWorksheet().getRange("A2").format.autofitColumns();, users might expect the column width adjustment to target only the cell at "A2", rather than the entire column.
This misalignment in expectations is highlighted in discussions like GitHub issue #1017, revealing a need for clearer functionality. For instance, suppose a column contains a mix of short data entries and one excessively long string. In such cases, it's often more visually appealing and functionally practical to ignore the outlier when adjusting column width. Currently, autofitColumns() will expand to accommodate the longest entry, which can lead to disproportionate column widths that disrupt the layout of the spreadsheet. This scenario demonstrates the limitation of a one-size-fits-all approach, suggesting a need for more flexible width adjustment options that can cater to specific formatting.