Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to autofit column width using Excel::Writer::XLSX

Tags:

excel

perl

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.

like image 826
John Jiang Avatar asked Oct 24 '13 08:10

John Jiang


People also ask

How do you AutoFit column width in Excel?

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.

How do I AutoFit column width in Xlsxwriter?

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.


1 Answers

Have a look at this example => https://metacpan.org/pod/Spreadsheet::WriteExcel::Examples#Example:-autofit.pl

like image 158
mpapec Avatar answered Oct 14 '22 07:10

mpapec