我正在寻找一种将该格式转换为DD / MM / YYYY日期格式的方法
public WebServiceResponse ReadFile(string fileName, string inputFormat)
{
string filePath = Server.MapPath("~/upload/");
string filePath = Server.MapPath("~/upload/");
string strConnection =
string.Format(
"Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source={0}{1};"
+ "Extended Properties=\"Excel
12.0;HDR=NO;IMEX=1;ImportMixedTypes=Text;\"", filePath, fileName);
var jsonArray = new List<Hashtable>();
string.
using (var cnConnection = new OleDbConnection(strConnection))
{
cnConnection.Open();
try
{
var cmdSelectSections = new
OleDbCommand(string.Format("SELECT * FROM [{0}]", "Sheet1$"),
cnConnection);
OleDbDataReader drdSections =
cmdSelectSections.ExecuteReader();
// Import excel rows into XML files
if (drdSections != null)
{
while (drdSections.Read())
{
var record = new Hashtable();
for (int j = 0; j < drdSections.FieldCount; j++)
{
record.Add("Col" + j.ToString(CultureInfo.InvariantCulture),
drdSections[j]);
}
jsonArray.Add(record);
//}
}
}
}
finally
{
cnConnection.Close();
}
}
var coldef = new string[20];
var numberOfCols = jsonArray[0].Count;
var i = 0;
var result = new Hashtable
{
{"colDef", coldef},
{"data", jsonArray}
};
return WebServiceResponse.PassResponse(result);
}
答案 0 :(得分:0)
您可以尝试
var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
var date = epoch.AddMilliseconds(1453154400000).ToString("dd/MM/yy");
希望您能得到正确的时间