104 lines
5.6 KiB
C#
104 lines
5.6 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, 10);
|
|
excel.SetCellValue(0, 0, 公司名稱, titleStyleCenter);
|
|
excel.MergeCell(1, 0, 1, 10);
|
|
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.SetColumnWidthInChars(0, 12);
|
|
excel.SetColumnWidthInChars(1, 12);
|
|
excel.SetColumnWidthInChars(2, 45);
|
|
excel.SetColumnWidthInChars(3, 26);
|
|
excel.SetColumnWidthInChars(4, 12);
|
|
excel.SetColumnWidthInChars(5, 30);
|
|
excel.SetColumnWidthInChars(6, 12);
|
|
excel.SetColumnWidthInChars(7, 15);
|
|
excel.SetColumnWidthInChars(8, 15);
|
|
excel.SetColumnWidthInChars(9, 15);
|
|
excel.SetColumnWidthInChars(10, 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.GetInt32(r["訓練時數"]), bodyStyleCenter);
|
|
excel.SetCellValue(rowId + 2, 5, DAC.GetString(r["訓練場地"]), bodyStyleCenter);
|
|
excel.SetCellValue(rowId + 2, 6, DAC.GetInt32(r["訓練人數"]), bodyStyleCenter);
|
|
excel.SetCellValue(rowId + 2, 7, DAC.GetInt32(r["預估經費"]), bodyStyleCenter);
|
|
excel.SetCellValue(rowId + 2, 8, DAC.GetInt32(r["實際經費"]), bodyStyleCenter);
|
|
excel.SetCellValue(rowId + 2, 9, DAC.GetDouble(r["學員出席率"]), bodyPercentStyle);
|
|
excel.SetCellValue(rowId + 2, 10, 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("SUM({0}:{1})", Excel.RCtoA1(beginRow, 4), Excel.RCtoA1(rowId + 1, 4)), bodyStyleCenter);
|
|
excel.SetCellValue(rowId + 2, 5, "", bodyStyleCenter);
|
|
excel.SetCellFormula(rowId + 2, 6, String.Format("SUM({0}:{1})", Excel.RCtoA1(beginRow, 6), Excel.RCtoA1(rowId + 1, 6)), bodyStyleCenter);
|
|
excel.SetCellFormula(rowId + 2, 7, String.Format("SUM({0}:{1})", Excel.RCtoA1(beginRow, 7), Excel.RCtoA1(rowId + 1, 7)), bodyStyleCenter);
|
|
excel.SetCellFormula(rowId + 2, 8, String.Format("SUM({0}:{1})", Excel.RCtoA1(beginRow, 8), Excel.RCtoA1(rowId + 1, 8)), bodyStyleCenter);
|
|
excel.SetCellFormula(rowId + 2, 9, String.Format("AVERAGE({0}:{1})", Excel.RCtoA1(beginRow, 9), Excel.RCtoA1(rowId + 1, 9)), bodyPercentStyle);
|
|
excel.SetCellFormula(rowId + 2, 10, String.Format("AVERAGE({0}:{1})", Excel.RCtoA1(beginRow, 10), Excel.RCtoA1(rowId + 1, 10)), bodyPercentStyle);
|
|
excel.SetRowHeightInPoints(rowId + 2, (int)Math.Truncate(BodyRowHeight * 2.0));
|
|
|
|
MemoryStream ms = new MemoryStream();
|
|
workbook.Write(ms);
|
|
return ms;
|
|
}
|
|
}
|
|
} |