This commit is contained in:
Celeste 2023-08-24 15:13:39 +08:00
commit a93b405ba6

View File

@ -475,7 +475,7 @@ namespace FrontendWebApi.ApiControllers
if (r.Count > 0)
{
string buildingName = r.Select(x => x.building_name).FirstOrDefault();
var sheet = workbook.CreateSheet($"{buildingName}電表報表");
var sheet = workbook.CreateSheet($"{buildingName} 電表報表");
int RowPosition = 0;
#region set cell
IRow row = sheet.CreateRow(RowPosition);
@ -493,7 +493,10 @@ namespace FrontendWebApi.ApiControllers
cell = row.CreateCell(i++);
cell.SetCellValue("設備");
cell.CellStyle = styleLine12;
cell = row.CreateCell(i++);
cell.SetCellValue("單位");
cell.CellStyle = styleLine12;
foreach (var rr in r.FirstOrDefault().rawData)
{
cell = row.CreateCell(i++);
@ -515,7 +518,7 @@ namespace FrontendWebApi.ApiControllers
foreach (var rr in r)
{
RowPosition += 1;
int k = 3;
int k = 4;
row = sheet.CreateRow(RowPosition);
for (int j = 0; j <= i; j++)
{
@ -524,16 +527,20 @@ namespace FrontendWebApi.ApiControllers
{
cell.SetCellValue(rr.building_name);
}
if (j == 1)
else if (j == 1)
{
cell.SetCellValue(rr.floor_tag);
}
if (j == 2)
else if (j == 2)
{
cell.SetCellValue(rr.device_full_name);
}
else if (j == 3)
{
cell.SetCellValue("kWh");
}
if (j == 3)
else if (j == 4)
{
foreach (var rrr in rr.rawData)
{
@ -543,16 +550,16 @@ namespace FrontendWebApi.ApiControllers
cell = row.CreateCell(j);
}
}
if (j == k)
{
cell.SetCellValue(rr.total);
}
if (j == k+1)
else if (j == k+1)
{
cell.SetCellValue(rr.price);
}
if (j == k+2)
else if (j == k+2)
{
cell.SetCellValue(rr.total_price);
}
@ -697,6 +704,9 @@ namespace FrontendWebApi.ApiControllers
cell = row.CreateCell(i++);
cell.SetCellValue("設備");
cell.CellStyle = styleLine12;
cell = row.CreateCell(i++);
cell.SetCellValue("單位");
cell.CellStyle = styleLine12;
foreach (var rr in rawDataTitle)
{
@ -736,7 +746,7 @@ namespace FrontendWebApi.ApiControllers
{
string compareDictKey = r.building_tag + r.floor_tag + r.device_serial_tag + r.device_number;
RowPosition += 1;
int k = 3;
int k = 4;
row = sheet.CreateRow(RowPosition);
for (int j = 0; j <= i; j++)
{
@ -745,16 +755,20 @@ namespace FrontendWebApi.ApiControllers
{
cell.SetCellValue(r.building_name);
}
if (j == 1)
else if (j == 1)
{
cell.SetCellValue(r.floor_tag);
}
if (j == 2)
else if (j == 2)
{
cell.SetCellValue(r.device_full_name);
}
else if (j == 3)
{
cell.SetCellValue("kWh");
}
if (j == 3)
else if (j == 4)
{
foreach (var rr in rawDataTitle)
{
@ -770,23 +784,23 @@ namespace FrontendWebApi.ApiControllers
{
cell.SetCellValue(r.total);
}
if (j == k + 1)
else if (j == k + 1)
{
cell.SetCellValue(compareDict.ContainsKey(compareDictKey) ? compareDict[compareDictKey][0] : "");
}
if (j == k + 2)
else if (j == k + 2)
{
cell.SetCellValue(r.price);
}
if (j == k + 3)
else if (j == k + 3)
{
cell.SetCellValue(compareDict.ContainsKey(compareDictKey) ? compareDict[compareDictKey][1] : "");
}
if (j == k + 4)
else if (j == k + 4)
{
cell.SetCellValue(r.total_price);
}
if (j == k + 5)
else if (j == k + 5)
{
cell.SetCellValue(compareDict.ContainsKey(compareDictKey) ? compareDict[compareDictKey][2] : "");
}