How to set “AutoSize” to Excel sheet column? (NPOI)

后端 未结 2 1093
孤城傲影
孤城傲影 2020-12-19 01:23

According to How can columns be set to 'autosize' in Excel documents created with NPOI? I did so:

foreach (DataColumn column in dataTable.Columns)
{
         


        
2条回答
  •  悲&欢浪女
    2020-12-19 02:12

    Just to add an extra bit to the answer by YellowFog. I found that I had to add all data to the sheet, then iterate through the columns, setting AutoSizeColumn(idx) for this to work correctly.

提交回复
热议问题