0

Could you explain me, I make excel file from datatable using npoi. Could I expand columns when file opens to header content lengths.

 using (FileStream fs = System.IO.File.Create(FileName))
        {
            workbook.Write(fs);
 }
Ronan Thibaudau
  • 3,413
  • 3
  • 29
  • 78
  • 1
    did you try `AutoSizeColumn` yet?. please check https://stackoverflow.com/a/6651803/7889129 and https://stackoverflow.com/a/3151841/7889129 – Maddy Apr 02 '18 at 13:01
  • @Maddy please post your comment as answer so OP (Julia) can mark as answer? If Julia has accepted the answer, so can mark this question as closed. Thanks. (I am not moderator, just a reminder from fellow developer.) – Just a HK developer Apr 10 '18 at 02:28

1 Answers1

1

please try AutoSizeColumn to set Autosize to all columns.

mySheet.AutoSizeColumn(columnIndex)

please check

“AutoSize” to Excel sheet column? (NPOI)

and

'autosize' in Excel documents created with NPOI?

Maddy
  • 771
  • 5
  • 14