Commit 512e36b5 by guanzhenshan

调整excel字段解析方法,优化解析速度

parent 41e1b1a4
...@@ -191,21 +191,15 @@ namespace Bailun.DC.Web.Base ...@@ -191,21 +191,15 @@ namespace Bailun.DC.Web.Base
return string.Empty; return string.Empty;
switch (cell.CellType) switch (cell.CellType)
{ {
case CellType.String:
return cell.StringCellValue;
case CellType.Blank: case CellType.Blank:
return string.Empty; return string.Empty;
case CellType.Boolean:
return cell.BooleanCellValue.ToString();
case CellType.Error:
return cell.ErrorCellValue.ToString();
case CellType.Numeric: case CellType.Numeric:
short format = cell.CellStyle.DataFormat; short format = cell.CellStyle.DataFormat;
if (format == 14 || format == 31 || format == 57 || format == 58 || HSSFDateUtil.IsCellDateFormatted(cell)) return cell.DateCellValue.ToString("yyyy-MM-dd HH:mm:ss"); if (format == 14 || format == 31 || format == 57 || format == 58 || HSSFDateUtil.IsCellDateFormatted(cell)) return cell.DateCellValue.ToString("yyyy-MM-dd HH:mm:ss");
return cell.NumericCellValue.ToString(); return cell.NumericCellValue.ToString();
case CellType.Unknown:
default:
return cell.ToString();
case CellType.String:
return cell.StringCellValue;
case CellType.Formula: case CellType.Formula:
try try
{ {
...@@ -215,8 +209,23 @@ namespace Bailun.DC.Web.Base ...@@ -215,8 +209,23 @@ namespace Bailun.DC.Web.Base
} }
catch catch
{ {
return cell.NumericCellValue.ToString(); try
{
return cell.NumericCellValue.ToString();
}
catch (Exception ex)
{
return "0";
}
} }
case CellType.Boolean:
return cell.BooleanCellValue.ToString();
case CellType.Error:
return cell.ErrorCellValue.ToString();
case CellType.Unknown:
default:
return cell.ToString();
} }
} }
......
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