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.
2 Answers
Have a look at this example => https://metacpan.org/pod/Spreadsheet::WriteExcel::Examples#Example:-autofit.pl
-
3This is the correct answer. Autofit isn't part of the Excel file format so it can't be done automatically by Excel::Writer::XLSX. However, with a small bit of work it can be simulated by the technique shown in the linked example. – jmcnamara Oct 24 '13 at 11:14
You can't make the column to be resized to the longest entry automatically in advance. You have two other options though: After you have all your entries typed into rows, double click on the border (where there are A,B,C...column headings) between the column you want to adjust and the column that follows. This will resize your column to the longest entry. Another option is to click on the column heading to select that column (A, B, C..), then right click and select "Format Cell" from the drop down menu. In the options window that pops out select "Alignment" tab and click on "Wrap Text". This will adjust the row height to fit all of you text as you type.

- 583
- 5
- 12