using System; using System.Collections.Generic; using System.Data; using NPOI.SS.UserModel; using System.IO; using Wellan.Data; using Wellan.Common; /// /// 出缺勤情形統計表 的摘要描述 /// public class 出缺勤情形統計表 : ExcelReportBase { public 出缺勤情形統計表() { } private ICellStyle bodyNumberStyleNoBorderD2; protected override void Init() { base.Init(); titleStyleCenterNoBorder.SetFont(bodyFont); bodyStyleCenterNoBorder.SetFont(bodyFont); bodyNumberStyleNoBorder.SetFont(bodyFont); titleStyleRightNoBorder.SetFont(bodyFont); titleStyleLeftNoBorder.SetFont(bodyFont); bodyNumberStyleNoBorderD2 = excel.NewCellStyle(bodyFont, HorizontalAlignment.Right, VerticalAlignment.Top, true); bodyNumberStyleNoBorderD2.DataFormat = NumberFormat.GetFormat("###,###,##0.00"); bodyNumberStyleNoBorderD2.WrapText = true; } public override MemoryStream 產生報表() { #region 報表抬頭 var row = 0; excel.MergeCell(row, 0, row, 19, BorderStyle.None); excel.SetCellValue(row, 0, 公司名稱, headerStyle); excel.SetRowHeight(row, 20); row++; excel.MergeCell(row, 0, row, 19, BorderStyle.None); excel.SetCellValue(row, 0, string.Format("承辦{0}", 客戶名稱), headerStyle); excel.SetRowHeight(row, 20); row++; excel.MergeCell(row, 0, row, 19, BorderStyle.None); excel.SetCellValue(row, 0, string.Format("『{0}』", 專案名稱), headerStyle); excel.SetRowHeight(row, 20); row++; excel.MergeCell(row, 0, row, 19, BorderStyle.None); excel.SetCellValue(row, 0, string.Format("{0}【{1}{2}】", 報表名稱, 年度, 月份), headerStyle); excel.SetRowHeight(row, 20); row++; excel.MergeCell(row, 4, row, 19, BorderStyle.None); excel.SetCellValue(row, 4, string.Format("{0}{1}出缺勤情形(單位:時)", 年度, 月份), titleStyleCenterNoBorder); row++; excel.SetCellValue(row, 0, "序號", titleStyleCenterNoBorder); excel.SetCellValue(row, 1, "站別", titleStyleCenterNoBorder); excel.SetCellValue(row, 2, "人員姓名", titleStyleCenterNoBorder); excel.SetCellValue(row, 3, "補休", titleStyleCenterNoBorder); excel.SetCellValue(row, 4, "特休", titleStyleCenterNoBorder); excel.SetCellValue(row, 5, "產假", titleStyleCenterNoBorder); excel.SetCellValue(row, 6, "公假", titleStyleCenterNoBorder); excel.SetCellValue(row, 7, "事假", titleStyleCenterNoBorder); excel.SetCellValue(row, 8, "喪假", titleStyleCenterNoBorder); excel.SetCellValue(row, 9, "病假", titleStyleCenterNoBorder); excel.SetCellValue(row, 10, "加班一", titleStyleCenterNoBorder); excel.SetCellValue(row, 11, "加班二", titleStyleCenterNoBorder); excel.SetCellValue(row, 12, "婚假", titleStyleCenterNoBorder); excel.SetCellValue(row, 13, "工傷假", titleStyleCenterNoBorder); excel.SetCellValue(row, 14, "生理假", titleStyleCenterNoBorder); excel.SetCellValue(row, 15, "家庭照顧假", titleStyleCenterNoBorder); excel.SetCellValue(row, 16, "陪產假", titleStyleCenterNoBorder); excel.SetCellValue(row, 17, "原民祭儀假", titleStyleCenterNoBorder); excel.SetCellValue(row, 18, "產檢假", titleStyleCenterNoBorder); excel.SetCellValue(row, 19, "其他假別(一)", titleStyleCenterNoBorder); excel.SetRowHeight(row, 20); row++; #endregion #region 報表資料 int beginRow = row; int serial = 1; int SST05_SUM = 0; int SST06_SUM = 0; int SST10_SUM = 0; int SST13_SUM = 0; int SST07_SUM = 0; int SST09_SUM = 0; int SST08_SUM = 0; int 加班_SUM = 0; int SST04_SUM = 0; int SST11_SUM = 0; int SST14_SUM = 0; int SST15_SUM = 0; int SST16_SUM = 0; int SST12_SUM = 0; int SST19_SUM = 0; int SST20_SUM = 0; int SST23_SUM = 0; int 全勤人數 = 0; foreach (DataRow r in 資料來源.Tables[0].Rows) { var 加班 = WDAC.GetInt32Value(r["SST01"]) * 60 + WDAC.GetInt32Value(r["SST01M"]) + WDAC.GetInt32Value(r["SST02"]) * 60 + WDAC.GetInt32Value(r["SST02M"]) + WDAC.GetInt32Value(r["SST03"]) * 60 + WDAC.GetInt32Value(r["SST03M"]) + WDAC.GetInt32Value(r["SST21"]) * 60 + WDAC.GetInt32Value(r["SST21M"]) + WDAC.GetInt32Value(r["SST22"]) * 60 + WDAC.GetInt32Value(r["SST22M"]); SST05_SUM += WDAC.GetInt32Value(r["SST05"]) * 60 + WDAC.GetInt32Value(r["SST05M"]); SST06_SUM += WDAC.GetInt32Value(r["SST06"]) * 60 + WDAC.GetInt32Value(r["SST06M"]); SST10_SUM += WDAC.GetInt32Value(r["SST10"]) * 60 + WDAC.GetInt32Value(r["SST10M"]); SST13_SUM += WDAC.GetInt32Value(r["SST13"]) * 60 + WDAC.GetInt32Value(r["SST13M"]); SST07_SUM += WDAC.GetInt32Value(r["SST07"]) * 60 + WDAC.GetInt32Value(r["SST07M"]); SST09_SUM += WDAC.GetInt32Value(r["SST09"]) * 60 + WDAC.GetInt32Value(r["SST09M"]); SST08_SUM += WDAC.GetInt32Value(r["SST08"]) * 60 + WDAC.GetInt32Value(r["SST08M"]); 加班_SUM += 加班; SST04_SUM += WDAC.GetInt32Value(r["SST04"]) * 60 + WDAC.GetInt32Value(r["SST04M"]); SST11_SUM += WDAC.GetInt32Value(r["SST11"]) * 60 + WDAC.GetInt32Value(r["SST11M"]); SST14_SUM += WDAC.GetInt32Value(r["SST14"]) * 60 + WDAC.GetInt32Value(r["SST14M"]); SST15_SUM += WDAC.GetInt32Value(r["SST15"]) * 60 + WDAC.GetInt32Value(r["SST15M"]); SST16_SUM += WDAC.GetInt32Value(r["SST16"]) * 60 + WDAC.GetInt32Value(r["SST16M"]); SST12_SUM += WDAC.GetInt32Value(r["SST12"]) * 60 + WDAC.GetInt32Value(r["SST12M"]); SST19_SUM += WDAC.GetInt32Value(r["SST19"]) * 60 + WDAC.GetInt32Value(r["SST19M"]); SST20_SUM += WDAC.GetInt32Value(r["SST20"]) * 60 + WDAC.GetInt32Value(r["SST20M"]); SST23_SUM += WDAC.GetInt32Value(r["SST23"]) * 60 + WDAC.GetInt32Value(r["SST23M"]); 全勤人數 += WDAC.GetInt32Value(r["SST07"]) == 0 && WDAC.GetInt32Value(r["SST08"]) == 0 && WDAC.GetInt32Value(r["SST10"]) == 0 && WDAC.GetInt32Value(r["SST12"]) == 0 ? 1 : 0; excel.SetCellValue(row, 0, serial, bodyStyleCenterNoBorder); excel.SetCellValue(row, 1, WDAC.GetStringValue(r["SSBRHX"]), bodyStyleCenterNoBorder); excel.SetCellValue(row, 2, WDAC.GetStringValue(r["BPNME"]), bodyStyleCenterNoBorder); if (以時分顯示時數) { excel.SetCellValue(row, 3, string.Format("{0:#00}:{1:00}", r["SST05"], r["SST05M"]), bodyStyleCenterNoBorder); excel.SetCellValue(row, 4, string.Format("{0:#00}:{1:00}", r["SST06"], r["SST06M"]), bodyStyleCenterNoBorder); excel.SetCellValue(row, 5, string.Format("{0:#00}:{1:00}", r["SST10"], r["SST10M"]), bodyStyleCenterNoBorder); excel.SetCellValue(row, 6, string.Format("{0:#00}:{1:00}", r["SST13"], r["SST13M"]), bodyStyleCenterNoBorder); excel.SetCellValue(row, 7, string.Format("{0:#00}:{1:00}", r["SST07"], r["SST07M"]), bodyStyleCenterNoBorder); excel.SetCellValue(row, 8, string.Format("{0:#00}:{1:00}", r["SST09"], r["SST09M"]), bodyStyleCenterNoBorder); excel.SetCellValue(row, 9, string.Format("{0:#00}:{1:00}", r["SST08"], r["SST08M"]), bodyStyleCenterNoBorder); excel.SetCellValue(row, 10, string.Format("{0:#00}:{1:00}", (int)Math.Floor(加班 / 60.0), 加班 % 60), bodyStyleCenterNoBorder); excel.SetCellValue(row, 11, string.Format("{0:#00}:{1:00}", r["SST04"], r["SST04M"]), bodyStyleCenterNoBorder); excel.SetCellValue(row, 12, string.Format("{0:#00}:{1:00}", r["SST11"], r["SST11M"]), bodyStyleCenterNoBorder); excel.SetCellValue(row, 13, string.Format("{0:#00}:{1:00}", r["SST14"], r["SST14M"]), bodyStyleCenterNoBorder); excel.SetCellValue(row, 14, string.Format("{0:#00}:{1:00}", r["SST15"], r["SST15M"]), bodyStyleCenterNoBorder); excel.SetCellValue(row, 15, string.Format("{0:#00}:{1:00}", r["SST16"], r["SST16M"]), bodyStyleCenterNoBorder); excel.SetCellValue(row, 16, string.Format("{0:#00}:{1:00}", r["SST12"], r["SST12M"]), bodyStyleCenterNoBorder); excel.SetCellValue(row, 17, string.Format("{0:#00}:{1:00}", r["SST19"], r["SST19M"]), bodyStyleCenterNoBorder); excel.SetCellValue(row, 18, string.Format("{0:#00}:{1:00}", r["SST20"], r["SST20M"]), bodyStyleCenterNoBorder); excel.SetCellValue(row, 19, string.Format("{0:#00}:{1:00}", r["SST23"], r["SST23M"]), bodyStyleCenterNoBorder); } else { excel.SetCellValue(row, 3, WDAC.GetInt32Value(r["SST05"]), bodyNumberStyleNoBorder); excel.SetCellValue(row, 4, WDAC.GetInt32Value(r["SST06"]), bodyNumberStyleNoBorder); excel.SetCellValue(row, 5, WDAC.GetInt32Value(r["SST10"]), bodyNumberStyleNoBorder); excel.SetCellValue(row, 6, WDAC.GetInt32Value(r["SST13"]), bodyNumberStyleNoBorder); excel.SetCellValue(row, 7, WDAC.GetInt32Value(r["SST07"]), bodyNumberStyleNoBorder); excel.SetCellValue(row, 8, WDAC.GetInt32Value(r["SST09"]), bodyNumberStyleNoBorder); excel.SetCellValue(row, 9, WDAC.GetInt32Value(r["SST08"]), bodyNumberStyleNoBorder); excel.SetCellValue(row, 10, (int)Math.Floor(加班 / 60.0), bodyNumberStyleNoBorder); excel.SetCellValue(row, 11, WDAC.GetInt32Value(r["SST04"]), bodyNumberStyleNoBorder); excel.SetCellValue(row, 12, WDAC.GetInt32Value(r["SST11"]), bodyNumberStyleNoBorder); excel.SetCellValue(row, 13, WDAC.GetInt32Value(r["SST14"]), bodyNumberStyleNoBorder); excel.SetCellValue(row, 14, WDAC.GetInt32Value(r["SST15"]), bodyNumberStyleNoBorder); excel.SetCellValue(row, 15, WDAC.GetInt32Value(r["SST16"]), bodyNumberStyleNoBorder); excel.SetCellValue(row, 16, WDAC.GetInt32Value(r["SST12"]), bodyNumberStyleNoBorder); excel.SetCellValue(row, 17, WDAC.GetInt32Value(r["SST19"]), bodyNumberStyleNoBorder); excel.SetCellValue(row, 18, WDAC.GetInt32Value(r["SST20"]), bodyNumberStyleNoBorder); excel.SetCellValue(row, 19, WDAC.GetInt32Value(r["SST23"]), bodyNumberStyleNoBorder); } row++; serial++; } #endregion #region 合計及表尾批示 var 人數 = (float)資料來源.Tables[0].Rows.Count; // 表尾合計 excel.MergeCell(row, 0, row, 2, BorderStyle.None); excel.SetCellValue(row, 0, string.Format("{0} 位合計", 人數), titleStyleLeftNoBorder); if (以時分顯示時數) { excel.SetCellValue(row, 3, MinuteToTime(SST05_SUM), bodyStyleCenterNoBorder); excel.SetCellValue(row, 4, MinuteToTime(SST06_SUM), bodyStyleCenterNoBorder); excel.SetCellValue(row, 5, MinuteToTime(SST10_SUM), bodyStyleCenterNoBorder); excel.SetCellValue(row, 6, MinuteToTime(SST13_SUM), bodyStyleCenterNoBorder); excel.SetCellValue(row, 7, MinuteToTime(SST07_SUM), bodyStyleCenterNoBorder); excel.SetCellValue(row, 8, MinuteToTime(SST09_SUM), bodyStyleCenterNoBorder); excel.SetCellValue(row, 9, MinuteToTime(SST08_SUM), bodyStyleCenterNoBorder); excel.SetCellValue(row, 10, MinuteToTime(加班_SUM), bodyStyleCenterNoBorder); excel.SetCellValue(row, 11, MinuteToTime(SST04_SUM), bodyStyleCenterNoBorder); excel.SetCellValue(row, 12, MinuteToTime(SST11_SUM), bodyStyleCenterNoBorder); excel.SetCellValue(row, 13, MinuteToTime(SST14_SUM), bodyStyleCenterNoBorder); excel.SetCellValue(row, 14, MinuteToTime(SST15_SUM), bodyStyleCenterNoBorder); excel.SetCellValue(row, 15, MinuteToTime(SST16_SUM), bodyStyleCenterNoBorder); excel.SetCellValue(row, 16, MinuteToTime(SST12_SUM), bodyStyleCenterNoBorder); excel.SetCellValue(row, 17, MinuteToTime(SST19_SUM), bodyStyleCenterNoBorder); excel.SetCellValue(row, 18, MinuteToTime(SST20_SUM), bodyStyleCenterNoBorder); excel.SetCellValue(row, 19, MinuteToTime(SST23_SUM), bodyStyleCenterNoBorder); } else { excel.SetCellFormula(row, 3, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 3), excel.RCtoA1(row - 1, 3)), bodyNumberStyleNoBorder); excel.SetCellFormula(row, 4, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 4), excel.RCtoA1(row - 1, 4)), bodyNumberStyleNoBorder); excel.SetCellFormula(row, 5, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 5), excel.RCtoA1(row - 1, 5)), bodyNumberStyleNoBorder); excel.SetCellFormula(row, 6, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 6), excel.RCtoA1(row - 1, 6)), bodyNumberStyleNoBorder); excel.SetCellFormula(row, 7, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 7), excel.RCtoA1(row - 1, 7)), bodyNumberStyleNoBorder); excel.SetCellFormula(row, 8, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 8), excel.RCtoA1(row - 1, 8)), bodyNumberStyleNoBorder); excel.SetCellFormula(row, 9, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 9), excel.RCtoA1(row - 1, 9)), bodyNumberStyleNoBorder); excel.SetCellFormula(row, 10, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 10), excel.RCtoA1(row - 1, 10)), bodyNumberStyleNoBorder); excel.SetCellFormula(row, 11, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 11), excel.RCtoA1(row - 1, 11)), bodyNumberStyleNoBorder); excel.SetCellFormula(row, 12, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 12), excel.RCtoA1(row - 1, 12)), bodyNumberStyleNoBorder); excel.SetCellFormula(row, 13, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 13), excel.RCtoA1(row - 1, 13)), bodyNumberStyleNoBorder); excel.SetCellFormula(row, 14, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 14), excel.RCtoA1(row - 1, 14)), bodyNumberStyleNoBorder); excel.SetCellFormula(row, 15, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 15), excel.RCtoA1(row - 1, 15)), bodyNumberStyleNoBorder); excel.SetCellFormula(row, 16, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 16), excel.RCtoA1(row - 1, 16)), bodyNumberStyleNoBorder); excel.SetCellFormula(row, 17, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 17), excel.RCtoA1(row - 1, 17)), bodyNumberStyleNoBorder); excel.SetCellFormula(row, 18, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 18), excel.RCtoA1(row - 1, 18)), bodyNumberStyleNoBorder); excel.SetCellFormula(row, 19, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 19), excel.RCtoA1(row - 1, 19)), bodyNumberStyleNoBorder); } row++; // 表尾平均、備註 excel.MergeCell(row, 0, row, 2, BorderStyle.None); excel.SetCellValue(row, 0, string.Format("{0} 位平均", 人數), titleStyleLeftNoBorder); if (以時分顯示時數) { var SST05_AVG = SST05_SUM / 人數; var SST06_AVG = SST06_SUM / 人數; var SST10_AVG = SST10_SUM / 人數; var SST13_AVG = SST13_SUM / 人數; var SST07_AVG = SST07_SUM / 人數; var SST09_AVG = SST09_SUM / 人數; var SST08_AVG = SST08_SUM / 人數; var 加班_AVG = 加班_SUM / 人數; var SST04_AVG = SST04_SUM / 人數; var SST11_AVG = SST11_SUM / 人數; var SST14_AVG = SST14_SUM / 人數; var SST15_AVG = SST15_SUM / 人數; var SST16_AVG = SST16_SUM / 人數; var SST12_AVG = SST12_SUM / 人數; var SST19_AVG = SST19_SUM / 人數; var SST20_AVG = SST20_SUM / 人數; var SST23_AVG = SST23_SUM / 人數; excel.SetCellValue(row, 3, string.Format("{0:#00}:{1:00}", (int)Math.Floor(SST05_AVG / 60.0), (int)Math.Floor(SST05_AVG % 60)), bodyStyleCenterNoBorder); excel.SetCellValue(row, 4, string.Format("{0:#00}:{1:00}", (int)Math.Floor(SST06_AVG / 60.0), (int)Math.Floor(SST06_AVG % 60)), bodyStyleCenterNoBorder); excel.SetCellValue(row, 5, string.Format("{0:#00}:{1:00}", (int)Math.Floor(SST10_AVG / 60.0), (int)Math.Floor(SST10_AVG % 60)), bodyStyleCenterNoBorder); excel.SetCellValue(row, 6, string.Format("{0:#00}:{1:00}", (int)Math.Floor(SST13_AVG / 60.0), (int)Math.Floor(SST13_AVG % 60)), bodyStyleCenterNoBorder); excel.SetCellValue(row, 7, string.Format("{0:#00}:{1:00}", (int)Math.Floor(SST07_AVG / 60.0), (int)Math.Floor(SST07_AVG % 60)), bodyStyleCenterNoBorder); excel.SetCellValue(row, 8, string.Format("{0:#00}:{1:00}", (int)Math.Floor(SST09_AVG / 60.0), (int)Math.Floor(SST09_AVG % 60)), bodyStyleCenterNoBorder); excel.SetCellValue(row, 9, string.Format("{0:#00}:{1:00}", (int)Math.Floor(SST08_AVG / 60.0), (int)Math.Floor(SST08_AVG % 60)), bodyStyleCenterNoBorder); excel.SetCellValue(row, 10, string.Format("{0:#00}:{1:00}", (int)Math.Floor(加班_AVG / 60.0), (int)Math.Floor(加班_AVG % 60)), bodyStyleCenterNoBorder); excel.SetCellValue(row, 11, string.Format("{0:#00}:{1:00}", (int)Math.Floor(SST04_AVG / 60.0), (int)Math.Floor(SST04_AVG % 60)), bodyStyleCenterNoBorder); excel.SetCellValue(row, 12, string.Format("{0:#00}:{1:00}", (int)Math.Floor(SST11_AVG / 60.0), (int)Math.Floor(SST11_AVG % 60)), bodyStyleCenterNoBorder); excel.SetCellValue(row, 13, string.Format("{0:#00}:{1:00}", (int)Math.Floor(SST14_AVG / 60.0), (int)Math.Floor(SST14_AVG % 60)), bodyStyleCenterNoBorder); excel.SetCellValue(row, 14, string.Format("{0:#00}:{1:00}", (int)Math.Floor(SST15_AVG / 60.0), (int)Math.Floor(SST15_AVG % 60)), bodyStyleCenterNoBorder); excel.SetCellValue(row, 15, string.Format("{0:#00}:{1:00}", (int)Math.Floor(SST16_AVG / 60.0), (int)Math.Floor(SST16_AVG % 60)), bodyStyleCenterNoBorder); excel.SetCellValue(row, 16, string.Format("{0:#00}:{1:00}", (int)Math.Floor(SST12_AVG / 60.0), (int)Math.Floor(SST12_AVG % 60)), bodyStyleCenterNoBorder); excel.SetCellValue(row, 17, string.Format("{0:#00}:{1:00}", (int)Math.Floor(SST19_AVG / 60.0), (int)Math.Floor(SST19_AVG % 60)), bodyStyleCenterNoBorder); excel.SetCellValue(row, 18, string.Format("{0:#00}:{1:00}", (int)Math.Floor(SST20_AVG / 60.0), (int)Math.Floor(SST20_AVG % 60)), bodyStyleCenterNoBorder); excel.SetCellValue(row, 19, string.Format("{0:#00}:{1:00}", (int)Math.Floor(SST23_AVG / 60.0), (int)Math.Floor(SST23_AVG % 60)), bodyStyleCenterNoBorder); row++; excel.MergeCell(row, 0, row, 2, BorderStyle.None); excel.SetCellValue(row, 0, "備註:1.", titleStyleRightNoBorder); excel.MergeCell(row, 3, row, 19, BorderStyle.None); excel.SetCellValue(row, 3, "加班1為加班採申請加班費方式;加班2為加班採補休方式申請。", titleStyleLeftNoBorder); row++; excel.MergeCell(row, 3, row, 19, BorderStyle.None); excel.SetCellValue(row, 3, string.Format("本月平均加班時數為 {0:#00}:{1:00} 小時。", (int)Math.Floor(加班_AVG / 60.0), (int)Math.Floor(加班_AVG % 60)), titleStyleLeftNoBorder); row++; excel.MergeCell(row, 0, row, 2, BorderStyle.None); excel.SetCellValue(row, 0, "2.", titleStyleRightNoBorder); excel.MergeCell(row, 3, row, 19, BorderStyle.None); excel.SetCellValue(row, 3, string.Format("{0}全勤(不含補休、特休及公假)共 {1} 位,全勤占 {2:##0.0}%。", 月份, 全勤人數, ((double)全勤人數 / (double)人數 * 100.0)), titleStyleLeftNoBorder); row++; } else { var 加班_AVG = (double)加班_SUM / (double)人數; excel.SetCellFormula(row, 3, String.Format("AVERAGE({0}:{1})", excel.RCtoA1(beginRow, 3), excel.RCtoA1(row - 2, 3)), bodyNumberStyleNoBorderD2); excel.SetCellFormula(row, 4, String.Format("AVERAGE({0}:{1})", excel.RCtoA1(beginRow, 4), excel.RCtoA1(row - 2, 4)), bodyNumberStyleNoBorderD2); excel.SetCellFormula(row, 5, String.Format("AVERAGE({0}:{1})", excel.RCtoA1(beginRow, 5), excel.RCtoA1(row - 2, 5)), bodyNumberStyleNoBorderD2); excel.SetCellFormula(row, 6, String.Format("AVERAGE({0}:{1})", excel.RCtoA1(beginRow, 6), excel.RCtoA1(row - 2, 6)), bodyNumberStyleNoBorderD2); excel.SetCellFormula(row, 7, String.Format("AVERAGE({0}:{1})", excel.RCtoA1(beginRow, 7), excel.RCtoA1(row - 2, 7)), bodyNumberStyleNoBorderD2); excel.SetCellFormula(row, 8, String.Format("AVERAGE({0}:{1})", excel.RCtoA1(beginRow, 8), excel.RCtoA1(row - 2, 8)), bodyNumberStyleNoBorderD2); excel.SetCellFormula(row, 9, String.Format("AVERAGE({0}:{1})", excel.RCtoA1(beginRow, 9), excel.RCtoA1(row - 2, 9)), bodyNumberStyleNoBorderD2); excel.SetCellFormula(row, 10, String.Format("AVERAGE({0}:{1})", excel.RCtoA1(beginRow, 10), excel.RCtoA1(row - 2, 10)), bodyNumberStyleNoBorderD2); excel.SetCellFormula(row, 11, String.Format("AVERAGE({0}:{1})", excel.RCtoA1(beginRow, 11), excel.RCtoA1(row - 2, 11)), bodyNumberStyleNoBorderD2); excel.SetCellFormula(row, 12, String.Format("AVERAGE({0}:{1})", excel.RCtoA1(beginRow, 12), excel.RCtoA1(row - 2, 12)), bodyNumberStyleNoBorderD2); excel.SetCellFormula(row, 13, String.Format("AVERAGE({0}:{1})", excel.RCtoA1(beginRow, 13), excel.RCtoA1(row - 2, 13)), bodyNumberStyleNoBorderD2); excel.SetCellFormula(row, 14, String.Format("AVERAGE({0}:{1})", excel.RCtoA1(beginRow, 14), excel.RCtoA1(row - 2, 14)), bodyNumberStyleNoBorderD2); excel.SetCellFormula(row, 15, String.Format("AVERAGE({0}:{1})", excel.RCtoA1(beginRow, 15), excel.RCtoA1(row - 2, 15)), bodyNumberStyleNoBorderD2); excel.SetCellFormula(row, 16, String.Format("AVERAGE({0}:{1})", excel.RCtoA1(beginRow, 16), excel.RCtoA1(row - 2, 16)), bodyNumberStyleNoBorderD2); excel.SetCellFormula(row, 17, String.Format("AVERAGE({0}:{1})", excel.RCtoA1(beginRow, 17), excel.RCtoA1(row - 2, 17)), bodyNumberStyleNoBorderD2); excel.SetCellFormula(row, 18, String.Format("AVERAGE({0}:{1})", excel.RCtoA1(beginRow, 18), excel.RCtoA1(row - 2, 18)), bodyNumberStyleNoBorderD2); excel.SetCellFormula(row, 19, String.Format("AVERAGE({0}:{1})", excel.RCtoA1(beginRow, 19), excel.RCtoA1(row - 2, 19)), bodyNumberStyleNoBorderD2); row++; excel.MergeCell(row, 0, row, 2, BorderStyle.None); excel.SetCellValue(row, 0, "備註:1.", titleStyleRightNoBorder); excel.MergeCell(row, 3, row, 19, BorderStyle.None); excel.SetCellValue(row, 3, "加班1為加班採申請加班費方式;加班2為加班採補休方式申請。", titleStyleLeftNoBorder); row++; excel.MergeCell(row, 3, row, 19, BorderStyle.None); excel.SetCellValue(row, 3, string.Format("本月平均加班時數為 {0:#00.00} 小時。", 加班_AVG), titleStyleLeftNoBorder); row++; excel.MergeCell(row, 0, row, 2, BorderStyle.None); excel.SetCellValue(row, 0, "2.", titleStyleRightNoBorder); excel.MergeCell(row, 3, row, 19, BorderStyle.None); excel.SetCellValue(row, 3, string.Format("{0}全勤(不含補休、特休及公假)共 {1} 位,全勤占 {2:##0.0}%。", 月份, 全勤人數, ((double)全勤人數 / (double)人數 * 100.0)), titleStyleLeftNoBorder); row++; } excel.MergeCell(row, 0, row, 6, BorderStyle.None); excel.SetCellValue(row, 0, "承辦人:", titleStyleLeftNoBorder); excel.MergeCell(row, 7, row, 13, BorderStyle.None); excel.SetCellValue(row, 7, "業務主管:", titleStyleLeftNoBorder); excel.MergeCell(row, 14, row, 19, BorderStyle.None); excel.SetCellValue(row, 14, "公司章:", titleStyleLeftNoBorder); #endregion excel.SetColumnWidth(0, 6); excel.SetColumnWidth(1, 10); excel.SetColumnWidth(2, 10); excel.SetColumnWidth(3, 10); excel.SetColumnWidth(4, 10); excel.SetColumnWidth(5, 10); excel.SetColumnWidth(6, 10); excel.SetColumnWidth(7, 10); excel.SetColumnWidth(8, 10); excel.SetColumnWidth(9, 10); excel.SetColumnWidth(10, 10); excel.SetColumnWidth(11, 10); excel.SetColumnWidth(12, 10); excel.SetColumnWidth(13, 10); excel.SetColumnWidth(14, 10); excel.SetColumnWidth(15, 10); excel.SetColumnWidth(16, 10); excel.SetColumnWidth(17, 10); excel.SetColumnWidth(18, 10); excel.SetColumnWidth(19, 10); MemoryStream ms = new MemoryStream(); workbook.Write(ms); return ms; } }