電站報表-修改背景下載匯出綜合報表的格式

This commit is contained in:
wanling040@gmail.com 2022-08-01 14:52:00 +08:00
parent 52589c37c4
commit 1a16cb764a

View File

@ -1116,7 +1116,7 @@ namespace SolarPower.Controllers
{ {
"小時發電量(kWh)", "小時發電量(kWh)",
"小時發電量百分比(%)", "小時發電量百分比(%)",
"小時平均日照度(W/㎡)", "小時累積日照度(W/㎡)",
"小時平均模組溫度(°C)" "小時平均模組溫度(°C)"
}; };
if (Formhead.Result.Data.ShowMoney == 1) if (Formhead.Result.Data.ShowMoney == 1)
@ -1138,7 +1138,7 @@ namespace SolarPower.Controllers
#region body //RowPosition = 1 #region body //RowPosition = 1
RowPosition++; RowPosition++;
var thour = ""; var tpr = ""; var tkwh = ""; var kWhkwp = ""; var ntd = ""; var ntdone = ""; var GeneratingCapacity = ""; var thour = ""; var tpr = ""; var tkwh = ""; var kWhkwp = ""; var ntd = ""; var ntdone = ""; var GeneratingCapacity = ""; var AverageDailyProfit = "";
foreach (dynamic body in Formbody.Result.Data) foreach (dynamic body in Formbody.Result.Data)
{ {
@ -1157,6 +1157,7 @@ namespace SolarPower.Controllers
onemoney = 0; onemoney = 0;
} }
ntdone = Checknull(Math.Round(onemoney, 4).ToString()); ntdone = Checknull(Math.Round(onemoney, 4).ToString());
AverageDailyProfit = Checknull(Math.Round((Convert.ToDouble(ntd) / Convert.ToDouble(GeneratingCapacity)), 2).ToString());
row = sheet.CreateRow(RowPosition); row = sheet.CreateRow(RowPosition);
cell = row.CreateCell(index); cell = row.CreateCell(index);
@ -1215,7 +1216,7 @@ namespace SolarPower.Controllers
index = 0; index = 0;
row = sheet.CreateRow(RowPosition); row = sheet.CreateRow(RowPosition);
cell = row.CreateCell(index); cell = row.CreateCell(index);
cell.SetCellValue("有效發電小時:"); cell.SetCellValue("日均發電度數:");
cell.CellStyle = styleLine12; cell.CellStyle = styleLine12;
cell = row.CreateCell(1); cell = row.CreateCell(1);
cell.SetCellValue(!string.IsNullOrEmpty(kWhkwp) ? Convert.ToDouble(kWhkwp) : 0); cell.SetCellValue(!string.IsNullOrEmpty(kWhkwp) ? Convert.ToDouble(kWhkwp) : 0);
@ -1274,6 +1275,16 @@ namespace SolarPower.Controllers
cell = row.CreateCell(1); cell = row.CreateCell(1);
cell.SetCellValue(!string.IsNullOrEmpty(ntdone) ? Convert.ToDouble(ntdone) : 0); cell.SetCellValue(!string.IsNullOrEmpty(ntdone) ? Convert.ToDouble(ntdone) : 0);
cell.CellStyle = styleLine12; cell.CellStyle = styleLine12;
RowPosition++;
index = 0;
row = sheet.CreateRow(RowPosition);
cell = row.CreateCell(index);
cell.SetCellValue("日均獲利(NTD):");
cell.CellStyle = styleLine12;
cell = row.CreateCell(1);
cell.SetCellValue(!string.IsNullOrEmpty(AverageDailyProfit) ? Convert.ToDouble(AverageDailyProfit) : 0);
cell.CellStyle = styleLine12;
} }
@ -1404,7 +1415,7 @@ namespace SolarPower.Controllers
//cell.CellStyle = styleLine12; //cell.CellStyle = styleLine12;
//index++; //index++;
cell = row.CreateCell(index); cell = row.CreateCell(index);
cell.SetCellValue("有效發電小時(日)"); cell.SetCellValue("日均發電度數(日)");
cell.CellStyle = styleLine12; cell.CellStyle = styleLine12;
index++; index++;
cell = row.CreateCell(index); cell = row.CreateCell(index);
@ -1434,6 +1445,10 @@ namespace SolarPower.Controllers
cell.SetCellValue("月售電單價(NTD)"); cell.SetCellValue("月售電單價(NTD)");
cell.CellStyle = styleLine12; cell.CellStyle = styleLine12;
index++; index++;
cell = row.CreateCell(index);
cell.SetCellValue("日均獲利(NTD)");
cell.CellStyle = styleLine12;
index++;
} }
cell = row.CreateCell(index); cell = row.CreateCell(index);
cell.SetCellValue("月售電天數"); cell.SetCellValue("月售電天數");
@ -1480,6 +1495,10 @@ namespace SolarPower.Controllers
cell.SetCellValue(Math.Round(Convert.ToDouble(monthmoneyone) / Useday, 4)); cell.SetCellValue(Math.Round(Convert.ToDouble(monthmoneyone) / Useday, 4));
cell.CellStyle = styleLine12; cell.CellStyle = styleLine12;
index++; index++;
cell = row.CreateCell(index);
cell.SetCellValue(Math.Round(Convert.ToDouble(monthmoney) / Convert.ToDouble(monthGeneratingCapacity) / Useday, 2));
cell.CellStyle = styleLine12;
index++;
} }
cell = row.CreateCell(index); cell = row.CreateCell(index);
cell.SetCellValue(Useday); cell.SetCellValue(Useday);
@ -1682,7 +1701,6 @@ namespace SolarPower.Controllers
index++; index++;
cell = row.CreateCell(index); cell = row.CreateCell(index);
//cell.SetCellValue(form.PowerstationType);
switch (form.PowerstationType) switch (form.PowerstationType)
{ {
case 0: case 0:
@ -2072,6 +2090,7 @@ namespace SolarPower.Controllers
ICell cell; ICell cell;
double kwhkwp = 0; double kwhkwp = 0;
double kwp = 0; double kwp = 0;
double totalGeneratingCapacity = 0;
CellRangeAddress region; CellRangeAddress region;
List<CityArray> cityArrays = new List<CityArray>(); List<CityArray> cityArrays = new List<CityArray>();
foreach (var form in Formbody.Result.Data) foreach (var form in Formbody.Result.Data)
@ -2089,12 +2108,43 @@ namespace SolarPower.Controllers
index++; index++;
cell = row.CreateCell(index); cell = row.CreateCell(index);
cell.SetCellValue(Math.Round(form.Kwh, 2)); switch (form.PowerstationType)
{
case 0:
cell.SetCellValue("自建躉售");
break;
case 1:
cell.SetCellValue("租建躉售");
break;
case 2:
cell.SetCellValue("自發自用");
break;
}
cell.CellStyle = styleLine12; cell.CellStyle = styleLine12;
index++; index++;
cell = row.CreateCell(index); cell = row.CreateCell(index);
cell.SetCellValue(Math.Round(form.AvgKWHKWP, 2)); cell.SetCellValue(form.ElectricityMeterAt);
cell.CellStyle = styleLine12;
index++;
cell = row.CreateCell(index);
cell.SetCellValue(Math.Round(form.PowerRate, 2));
cell.CellStyle = styleLine12;
index++;
cell = row.CreateCell(index);
cell.SetCellValue(Math.Round(form.TodayMoney / form.GeneratingCapacity / form.Days, 2));//日均獲利
cell.CellStyle = styleLine12;
index++;
cell = row.CreateCell(index);
cell.SetCellValue(Math.Round(form.AvgKWHKWP, 2));//日均發電度數
cell.CellStyle = styleLine12;
index++;
cell = row.CreateCell(index);
cell.SetCellValue(Math.Round(form.Kwh, 2));//發電量
cell.CellStyle = styleLine12; cell.CellStyle = styleLine12;
//index++; //index++;
@ -2148,6 +2198,7 @@ namespace SolarPower.Controllers
kwp += form.Kwh; kwp += form.Kwh;
kwhkwp += form.AvgKWHKWP; kwhkwp += form.AvgKWHKWP;
totalGeneratingCapacity += form.GeneratingCapacity;
RowPosition++; RowPosition++;
CityArray cityinfo = new CityArray CityArray cityinfo = new CityArray
{ {
@ -2155,7 +2206,8 @@ namespace SolarPower.Controllers
Count = 1, Count = 1,
Kwh = form.Kwh, Kwh = form.Kwh,
SolarHour = form.SolarHour, SolarHour = form.SolarHour,
Kwhkwp = form.AvgKWHKWP Kwhkwp = form.AvgKWHKWP,
GeneratingCapacity = form.GeneratingCapacity
}; };
if (cityArrays.Where(a => a.City == form.CityName).Count() > 0) if (cityArrays.Where(a => a.City == form.CityName).Count() > 0)
{ {
@ -2164,6 +2216,7 @@ namespace SolarPower.Controllers
city.Kwh += cityinfo.Kwh; city.Kwh += cityinfo.Kwh;
city.SolarHour += cityinfo.SolarHour; city.SolarHour += cityinfo.SolarHour;
city.Kwhkwp += cityinfo.Kwhkwp; city.Kwhkwp += cityinfo.Kwhkwp;
city.GeneratingCapacity += cityinfo.GeneratingCapacity;
} }
else else
{ {
@ -2180,9 +2233,13 @@ namespace SolarPower.Controllers
{ {
"區域", "區域",
"電站名稱", "電站名稱",
"電站類型",
"掛錶日期",
"躉售費率",
"每kw日均獲利",
"日均發電度數",
"發電量", "發電量",
"有效發電小時", //"平均日照",
"平均日照",
"PR" "PR"
}; };
if (Formhead.Result.Data.ShowMoney == 1) if (Formhead.Result.Data.ShowMoney == 1)
@ -2219,7 +2276,17 @@ namespace SolarPower.Controllers
index++; index++;
cell = row.CreateCell(index); cell = row.CreateCell(index);
cell.SetCellValue(Math.Round((cityArray.Kwh / cityArray.Count), 2)); cell.SetCellValue(Math.Round(cityArray.GeneratingCapacity, 2));
cell.CellStyle = styleLine12;
region = new CellRangeAddress(cityRowPosition, cityRowPosition, index, index + 1);
sheet.AddMergedRegion(region);
index++;
cell = row.CreateCell(index);
cell.CellStyle = styleLine12;
index++;
cell = row.CreateCell(index);
cell.SetCellValue(Math.Round(cityArray.Kwh, 3));
cell.CellStyle = styleLine12; cell.CellStyle = styleLine12;
region = new CellRangeAddress(cityRowPosition, cityRowPosition, index, index + 1); region = new CellRangeAddress(cityRowPosition, cityRowPosition, index, index + 1);
sheet.AddMergedRegion(region); sheet.AddMergedRegion(region);
@ -2230,7 +2297,7 @@ namespace SolarPower.Controllers
index++; index++;
cell = row.CreateCell(index); cell = row.CreateCell(index);
cell.SetCellValue(Math.Round((cityArray.Kwhkwp / cityArray.Count), 2)); cell.SetCellValue(Math.Round((cityArray.Kwh / cityArray.GeneratingCapacity), 2));
cell.CellStyle = styleLine12; cell.CellStyle = styleLine12;
region = new CellRangeAddress(cityRowPosition, cityRowPosition, index, index + 1); region = new CellRangeAddress(cityRowPosition, cityRowPosition, index, index + 1);
sheet.AddMergedRegion(region); sheet.AddMergedRegion(region);
@ -2254,7 +2321,7 @@ namespace SolarPower.Controllers
index++; index++;
cell = row.CreateCell(index); cell = row.CreateCell(index);
cell.SetCellValue("平均發電量(kWp)"); cell.SetCellValue("裝置容量");
cell.CellStyle = styleLine12; cell.CellStyle = styleLine12;
region = new CellRangeAddress(RowPosition, RowPosition, index, index + 1); region = new CellRangeAddress(RowPosition, RowPosition, index, index + 1);
sheet.AddMergedRegion(region); sheet.AddMergedRegion(region);
@ -2264,7 +2331,17 @@ namespace SolarPower.Controllers
index++; index++;
cell = row.CreateCell(index); cell = row.CreateCell(index);
cell.SetCellValue("有效發電小時"); cell.SetCellValue("總發電量");
cell.CellStyle = styleLine12;
region = new CellRangeAddress(RowPosition, RowPosition, index, index + 1);
sheet.AddMergedRegion(region);
index++;
cell = row.CreateCell(index);
cell.CellStyle = styleLine12;
index++;
cell = row.CreateCell(index);
cell.SetCellValue("日均發電度數");
cell.CellStyle = styleLine12; cell.CellStyle = styleLine12;
region = new CellRangeAddress(RowPosition, RowPosition, index, index + 1); region = new CellRangeAddress(RowPosition, RowPosition, index, index + 1);
sheet.AddMergedRegion(region); sheet.AddMergedRegion(region);
@ -2332,7 +2409,7 @@ namespace SolarPower.Controllers
index++; index++;
cell = row.CreateCell(index); cell = row.CreateCell(index);
cell.SetCellValue(Math.Round(kwhkwp / Formbody.Result.Data.Count, 2)); cell.SetCellValue(Math.Round(kwp / totalGeneratingCapacity, 2));
cell.CellStyle = styleLine12; cell.CellStyle = styleLine12;
region = new CellRangeAddress(RowPosition, RowPosition, index, index + 1); region = new CellRangeAddress(RowPosition, RowPosition, index, index + 1);
sheet.AddMergedRegion(region); sheet.AddMergedRegion(region);