Hi all...i'm having a problem in formatting columns in excel. For example i have column Name, Birth Date and Salary and i want to format it to string, date and numeric respectively. When i format the columns using the codes below, all columns format become numeric. Any advise @ reference i can refer to?
objField = (ADODB.Field)ob jFields.Current ;
objField = (ADODB.Field)ob jFields.Current ;
Code:
for (int n = 0; n < nFields; n++)
{
switch (objField.Type.ToString())
{
case "adVarWChar":
case "advarwchar":
{
break;
}
case "adDBTimeStamp":
case "addbtimestamp":
{
((Range)sheet1.Cells[1, n + 1]).EntireColumn.NumberFormat = "dd-mmm-yy";
break;
}
case "adNumeric":
case "adnumeric":
{
((Range)sheet1.Cells[1, n + 1]).EntireColumn.NumberFormat = "0.00";
break;
}
}
}
Comment