I am using Excel::Writer::XLSX module to generate excel report, but I can not find the method about 'autofit', now the column width must be set in advance. So I'd like to know how to autofit the column width in sheet using Excel::Writer::XLSX module. Thanks.
Change the column width to automatically fit the contents (AutoFit) Select the column or columns that you want to change. On the Home tab, in the Cells group, click Format. Under Cell Size, click AutoFit Column Width.
As a general rule, you want the width of the columns a bit larger than the size of the longest string in the column. The with of 1 unit of the xlsxwriter columns is about equal to the width of one character. So, you can simulate autofit by setting each column to the max number of characters in that column.
Have a look at this example => https://metacpan.org/pod/Spreadsheet::WriteExcel::Examples#Example:-autofit.pl
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With