RSS

Category Archives: Microsoft VSTO – Excel

MS VSTO – Excel related actions.

How do I change the format of an entire column?

To change the format of an entire column, you need to use the EntireColumn property to get the range of cells and
change the NumberFormat property of that specific range.

//Change the format for the entire column accordingly.
Microsoft.Office.Interop.Excel.Range range = activeCell.EntireColumn;
if (isChangeToGeneralFormat)
range.NumberFormat = "General"; //format as General.
else
range.NumberFormat = "@"; //format as Text;

Advertisements
 
Leave a comment

Posted by on March 7, 2011 in Microsoft VSTO - Excel