Commit 52915361 by lcx

自定义抽取添加列头写入

parent 8939901e
...@@ -34,6 +34,8 @@ CustomExtractService customExtractService ...@@ -34,6 +34,8 @@ CustomExtractService customExtractService
public PerSheetPoint Point => new PerSheetPoint public PerSheetPoint Point => new PerSheetPoint
{ {
HeaderFirstRowNum = 1,
HeaderFirstCellNum = 6,
DataFirstRowNum = 2, DataFirstRowNum = 2,
DataFirstCellNum = 6, DataFirstCellNum = 6,
}; };
...@@ -50,6 +52,7 @@ public void WriteDataToCustom(IWorkbook workbook, per_allot allot, ExcelStyle st ...@@ -50,6 +52,7 @@ public void WriteDataToCustom(IWorkbook workbook, per_allot allot, ExcelStyle st
if (configs == null || !configs.Any()) throw new Exception("医院未配置绩效抽取信息"); if (configs == null || !configs.Any()) throw new Exception("医院未配置绩效抽取信息");
var parameters = customExtractService.GetParameters(allot); var parameters = customExtractService.GetParameters(allot);
var headerStyle = style.SetBgkColorAndFormat(style.GetCellStyle(), StyleType.列头);
var cellStyle = style.SetBgkColorAndFormat(style.GetCellStyle(), StyleType.数据); var cellStyle = style.SetBgkColorAndFormat(style.GetCellStyle(), StyleType.数据);
foreach (var module in modules) foreach (var module in modules)
...@@ -76,6 +79,20 @@ public void WriteDataToCustom(IWorkbook workbook, per_allot allot, ExcelStyle st ...@@ -76,6 +79,20 @@ public void WriteDataToCustom(IWorkbook workbook, per_allot allot, ExcelStyle st
if (dynamics == null || dynamics.Count() == 0) if (dynamics == null || dynamics.Count() == 0)
continue; continue;
var first = (IDictionary<string, object>)dynamics.ElementAt(0);
var header = sheet.GetOrCreate(Point.HeaderFirstRowNum.Value);
if (header != null)
{
var cellindex = Point.HeaderFirstCellNum.Value;
foreach (var item in first)
{
var cell = header.GetOrCreate(cellindex);
cell.SetCellOValue(item.Key);
cell.CellStyle = headerStyle;
cellindex++;
}
}
var rowindex = Point.DataFirstRowNum.Value; var rowindex = Point.DataFirstRowNum.Value;
for (int r = 0; r < dynamics.Count(); r++) for (int r = 0; r < dynamics.Count(); r++)
{ {
......
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