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 各項法定提撥費用明細表() { } protected override void Init() { base.Init(); titleStyleCenterNoBorder.SetFont(bodyFont); bodyStyleCenterNoBorder.SetFont(bodyFont); bodyNumberStyleNoBorder.SetFont(bodyFont); titleStyleRightNoBorder.SetFont(bodyFont); titleStyleLeftNoBorder.SetFont(bodyFont); } public override MemoryStream 產生報表() { #region 報表抬頭 var row = 0; excel.MergeCell(row, 0, row, 14, BorderStyle.None); excel.SetCellValue(row, 0, 公司名稱, headerStyle); excel.SetRowHeight(row, 20); row++; excel.MergeCell(row, 0, row, 14, BorderStyle.None); excel.SetCellValue(row, 0, string.Format("承辦{0}", 客戶名稱), headerStyle); excel.SetRowHeight(row, 20); row++; excel.MergeCell(row, 0, row, 14, BorderStyle.None); excel.SetCellValue(row, 0, string.Format("『{0}』", 專案名稱), headerStyle); excel.SetRowHeight(row, 20); row++; excel.MergeCell(row, 0, row, 14, BorderStyle.None); excel.SetCellValue(row, 0, string.Format("{0}【{1}{2}】", 報表名稱, 年度, 月份), headerStyle); excel.SetRowHeight(row, 20); row++; excel.MergeCell(row, 5, row, 8, BorderStyle.None); excel.SetCellValue(row, 5, "員工自負額", titleStyleCenterNoBorder); excel.MergeCell(row, 9, row, 14, BorderStyle.None); excel.SetCellValue(row, 9, "雇主負擔部分", 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); row++; #endregion #region 報表資料 int beginRow = row; int serial = 1; foreach (DataRow r in 資料來源.Tables[0].Rows) { excel.SetCellValue(row, 0, serial, bodyStyleCenterNoBorder); excel.SetCellValue(row, 1, WDAC.GetStringValue(r["BPNME"]), bodyStyleCenterNoBorder); excel.SetCellValue(row, 2, WDAC.GetInt32Value(r["SSP00"]) + WDAC.GetInt32Value(r["SSP02"]), bodyNumberStyleNoBorder); excel.SetCellValue(row, 3, WDAC.GetInt32Value(r["SSL01"]), bodyNumberStyleNoBorder); excel.SetCellValue(row, 4, WDAC.GetInt32Value(r["SSD02"]), bodyNumberStyleNoBorder); excel.SetCellValue(row, 5, WDAC.GetInt32Value(r["SSS04"]), bodyNumberStyleNoBorder); excel.SetCellValue(row, 6, WDAC.GetInt32Value(r["SSS05"]), bodyNumberStyleNoBorder); excel.SetCellValue(row, 7, WDAC.GetInt32Value(r["SSS07"]), bodyNumberStyleNoBorder); excel.SetCellValue(row, 8, WDAC.GetInt32Value(r["SSS06"]), bodyNumberStyleNoBorder); excel.SetCellValue(row, 9, WDAC.GetInt32Value(r["SSH01"]), bodyNumberStyleNoBorder); excel.SetCellValue(row, 10, WDAC.GetInt32Value(r["SSH02"]), bodyNumberStyleNoBorder); excel.SetCellValue(row, 11, WDAC.GetInt32Value(r["SSH03"]), bodyNumberStyleNoBorder); excel.SetCellValue(row, 12, WDAC.GetInt32Value(r["SSH04"]), bodyNumberStyleNoBorder); excel.SetCellValue(row, 13, WDAC.GetInt32Value(r["SSH05"]), bodyNumberStyleNoBorder); excel.SetCellValue(row, 14, WDAC.GetInt32Value(r["SSH06"]), bodyNumberStyleNoBorder); row++; serial++; } #endregion #region 合計及表尾批示 excel.MergeCell(row, 0, row, 1, BorderStyle.None); excel.SetCellValue(row, 0, "合計", titleStyleLeftNoBorder); 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); row++; excel.SetCellValue(row, 9, "雇主勞保", titleStyleRightNoBorder); excel.MergeCell(row, 10, row, 11, BorderStyle.None); excel.SetCellFormula(row, 10, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 9), excel.RCtoA1(row - 2, 11)), bodyNumberStyleNoBorder); row++; excel.MergeCell(row, 0, row, 4, BorderStyle.None); excel.SetCellValue(row, 0, "承辦人:", titleStyleLeftNoBorder); excel.MergeCell(row, 5, row, 9, BorderStyle.None); excel.SetCellValue(row, 5, "業務主管:", titleStyleLeftNoBorder); excel.MergeCell(row, 10, row, 14, BorderStyle.None); excel.SetCellValue(row, 10, "公司章:", 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); MemoryStream ms = new MemoryStream(); workbook.Write(ms); return ms; } }