I want the cells I write to expand or contract so that all their content displays without manually adjusting the width of the cells.
I tried this:
_xlSheet = (MSExcel.Excel.Worksheet)_xlSheets.Item[1];
_xlSheet.Columns.AutoFit();
_xlSheet.Rows.AutoFit();
...but it does nothing.
It might be because I've already monkeyed with the columns by spanning them earlier, like so:
var rowRngMemberName = _xlSheet.Range[_xlSheet.Cells[1, 1], _xlSheet.Cells[1, 6]];
rowRngMemberName.Merge(Type.Missing);
rowRngMemberName.Font.Bold = true;
rowRngMemberName.Font.Italic = true;
rowRngMemberName.Font.Size = 20;
rowRngMemberName.Value2 = shortName;
Is this the problem? If so, how can I resolve it?
BTW, I am referencing Microsoft.Office.Interop.Excel
Identity = Microsoft.Office.Interop.Excel
Path = C:\Program Files (x86)\Microsoft Visual Studio 12.0\Visual Studio Tools for Office\PIA\Office15\Microsoft.Office.Interop.Excel.dll
(I realize this can differ for you, but it might provide useful info)
Version: v2.0.50727