I make more time on it so it is solution, may be help someone :
firt you get excel format by function
public static string GetExcelCellFormat(string cellFormat )
{
if (cellFormat.Contains("#"))
{
return "Number";
}
if (cellFormat.Contains("d"))
{
return "Date";
}
return "General";
}
and user fuction below tocheck is number ?
public static bool IsValidnumber(string number)
{
Regex regex = new Regex(@"^[-+]?[0-9]*\.?[0-9]+$");
return regex.IsMatch(number);
}
then you find in excel , if the value is number , you charge it to date string value by function
strdate = Convert.ToDateTime(rg.Value).ToString("dd/MM/yyyy");
detail like the example below:
public static cExcel.Worksheet GetworksheetObject(string FileName)
{
cExcel.Application ExcelObj = new cExcel.Application();
cExcel.Workbook theWorkbook = null;
string strPath = FileName;
theWorkbook = ExcelObj.Workbooks.Open(strPath);
cExcel.Sheets sheets = theWorkbook.Worksheets;
cExcel.Worksheet worksheet = (cExcel.Worksheet)sheets.get_Item(1);
cExcel.Range xlRange = worksheet.UsedRange;
foreach (var item in xlRange)
{
cExcel.Range rg = (cExcel.Range)item;
String format = GetExcelCellFormat(rg.NumberFormat.ToString());
if (format == "Date")
{
string strdate;
if (Utils.IsValidnumber(rg.Value2.ToString()))
{
strdate = Convert.ToDateTime(rg.Value).ToString("dd/MM/yyyy");
}
else
{
strdate = rg.Value.ToString();
}
rg.Value = strdate;
}
}
return worksheet;
}