Commit f95437a6 by 泽锋 李

导入优化

parent 20b71dbb
...@@ -83,8 +83,12 @@ namespace AutoTurnOver.Utility ...@@ -83,8 +83,12 @@ namespace AutoTurnOver.Utility
int col = workSheet.Dimension.Columns; int col = workSheet.Dimension.Columns;
for (int j = 1; j <= col; j++) for (int j = 1; j <= col; j++)
{ {
if(workSheet.Cells[1, j] != null && workSheet.Cells[1, j].Value!=null)
{
table.Columns.Add(workSheet.Cells[1, j].Value.ToString()); table.Columns.Add(workSheet.Cells[1, j].Value.ToString());
} }
}
for (int i = 2; i <= row; i++) for (int i = 2; i <= row; i++)
{ {
DataRow data_row = table.NewRow(); DataRow data_row = table.NewRow();
...@@ -92,11 +96,31 @@ namespace AutoTurnOver.Utility ...@@ -92,11 +96,31 @@ namespace AutoTurnOver.Utility
{ {
try try
{ {
data_row[workSheet.Cells[1, j].Value.ToString()] = workSheet.Cells[i, j].Value == null ? "" : workSheet.Cells[i, j].Value.ToString(); var cell = workSheet.Cells[i, j];
if (workSheet.Cells[1, j] != null && workSheet.Cells[1, j].Value!=null)
{
if (workSheet.Cells[i, j] != null && workSheet.Cells[i, j].Value != null)
{
if (cell.Style.Numberformat.Format.IndexOf("yyyy") > -1 || (cell.Style.Numberformat.Format.IndexOf("月") > -1 && cell.Style.Numberformat.Format.IndexOf("日") > -1))
{
data_row[workSheet.Cells[1, j].Value.ToString()] = cell.GetValue<DateTime>();
} }
catch (Exception ex) else
{ {
data_row[workSheet.Cells[1, j].Value.ToString()] = cell.Value;
}
}
else
{
data_row[workSheet.Cells[1, j].Value.ToString()] = "";
}
}
}
catch (Exception ex)
{
throw; throw;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment