Commit 107eaf30 by lcx

Merge branch 'develop' of http://192.168.18.110:8880/zry/performance into develop

parents 3acd34e0 3bf7c507
......@@ -190,6 +190,7 @@ public string AllComputerViewReport(int allotId, List<dynamic> dynamics, string
string filepath = Path.Combine(dpath, $"{hospital.HosName}-{name}-{DateTime.Now:yyyyMMdd}");
FileHelper.DeleteFile(filepath);
string[] notSum = new string[] { "year", "month" };
using (FileStream fs = new FileStream(filepath, FileMode.OpenOrCreate))
using (ExcelPackage package = new ExcelPackage(fs))
{
......@@ -197,11 +198,12 @@ public string AllComputerViewReport(int allotId, List<dynamic> dynamics, string
if (dynamics != null && dynamics.Count() > 0)
{
worksheet.SetValue(1, 1, $"{allot.Year}{allot.Month}{hospital.HosName}医院 --- {name}");
var headers = ((IDictionary<string, object>)dynamics.ElementAt(0)).Keys;
for (int col = 0; col < headList.Count; col++)
{
worksheet.SetValue(1, col + 1, headList[col].Alias);
worksheet.SetValue(2, col + 1, headList[col].Alias);
}
for (int col = 0; col < headList.Count; col++)
{
......@@ -211,23 +213,35 @@ public string AllComputerViewReport(int allotId, List<dynamic> dynamics, string
var temp = (IDictionary<string, object>)data;
var value = temp[headList[col].Name];
worksheet.Cells[row + 2, col + 1].Value = value;
worksheet.Cells[row + 3, col + 1].Value = value;
}
if (col == 0)
worksheet.SetValue(dynamics.Count() + 2, col + 1, "合计");
else
else if (!notSum.Contains(headList[col].Name.ToLower()))
worksheet.Cells[dynamics.Count() + 2, col + 1].Formula = string.Format("SUM({0})", new ExcelAddress(2, col + 1, dynamics.Count() + 1, col + 1).Address);
}
}
worksheet.View.FreezePanes(2, 1);
for (int row = worksheet.Dimension.Start.Row; row <= worksheet.Dimension.End.Row; row++)
{
for (int col = worksheet.Dimension.Start.Column; col <= worksheet.Dimension.End.Column; col++)
#region 样式设置
for (int row = worksheet.Dimension.Start.Row; row <= worksheet.Dimension.End.Row; row++)
{
worksheet.Cells[row, col].Style.Border.BorderAround(ExcelBorderStyle.Thin);
worksheet.Cells[row, col].Style.Numberformat.Format = "#,##0.00";
worksheet.Row(row).Height = 20;
for (int col = worksheet.Dimension.Start.Column; col <= worksheet.Dimension.End.Column; col++)
{
worksheet.Cells[row, col].Style.Numberformat.Format = "#,##0.00";
worksheet.Cells[row, col].Style.Border.BorderAround(ExcelBorderStyle.Thin);
worksheet.Cells[row, col].Style.VerticalAlignment = ExcelVerticalAlignment.Center;
}
}
worksheet.Cells[1, 1, 1, headList.Count].Merge = true;
worksheet.Cells[1, 1, 1, headList.Count].Style.VerticalAlignment = ExcelVerticalAlignment.Center;
worksheet.Cells[1, 1, 1, headList.Count].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
worksheet.Cells[1, 1, 1, headList.Count].Style.Font.Bold = true;
worksheet.Cells[1, 1, 1, headList.Count].Style.Font.Size = 16;
worksheet.Row(1).Height = 24;
worksheet.Cells[2, 1, 2, headList.Count].Style.Font.Bold = true;
worksheet.View.FreezePanes(3, 1);
worksheet.Cells.AutoFitColumns();
#endregion
}
package.Save();
}
......
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