Commit f95437a6 by 泽锋 李

导入优化

parent 20b71dbb
...@@ -83,7 +83,11 @@ namespace AutoTurnOver.Utility ...@@ -83,7 +83,11 @@ 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++)
{ {
table.Columns.Add(workSheet.Cells[1, j].Value.ToString()); if(workSheet.Cells[1, j] != null && workSheet.Cells[1, j].Value!=null)
{
table.Columns.Add(workSheet.Cells[1, j].Value.ToString());
}
} }
for (int i = 2; i <= row; i++) for (int i = 2; i <= row; i++)
{ {
...@@ -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>();
}
else
{
data_row[workSheet.Cells[1, j].Value.ToString()] = cell.Value;
}
}
else
{
data_row[workSheet.Cells[1, j].Value.ToString()] = "";
}
}
} }
catch (Exception ex) 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