Column Width autofit functionality using perl

前端 未结 3 500
梦如初夏
梦如初夏 2021-01-22 21:06

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

3条回答
  •  悲&欢浪女
    2021-01-22 21:27

    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.

提交回复
热议问题