125 lines
7.5 KiB
C#
125 lines
7.5 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Data;
|
|
using NPOI.SS.Util;
|
|
using WebLib;
|
|
|
|
namespace Education.Report
|
|
{
|
|
public class 年度課程執行狀況報表 : ReportBase
|
|
{
|
|
public string 公司名稱;
|
|
public int 年度;
|
|
public bool 包含未開課;
|
|
public DataTable data;
|
|
|
|
public MemoryStream DoReport()
|
|
{
|
|
workbook.RemoveSheetAt(0);
|
|
|
|
sheet = workbook.CreateSheet("報表");
|
|
SetPaperAndMargin(sheet);
|
|
sheet.RepeatingRows = new CellRangeAddress(0, 2, -1, -1);
|
|
|
|
excel.Sheet = sheet;
|
|
|
|
// 報表抬頭
|
|
excel.MergeCell(0, 0, 0, 15);
|
|
excel.SetCellValue(0, 0, 公司名稱, titleStyleCenter);
|
|
excel.MergeCell(1, 0, 1, 15);
|
|
if (!包含未開課)
|
|
excel.SetCellValue(1, 0, String.Format("{0}年度教育訓練課程執行狀況", 年度), titleStyleCenter);
|
|
else
|
|
excel.SetCellValue(1, 0, String.Format("{0}年度教育訓練課程狀況", 年度), titleStyleCenter);
|
|
excel.SetRowHeightInPoints(0, HeaderRowHeight);
|
|
excel.SetRowHeightInPoints(1, HeaderRowHeight);
|
|
|
|
// excel.SetRangeOuterBorder(1, 0, 1, 7, BorderStyle.Thin);
|
|
|
|
excel.SetCellValue(2, 0, "", bodyStyleCenter);
|
|
excel.SetCellValue(2, 1, "訓練日期", bodyStyleCenter);
|
|
excel.SetCellValue(2, 2, "課程企劃編號名稱", bodyStyleCenter);
|
|
excel.SetCellValue(2, 3, "講師姓名", bodyStyleCenter);
|
|
excel.SetCellValue(2, 4, "講師滿意度", bodyStyleCenter);
|
|
excel.SetCellValue(2, 5, "課程滿意度", bodyStyleCenter);
|
|
excel.SetCellValue(2, 6, "行政服務品質滿意度", bodyStyleCenter);
|
|
excel.SetCellValue(2, 7, "餐點與茶飲滿意度", bodyStyleCenter);
|
|
excel.SetCellValue(2, 8, "場地滿意度", bodyStyleCenter);
|
|
excel.SetCellValue(2, 9, "訓練時數", bodyStyleCenter);
|
|
excel.SetCellValue(2, 10, "訓練場地", bodyStyleCenter);
|
|
excel.SetCellValue(2, 11, "訓練人數", bodyStyleCenter);
|
|
excel.SetCellValue(2, 12, "預估經費", bodyStyleCenter);
|
|
excel.SetCellValue(2, 13, "實際經費", bodyStyleCenter);
|
|
excel.SetCellValue(2, 14, "學員出席率", bodyStyleCenter);
|
|
excel.SetCellValue(2, 15, "整體滿意度", bodyStyleCenter);
|
|
|
|
excel.SetColumnWidthInChars(0, 12);
|
|
excel.SetColumnWidthInChars(1, 12);
|
|
excel.SetColumnWidthInChars(2, 45);
|
|
excel.SetColumnWidthInChars(3, 20);
|
|
excel.SetColumnWidthInChars(4, 15);
|
|
excel.SetColumnWidthInChars(5, 15);
|
|
excel.SetColumnWidthInChars(6, 22);
|
|
excel.SetColumnWidthInChars(7, 22);
|
|
excel.SetColumnWidthInChars(8, 15);
|
|
excel.SetColumnWidthInChars(9, 12);
|
|
excel.SetColumnWidthInChars(10, 30);
|
|
excel.SetColumnWidthInChars(11, 12);
|
|
excel.SetColumnWidthInChars(12, 15);
|
|
excel.SetColumnWidthInChars(13, 15);
|
|
excel.SetColumnWidthInChars(14, 15);
|
|
excel.SetColumnWidthInChars(15, 15);
|
|
excel.SetRowHeightInPoints(2, (int)Math.Truncate(BodyRowHeight * 2.0));
|
|
|
|
int rowId = 1;
|
|
int beginRow = 3;
|
|
foreach (DataRow r in data.Rows)
|
|
{
|
|
// 報表內容
|
|
excel.SetCellValue(rowId + 2, 0, rowId, bodyStyleCenter);
|
|
excel.SetCellValue(rowId + 2, 1, 訓練課程企劃.Get訓練日期Str(DAC.GetDateTime(r["訓練日期"]), DAC.GetDateTime(r["訓練日期迄"]), "yyyyMMdd"), bodyStyleCenter);
|
|
excel.SetCellValue(rowId + 2, 2, String.Format("[{0:000000}]{1}", r["編號"], r["訓練名稱"]), bodyStyleLeft);
|
|
excel.SetCellValue(rowId + 2, 3, DAC.GetString(r["講師姓名"]), bodyStyleLeft);
|
|
excel.SetCellValue(rowId + 2, 4, DAC.GetDouble(r["講師滿意度"]), bodyPercentStyle);
|
|
excel.SetCellValue(rowId + 2, 5, DAC.GetDouble(r["課程滿意度"]), bodyPercentStyle);
|
|
excel.SetCellValue(rowId + 2, 6, DAC.GetDouble(r["行政滿意度"]), bodyPercentStyle);
|
|
excel.SetCellValue(rowId + 2, 7, DAC.GetDouble(r["餐點滿意度"]), bodyPercentStyle);
|
|
excel.SetCellValue(rowId + 2, 8, DAC.GetDouble(r["場地滿意度"]), bodyPercentStyle);
|
|
excel.SetCellValue(rowId + 2, 9, DAC.GetInt32(r["訓練時數"]), bodyStyleCenter);
|
|
excel.SetCellValue(rowId + 2, 10, DAC.GetString(r["訓練場地"]), bodyStyleCenter);
|
|
excel.SetCellValue(rowId + 2, 11, DAC.GetInt32(r["訓練人數"]), bodyStyleCenter);
|
|
excel.SetCellValue(rowId + 2, 12, DAC.GetInt32(r["預估經費"]), bodyStyleCenter);
|
|
excel.SetCellValue(rowId + 2, 13, DAC.GetInt32(r["實際經費"]), bodyStyleCenter);
|
|
excel.SetCellValue(rowId + 2, 14, DAC.GetDouble(r["學員出席率"]), bodyPercentStyle);
|
|
excel.SetCellValue(rowId + 2, 15, DAC.GetDouble(r["整體滿意度"]), bodyPercentStyle);
|
|
|
|
// excel.SetRowHeightInPoints(rowId + 2, (int)Math.Truncate(BodyRowHeight * 1.5));
|
|
rowId++;
|
|
}
|
|
|
|
// 報表結尾統計
|
|
excel.SetCellValue(rowId + 2, 0, "統計結果", bodyStyleCenter);
|
|
excel.SetCellValue(rowId + 2, 1, "", bodyStyleCenter);
|
|
excel.SetCellValue(rowId + 2, 2, "", bodyStyleLeft);
|
|
excel.SetCellValue(rowId + 2, 3, "", bodyStyleLeft);
|
|
excel.SetCellFormula(rowId + 2, 4, String.Format("AVERAGE({0}:{1})", Excel.RCtoA1(beginRow, 4), Excel.RCtoA1(rowId + 1, 4)), bodyPercentStyle);
|
|
excel.SetCellFormula(rowId + 2, 5, String.Format("AVERAGE({0}:{1})", Excel.RCtoA1(beginRow, 5), Excel.RCtoA1(rowId + 1, 5)), bodyPercentStyle);
|
|
excel.SetCellFormula(rowId + 2, 6, String.Format("AVERAGE({0}:{1})", Excel.RCtoA1(beginRow, 6), Excel.RCtoA1(rowId + 1, 6)), bodyPercentStyle);
|
|
excel.SetCellFormula(rowId + 2, 7, String.Format("AVERAGE({0}:{1})", Excel.RCtoA1(beginRow, 7), Excel.RCtoA1(rowId + 1, 7)), bodyPercentStyle);
|
|
excel.SetCellFormula(rowId + 2, 8, String.Format("AVERAGE({0}:{1})", Excel.RCtoA1(beginRow, 8), Excel.RCtoA1(rowId + 1, 8)), bodyPercentStyle);
|
|
excel.SetCellFormula(rowId + 2, 9, String.Format("SUM({0}:{1})", Excel.RCtoA1(beginRow, 9), Excel.RCtoA1(rowId + 1, 9)), bodyStyleCenter);
|
|
excel.SetCellValue(rowId + 2, 10, "", bodyStyleCenter);
|
|
excel.SetCellFormula(rowId + 2, 11, String.Format("SUM({0}:{1})", Excel.RCtoA1(beginRow, 11), Excel.RCtoA1(rowId + 1, 11)), bodyStyleCenter);
|
|
excel.SetCellFormula(rowId + 2, 12, String.Format("SUM({0}:{1})", Excel.RCtoA1(beginRow, 12), Excel.RCtoA1(rowId + 1, 12)), bodyStyleCenter);
|
|
excel.SetCellFormula(rowId + 2, 13, String.Format("SUM({0}:{1})", Excel.RCtoA1(beginRow, 13), Excel.RCtoA1(rowId + 1, 13)), bodyStyleCenter);
|
|
excel.SetCellFormula(rowId + 2, 14, String.Format("AVERAGE({0}:{1})", Excel.RCtoA1(beginRow, 14), Excel.RCtoA1(rowId + 1, 14)), bodyPercentStyle);
|
|
excel.SetCellFormula(rowId + 2, 15, String.Format("AVERAGE({0}:{1})", Excel.RCtoA1(beginRow, 15), Excel.RCtoA1(rowId + 1, 15)), bodyPercentStyle);
|
|
excel.SetRowHeightInPoints(rowId + 2, (int)Math.Truncate(BodyRowHeight * 2.0));
|
|
|
|
MemoryStream ms = new MemoryStream();
|
|
workbook.Write(ms);
|
|
return ms;
|
|
}
|
|
}
|
|
}
|