Commit 24a68b41 by 李承祥

提取数据时,二级列头无法绑定数据

parent 86a64175
...@@ -240,6 +240,13 @@ private bool WriteExcel(string newpath, string originalPath, List<PerSheet> shee ...@@ -240,6 +240,13 @@ private bool WriteExcel(string newpath, string originalPath, List<PerSheet> shee
var script = scriptList.First(t => sheet.SheetName.Contains(t.SheetName)); var script = scriptList.First(t => sheet.SheetName.Contains(t.SheetName));
if (!string.IsNullOrEmpty(script.ExecuteScript)) if (!string.IsNullOrEmpty(script.ExecuteScript))
{ {
var children = new List<PerHeader>();
foreach (var item in sheet.PerHeader?.Select(t => t.Children))
{
if (item != null)
children = children.Union(item).ToList();
}
var connection = ConnectionBuilder.Create(DatabaseType.SqlServer, hospitalConfig.DbSource, hospitalConfig.DbName, hospitalConfig.DbUser, hospitalConfig.DbPassword); var connection = ConnectionBuilder.Create(DatabaseType.SqlServer, hospitalConfig.DbSource, hospitalConfig.DbName, hospitalConfig.DbUser, hospitalConfig.DbPassword);
var dataList = perforExtractRepository.ExecuteScript(connection, script.ExecuteScript, null); var dataList = perforExtractRepository.ExecuteScript(connection, script.ExecuteScript, null);
//创建数据行 //创建数据行
...@@ -249,7 +256,8 @@ private bool WriteExcel(string newpath, string originalPath, List<PerSheet> shee ...@@ -249,7 +256,8 @@ private bool WriteExcel(string newpath, string originalPath, List<PerSheet> shee
//写入单元格 //写入单元格
foreach (var data in dataList.Where(t => t.RowNumber == pointRow)) foreach (var data in dataList.Where(t => t.RowNumber == pointRow))
{ {
var headInfo = sheet.PerHeader.FirstOrDefault(t => t.CellValue == data.ColumnName); var headInfo = sheet.PerHeader.FirstOrDefault(t => t.CellValue == data.ColumnName)
?? children?.FirstOrDefault(t => t.CellValue == data.ColumnName);
if (headInfo != null) if (headInfo != null)
{ {
importRow.CreateCell(headInfo.PointCell).SetCellValue(Verify(data.Value.ToString())); importRow.CreateCell(headInfo.PointCell).SetCellValue(Verify(data.Value.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