-1

Currently, I am using

using Microsoft.Office.Core;
using Excel = Microsoft.Office.Interop.Excel;

to help me with the export to excel but how can I set it to auto-size the cell rather then the user do not have to resize then they can read all the words in excel

I have used

xlWorkSheet.UsedRange.Rows.AutoFit();
xlWorkSheet.UsedRange.Columns.AutoFit(); 

but they are not helpful enough

Current Problem

Mihir Dave
  • 3,954
  • 1
  • 12
  • 28
vulcan
  • 11
  • 6

1 Answers1

0

You have to define a range and then you can use

aRange.Columns.AutoFit();

See the Reference

or you can use

worksheet.Columns.AutoFit();

or

worksheet.Rows.AutoFit();
Mihir Dave
  • 3,954
  • 1
  • 12
  • 28