While working with Excel Interop
, i come up with an issue. Before Saving I Autofit columns of worksheet with the following code.
Excel.Worksheet curSheet = (Excel.Worksheet)wsEnumerator.Current;
curSheet.UsedRange.EntireColumn.AutoFit();
And it works fine for me. Then i encountered an issue with some specific Excel sheet. If i autofit it says AutoFit method of Range class failed
.
The excel sheet which cause the issue is available here
Now what i want to know is, whether there is some way to check if an excel sheet support Autofit or not. Something like
if(sheet.CanAutoFit())
curSheet.UsedRange.EntireColumn.AutoFit();
Any help would be appreciated.