Column Width autofit functionality using perl

戏子无情 提交于 2019-12-31 03:20:07

问题


I have generated the excel sheet using set of csv files using perl script.In that i need to set width of the column as auto-fit.What 'm suppose to do i've got The way to do this in the module called OLE i don't know how to do this you please help me?


回答1:


There is no way to set a file's column to "AutoFit" because that is not a setting of the file. Excel calculates this and sets a column width at run-time.

One option is to calculate the "AutoFit" width yourself based on your data, and then set the column width to the value that you calculate. This discussion gives some workaround code that does that.

Another option is to use Win32::OLE to set the column to AutoFit. How to do this is not documented in the module itself; you would have to search around the Microsoft OLE documentation to find the appropriate command.

Update: This site appears to show how to use AutoFit with Win32::OLE.




回答2:


You could generate your Excel file with Excel::Writer::XLSX module, and adjust the column width with set_column method




回答3:


Have a look at the autofit.pl example here



来源:https://stackoverflow.com/questions/15681221/column-width-autofit-functionality-using-perl

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!