Wednesday, October 13, 2010

How to Format A Excle Column.

Summary : This Code Code Snippets Guide you to format EXCEL Column progrmaticaly. Here i am doing number formating

Follwing is the COde for formating the first Column of EXcel sheet. You Have to change the Column index of cell to format the required column

VB.NET

Dim Wb As Excel.Workbook =
Dim xWS As Excel.Worksheet
xWS = Wb.ActiveSheet
CType(xWS.Cells(1, 1), Excel.Range).EntireColumn.NumberFormat = "#,##0.00"

C#


Excel.Workbook wb = ;
Excel.Worksheet xWS;
xWS = wb.ActiveSheet;
Excel.Range rng = xWS.Cells[1,1] as Excel.Range;
rng.EntireColumn.NumberFormat = "#,##0.00";

No comments: