How to set XLSX cell width with EPPlus?

前端 未结 5 1877
孤城傲影
孤城傲影 2021-01-31 00:47

Hello I have this code where i create an xlsx file and i need to pre set the width of the xlsx sheet cells. The actual problem is that when i open the excell i need to double c

5条回答
  •  别那么骄傲
    2021-01-31 01:28

    I find that setting the column widths after I have filled in all the data on the sheet works:

    ws.Column(1).Width = 50;
    

    There is also the autoFitColumns method but this ignores cells with formulas and wrapped text so it did not work for me.

    ws.Cells["A1:K20"].AutoFitColumns();
    

提交回复
热议问题