chore: 首次簽入 Thinkyu ASP.NET 專案
- 加入 Visual Studio / ASP.NET .gitignore - 排除建置輸出、IDE 設定、NuGet packages、大型 MSI 安裝檔
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
using System;
|
||||
using System.Web;
|
||||
using System.Web.Services;
|
||||
using System.Web.Services.Protocols;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Xml.Serialization;
|
||||
using System.IO.Compression;
|
||||
|
||||
[WebService(Namespace = "http://www.maolaoda.com/CRAXFileTransfer")]
|
||||
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
|
||||
public class CRAXFileTransfer : System.Web.Services.WebService
|
||||
{
|
||||
public CRAXFileTransfer()
|
||||
{
|
||||
//Uncomment the following line if using designed components
|
||||
//InitializeComponent();
|
||||
}
|
||||
|
||||
[WebMethod]
|
||||
public GetFileResponse GetFile(string filename, bool compress)
|
||||
{
|
||||
GetFileResponse response = new GetFileResponse();
|
||||
try
|
||||
{
|
||||
response.FileName = filename;
|
||||
|
||||
if (compress)
|
||||
{
|
||||
FileStream readStream = File.Open(Server.MapPath(filename), FileMode.Open, FileAccess.Read);
|
||||
byte[] buffer = new byte[readStream.Length];
|
||||
int count = readStream.Read(buffer, 0, buffer.Length);
|
||||
readStream.Close();
|
||||
if (count != buffer.Length)
|
||||
{
|
||||
response.Message = "Unable to read data from " + filename;
|
||||
}
|
||||
else
|
||||
{
|
||||
MemoryStream outputStream = new MemoryStream();
|
||||
GZipStream compressStream = new GZipStream(outputStream, CompressionMode.Compress, true);
|
||||
compressStream.Write(buffer, 0, buffer.Length);
|
||||
compressStream.Flush();
|
||||
compressStream.Close();
|
||||
response.FileContents = outputStream.GetBuffer();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
response.FileContents = File.ReadAllBytes(Server.MapPath(filename));
|
||||
}
|
||||
|
||||
response.Message = "OK";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
response.Message = "ERROR:" + ex.Message;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
[XmlRoot("getFileResponse", Namespace = "http://www.maolaoda.com/CRAXFileTransfer")]
|
||||
public class GetFileResponse
|
||||
{
|
||||
[XmlElement("fileName", IsNullable = false)]
|
||||
public string FileName;
|
||||
|
||||
[XmlElement("message", IsNullable = false)]
|
||||
public string Message;
|
||||
|
||||
[XmlElement("fileData", IsNullable = true)]
|
||||
public byte[] FileContents;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,315 @@
|
||||
using System;
|
||||
using NPOI.SS.UserModel;
|
||||
using NPOI.SS.Util;
|
||||
using NPOI.HSSF.UserModel;
|
||||
using NPOI.HSSF.Util;
|
||||
using System.IO;
|
||||
|
||||
public class Excel
|
||||
{
|
||||
public HSSFWorkbook WorkBook
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public HSSFSheet Sheet
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 建立或取得指定行列的儲存格
|
||||
/// </summary>
|
||||
/// <param name="row">列</param>
|
||||
/// <param name="col">行</param>
|
||||
/// <returns></returns>
|
||||
public ICell Cell(int row, int col)
|
||||
{
|
||||
if (Sheet.GetRow(row) == null)
|
||||
Sheet.CreateRow(row);
|
||||
if (Sheet.GetRow(row).GetCell(col) == null)
|
||||
Sheet.GetRow(row).CreateCell(col);
|
||||
return Sheet.GetRow(row).GetCell(col);
|
||||
}
|
||||
|
||||
public string RCtoA1(int row, int col)
|
||||
{
|
||||
string colX;
|
||||
|
||||
if (col <= 25)
|
||||
colX = Char.ConvertFromUtf32(65 + col);
|
||||
else
|
||||
{
|
||||
col = col - 26;
|
||||
colX = Char.ConvertFromUtf32(65 + (int)(col / 26)) + Char.ConvertFromUtf32(65 + (col % 26));
|
||||
}
|
||||
|
||||
return String.Format("{0}{1}", colX, row + 1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 建立新字體
|
||||
/// </summary>
|
||||
public IFont NewFont(string fontName)
|
||||
{
|
||||
return NewFont(fontName, 9, FontBoldWeight.Normal, HSSFColor.COLOR_NORMAL);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 建立新字體
|
||||
/// </summary>
|
||||
public IFont NewFont(string fontName, short fontSize)
|
||||
{
|
||||
return NewFont(fontName, fontSize, FontBoldWeight.Normal, HSSFColor.COLOR_NORMAL);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 建立新字體
|
||||
/// </summary>
|
||||
public IFont NewFont(string fontName, short fontSize, FontBoldWeight fontWeight)
|
||||
{
|
||||
return NewFont(fontName, fontSize, fontWeight, HSSFColor.COLOR_NORMAL);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 建立新字體
|
||||
/// </summary>
|
||||
public IFont NewFont(string fontName, short fontSize, FontBoldWeight fontWeight, short color)
|
||||
{
|
||||
IFont result = WorkBook.CreateFont(); // 抬頭字體
|
||||
result.FontName = fontName;
|
||||
result.FontHeightInPoints = fontSize;
|
||||
result.Boldweight = (short)fontWeight;
|
||||
result.Color = color;
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 建立新樣式
|
||||
/// </summary>
|
||||
public ICellStyle NewCellStyle(IFont font, HorizontalAlignment align, VerticalAlignment valign, bool warpText)
|
||||
{
|
||||
ICellStyle style = WorkBook.CreateCellStyle();
|
||||
style.SetFont(font);
|
||||
style.Alignment = align;
|
||||
style.VerticalAlignment = valign;
|
||||
style.WrapText = warpText;
|
||||
return style;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 合併儲存格
|
||||
/// </summary>
|
||||
public void MergeCell(int row1, int col1, int row2, int col2)
|
||||
{
|
||||
// 建立範圍內所有儲存格
|
||||
for (int row = row1; row <= row2; row++)
|
||||
for (int col = col1; col <= col2; col++)
|
||||
Cell(row, col);
|
||||
|
||||
CellRangeAddress region = new CellRangeAddress(row1, row2, col1, col2); // Region.ConvertToCellRangeAddress(new Region(row1, col1, row2, col2));
|
||||
Sheet.AddMergedRegion(region);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 合併儲存格,並設定合併後的邊框樣式
|
||||
/// </summary>
|
||||
public void MergeCell(int row1, int col1, int row2, int col2, BorderStyle bordertype)
|
||||
{
|
||||
// 建立範圍內所有儲存格
|
||||
for (int row = row1; row <= row2; row++)
|
||||
for (int col = col1; col <= col2; col++)
|
||||
Cell(row, col);
|
||||
|
||||
CellRangeAddress region = new CellRangeAddress(row1, row2, col1, col2); //Region.ConvertToCellRangeAddress(new Region(row1, col1, row2, col2));
|
||||
Sheet.AddMergedRegion(region);
|
||||
SetRangeOuterBorder(region, bordertype);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 設定單一儲存格的邊框樣式
|
||||
/// </summary>
|
||||
public void SetCellBorder(int row, int col, BorderStyle bordertype)
|
||||
{
|
||||
CellRangeAddress region = new CellRangeAddress(row, row, col, col);
|
||||
HSSFRegionUtil.SetBorderTop(bordertype, region, Sheet as HSSFSheet, WorkBook);
|
||||
HSSFRegionUtil.SetBorderLeft(bordertype, region, Sheet as HSSFSheet, WorkBook);
|
||||
HSSFRegionUtil.SetBorderBottom(bordertype, region, Sheet as HSSFSheet, WorkBook);
|
||||
HSSFRegionUtil.SetBorderRight(bordertype, region, Sheet as HSSFSheet, WorkBook);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 設定一個儲存格範圍的外圍邊框樣式
|
||||
/// </summary>
|
||||
public void SetRangeOuterBorder(int row1, int col1, int row2, int col2, BorderStyle bordertype)
|
||||
{
|
||||
CellRangeAddress region = new CellRangeAddress(row1, row2, col1, col2);
|
||||
HSSFRegionUtil.SetBorderTop(bordertype, region, Sheet as HSSFSheet, WorkBook);
|
||||
HSSFRegionUtil.SetBorderLeft(bordertype, region, Sheet as HSSFSheet, WorkBook);
|
||||
HSSFRegionUtil.SetBorderBottom(bordertype, region, Sheet as HSSFSheet, WorkBook);
|
||||
HSSFRegionUtil.SetBorderRight(bordertype, region, Sheet as HSSFSheet, WorkBook);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 設定一個儲存格範圍的外圍邊框樣式
|
||||
/// </summary>
|
||||
public void SetRangeOuterBorder(int row1, int col1, int row2, int col2, BorderStyle bordertypeTop, BorderStyle bordertypeLeft, BorderStyle bordertypeBottom, BorderStyle bordertypeRight)
|
||||
{
|
||||
CellRangeAddress region = new CellRangeAddress(row1, row2, col1, col2);
|
||||
HSSFRegionUtil.SetBorderTop(bordertypeTop, region, Sheet as HSSFSheet, WorkBook);
|
||||
HSSFRegionUtil.SetBorderLeft(bordertypeLeft, region, Sheet as HSSFSheet, WorkBook);
|
||||
HSSFRegionUtil.SetBorderBottom(bordertypeBottom, region, Sheet as HSSFSheet, WorkBook);
|
||||
HSSFRegionUtil.SetBorderRight(bordertypeRight, region, Sheet as HSSFSheet, WorkBook);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 設定一個儲存格範圍的外圍邊框樣式
|
||||
/// </summary>
|
||||
public void SetRangeOuterBorder(CellRangeAddress region, BorderStyle bordertype)
|
||||
{
|
||||
HSSFRegionUtil.SetBorderTop(bordertype, region, Sheet as HSSFSheet, WorkBook);
|
||||
HSSFRegionUtil.SetBorderLeft(bordertype, region, Sheet as HSSFSheet, WorkBook);
|
||||
HSSFRegionUtil.SetBorderBottom(bordertype, region, Sheet as HSSFSheet, WorkBook);
|
||||
HSSFRegionUtil.SetBorderRight(bordertype, region, Sheet as HSSFSheet, WorkBook);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 設定一個儲存格範圍的外圍邊框樣式
|
||||
/// </summary>
|
||||
public void SetRangeOuterBorder(CellRangeAddress region, BorderStyle bordertypeTop, BorderStyle bordertypeLeft, BorderStyle bordertypeBottom, BorderStyle bordertypeRight)
|
||||
{
|
||||
HSSFRegionUtil.SetBorderTop(bordertypeTop, region, Sheet as HSSFSheet, WorkBook);
|
||||
HSSFRegionUtil.SetBorderLeft(bordertypeLeft, region, Sheet as HSSFSheet, WorkBook);
|
||||
HSSFRegionUtil.SetBorderBottom(bordertypeBottom, region, Sheet as HSSFSheet, WorkBook);
|
||||
HSSFRegionUtil.SetBorderRight(bordertypeRight, region, Sheet as HSSFSheet, WorkBook);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 設定一個儲存格範圍的內部格線樣式 (慢,建議僅使用於小範圍!)
|
||||
/// </summary>
|
||||
public void SetRangeInnerGrid(int row1, int col1, int row2, int col2, BorderStyle bordertype)
|
||||
{
|
||||
/*
|
||||
CellRangeAddress region = new CellRangeAddress(row1, row2, col1, col2);
|
||||
Sheet.SetEnclosedBorderOfRegion(region, bordertype, HSSFColor.COLOR_NORMAL);
|
||||
*/
|
||||
|
||||
for (int col = col1; col <= col2; col++)
|
||||
{
|
||||
SetRangeOuterBorder(row1, col, row2, col, bordertype);
|
||||
}
|
||||
for (int row = row1; row <= row2; row++)
|
||||
{
|
||||
SetRangeOuterBorder(row, col1, row, col2, bordertype);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetCellStyle(int row, int col, ICellStyle style)
|
||||
{
|
||||
Cell(row, col).CellStyle = style;
|
||||
}
|
||||
|
||||
public void SetCellValue(int row, int col, bool value, ICellStyle style)
|
||||
{
|
||||
Cell(row, col).SetCellValue(value);
|
||||
Cell(row, col).CellStyle = style;
|
||||
}
|
||||
|
||||
public void SetCellValue(int row, int col, DateTime value, ICellStyle style)
|
||||
{
|
||||
Cell(row, col).SetCellValue(value);
|
||||
Cell(row, col).CellStyle = style;
|
||||
}
|
||||
|
||||
public void SetCellValue(int row, int col, double value, ICellStyle style)
|
||||
{
|
||||
Cell(row, col).SetCellValue(value);
|
||||
Cell(row, col).CellStyle = style;
|
||||
}
|
||||
|
||||
public void SetCellValue(int row, int col, IRichTextString value, ICellStyle style)
|
||||
{
|
||||
Cell(row, col).SetCellValue(value);
|
||||
Cell(row, col).CellStyle = style;
|
||||
}
|
||||
|
||||
public void SetCellValue(int row, int col, string value, ICellStyle style)
|
||||
{
|
||||
Cell(row, col).SetCellValue(value);
|
||||
Cell(row, col).CellStyle = style;
|
||||
}
|
||||
|
||||
public void SetCellValue(int row, int col, bool value)
|
||||
{
|
||||
Cell(row, col).SetCellValue(value);
|
||||
}
|
||||
|
||||
public void SetCellValue(int row, int col, DateTime value)
|
||||
{
|
||||
Cell(row, col).SetCellValue(value);
|
||||
}
|
||||
|
||||
public void SetCellValue(int row, int col, double value)
|
||||
{
|
||||
Cell(row, col).SetCellValue(value);
|
||||
}
|
||||
|
||||
public void SetCellValue(int row, int col, IRichTextString value)
|
||||
{
|
||||
Cell(row, col).SetCellValue(value);
|
||||
}
|
||||
|
||||
public void SetCellValue(int row, int col, string value)
|
||||
{
|
||||
Cell(row, col).SetCellValue(value);
|
||||
}
|
||||
|
||||
public void SetCellFormula(int row, int col, string formula)
|
||||
{
|
||||
Cell(row, col).CellFormula = formula;
|
||||
}
|
||||
|
||||
public void SetCellFormula(int row, int col, string formula, ICellStyle style)
|
||||
{
|
||||
Cell(row, col).CellFormula = formula;
|
||||
Cell(row, col).CellStyle = style;
|
||||
}
|
||||
|
||||
private HSSFPatriarch patriarch = null;
|
||||
public void DrawLine(int col1, int row1, int dx1, int dy1, int col2, int row2, int dx2, int dy2, LineStyle lineStyle, int lineWidth)
|
||||
{
|
||||
if (patriarch == null)
|
||||
patriarch = Sheet.CreateDrawingPatriarch() as HSSFPatriarch;
|
||||
|
||||
HSSFClientAnchor a = new HSSFClientAnchor(dx1, dy1, dx2, dy2, col1, row1, col2, row2);
|
||||
HSSFSimpleShape s = patriarch.CreateSimpleShape(a);
|
||||
s.ShapeType = HSSFSimpleShape.OBJECT_TYPE_LINE; // 設定線條類型為線條
|
||||
s.LineStyle = lineStyle; // 設定為實線
|
||||
s.LineWidth = lineWidth;
|
||||
}
|
||||
|
||||
public void DrawPicture(int col1, int row1, int dx1, int dy1, int col2, int row2, int dx2, int dy2, string pictureFileName)
|
||||
{
|
||||
if (patriarch == null)
|
||||
patriarch = Sheet.CreateDrawingPatriarch() as HSSFPatriarch;
|
||||
|
||||
byte[] picture = File.ReadAllBytes(pictureFileName);
|
||||
int pictureIdx = WorkBook.AddPicture(picture, PictureType.JPEG);
|
||||
|
||||
HSSFClientAnchor a = new HSSFClientAnchor(dx1, dy1, dx2, dy2, col1, row1, col2, row2);
|
||||
HSSFPicture p = patriarch.CreatePicture(a, pictureIdx) as HSSFPicture;
|
||||
//p.Resize();
|
||||
}
|
||||
|
||||
public void SetColumnWidth(int column, int width)
|
||||
{
|
||||
Sheet.SetColumnWidth(column, width * 256 + 182);
|
||||
}
|
||||
|
||||
public void SetRowHeight(int row, int height)
|
||||
{
|
||||
Sheet.GetRow(row).HeightInPoints = height;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,313 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Web;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using NPOI.SS.UserModel;
|
||||
using NPOI.HSSF.UserModel;
|
||||
using NPOI.HSSF.Util;
|
||||
using System.IO;
|
||||
using NPOI.SS.Util;
|
||||
|
||||
/// <summary>
|
||||
/// 報表基礎類別
|
||||
/// </summary>
|
||||
public abstract class ExcelReportBase
|
||||
{
|
||||
protected HSSFWorkbook workbook;
|
||||
protected HSSFSheet sheet;
|
||||
protected Excel excel;
|
||||
protected IFont headerFont;
|
||||
protected IFont footerFont;
|
||||
protected IFont titleFont;
|
||||
protected IFont titleFontBoldUnderLine;
|
||||
protected IFont bodyFont;
|
||||
protected IFont bodyFontS;
|
||||
protected IFont bodyFont6PT;
|
||||
protected IFont bodyFont8PT;
|
||||
protected ICellStyle headerStyle;
|
||||
protected ICellStyle footerStyle;
|
||||
protected ICellStyle titleStyleLeft;
|
||||
protected ICellStyle titleStyleRight;
|
||||
protected ICellStyle titleStyleCenter;
|
||||
protected ICellStyle titleStyleCenterYellowBGC;
|
||||
protected ICellStyle titleStyleCenterBottom;
|
||||
protected ICellStyle titleStyleLeftNoBorder;
|
||||
protected ICellStyle titleStyleRightNoBorder;
|
||||
protected ICellStyle titleStyleCenterNoBorder;
|
||||
protected ICellStyle titleStyleCenterBottomNoBorder;
|
||||
protected ICellStyle titleStyleCenterUDBorder;
|
||||
protected ICellStyle bodyStyleLeft;
|
||||
protected ICellStyle bodyStyleRight;
|
||||
protected ICellStyle bodyStyleCenter;
|
||||
protected ICellStyle bodyStyleLeftNoBorder;
|
||||
protected ICellStyle bodyStyleRightNoBorder;
|
||||
protected ICellStyle bodyStyleCenterNoBorder;
|
||||
|
||||
protected ICellStyle bodyNumberStyle;
|
||||
protected ICellStyle bodyNumberStyleNoBorder;
|
||||
protected ICellStyle bodyNumberStyleUDBorder;
|
||||
protected ICellStyle bodyNumberStyle2;
|
||||
protected ICellStyle bodyStyleCenterS;
|
||||
protected ICellStyle bodyStyleCenterXS;
|
||||
protected int HeaderRowHeight = 27;
|
||||
protected int BodyRowHeight = 24;
|
||||
protected int thisYy;
|
||||
protected int thisMm;
|
||||
protected int prevYy;
|
||||
protected int prevMm;
|
||||
|
||||
public ExcelReportBase()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
public DataSet 資料來源
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public string 公司名稱
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public string 客戶名稱
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public string 專案名稱
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public string 報表名稱
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public DateTime 報表時間
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public string 客戶編號
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public string 專案編號
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public string 年度
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public string 月份
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public Dictionary<string, string> 報表參數
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public bool 以時分顯示時數 { get; set; }
|
||||
|
||||
protected virtual void Init()
|
||||
{
|
||||
workbook = new HSSFWorkbook();
|
||||
sheet = workbook.CreateSheet("報表") as HSSFSheet;
|
||||
sheet.ForceFormulaRecalculation = true;
|
||||
excel = new Excel();
|
||||
excel.WorkBook = workbook;
|
||||
excel.Sheet = sheet;
|
||||
numberFormat = workbook.CreateDataFormat();
|
||||
|
||||
SetPaperAndMargin(sheet);
|
||||
|
||||
headerFont = excel.NewFont("標楷體", 16, FontBoldWeight.Bold);
|
||||
footerFont = excel.NewFont("標楷體", 16);
|
||||
titleFont = excel.NewFont("標楷體", 12);
|
||||
titleFontBoldUnderLine = excel.NewFont("標楷體", 12, FontBoldWeight.Bold);
|
||||
titleFontBoldUnderLine.Underline = FontUnderlineType.Single;
|
||||
bodyFont = excel.NewFont("標楷體", 12);
|
||||
bodyFontS = excel.NewFont("標楷體", 10);
|
||||
bodyFont6PT = excel.NewFont("標楷體", 6);
|
||||
bodyFont8PT = excel.NewFont("標楷體", 8);
|
||||
|
||||
headerStyle = excel.NewCellStyle(headerFont, HorizontalAlignment.Center, VerticalAlignment.Top, true);
|
||||
footerStyle = excel.NewCellStyle(footerFont, HorizontalAlignment.Left, VerticalAlignment.Top, true);
|
||||
|
||||
titleStyleLeft = excel.NewCellStyle(titleFont, HorizontalAlignment.Left, VerticalAlignment.Top, true);
|
||||
titleStyleLeft.BorderTop = BorderStyle.Thin;
|
||||
titleStyleLeft.BorderBottom = BorderStyle.Thin;
|
||||
titleStyleLeft.BorderLeft = BorderStyle.Thin;
|
||||
titleStyleLeft.BorderRight = BorderStyle.Thin;
|
||||
|
||||
titleStyleRight = excel.NewCellStyle(titleFont, HorizontalAlignment.Right, VerticalAlignment.Top, true);
|
||||
titleStyleRight.BorderTop = BorderStyle.Thin;
|
||||
titleStyleRight.BorderBottom = BorderStyle.Thin;
|
||||
titleStyleRight.BorderLeft = BorderStyle.Thin;
|
||||
titleStyleRight.BorderRight = BorderStyle.Thin;
|
||||
|
||||
titleStyleCenter = excel.NewCellStyle(titleFont, HorizontalAlignment.Center, VerticalAlignment.Top, true);
|
||||
titleStyleCenter.BorderTop = BorderStyle.Thin;
|
||||
titleStyleCenter.BorderBottom = BorderStyle.Thin;
|
||||
titleStyleCenter.BorderLeft = BorderStyle.Thin;
|
||||
titleStyleCenter.BorderRight = BorderStyle.Thin;
|
||||
|
||||
titleStyleCenterYellowBGC = excel.NewCellStyle(titleFont, HorizontalAlignment.Center, VerticalAlignment.Top, true);
|
||||
titleStyleCenterYellowBGC.BorderTop = BorderStyle.Thin;
|
||||
titleStyleCenterYellowBGC.BorderBottom = BorderStyle.Thin;
|
||||
titleStyleCenterYellowBGC.BorderLeft = BorderStyle.Thin;
|
||||
titleStyleCenterYellowBGC.BorderRight = BorderStyle.Thin;
|
||||
titleStyleCenterYellowBGC.FillBackgroundColor = NPOI.HSSF.Util.HSSFColor.Yellow.Index;
|
||||
titleStyleCenterYellowBGC.FillPattern = FillPattern.SolidForeground;
|
||||
titleStyleCenterYellowBGC.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Yellow.Index;
|
||||
|
||||
titleStyleCenterBottom = excel.NewCellStyle(titleFont, HorizontalAlignment.Center, VerticalAlignment.Bottom, true);
|
||||
titleStyleCenterBottom.BorderTop = BorderStyle.Thin;
|
||||
titleStyleCenterBottom.BorderBottom = BorderStyle.Thin;
|
||||
titleStyleCenterBottom.BorderLeft = BorderStyle.Thin;
|
||||
titleStyleCenterBottom.BorderRight = BorderStyle.Thin;
|
||||
|
||||
titleStyleLeftNoBorder = excel.NewCellStyle(titleFont, HorizontalAlignment.Left, VerticalAlignment.Top, true);
|
||||
titleStyleRightNoBorder = excel.NewCellStyle(titleFont, HorizontalAlignment.Right, VerticalAlignment.Top, true);
|
||||
titleStyleCenterNoBorder = excel.NewCellStyle(titleFont, HorizontalAlignment.Center, VerticalAlignment.Top, true);
|
||||
titleStyleCenterBottomNoBorder = excel.NewCellStyle(titleFont, HorizontalAlignment.Center, VerticalAlignment.Bottom, true);
|
||||
|
||||
titleStyleCenterUDBorder = excel.NewCellStyle(titleFont, HorizontalAlignment.Center, VerticalAlignment.Top, true);
|
||||
titleStyleCenterUDBorder.BorderTop = BorderStyle.Thin;
|
||||
titleStyleCenterUDBorder.BorderBottom = BorderStyle.Thin;
|
||||
|
||||
bodyStyleLeft = excel.NewCellStyle(bodyFont, HorizontalAlignment.Left, VerticalAlignment.Top, true);
|
||||
bodyStyleLeft.BorderTop = BorderStyle.Thin;
|
||||
bodyStyleLeft.BorderBottom = BorderStyle.Thin;
|
||||
bodyStyleLeft.BorderLeft = BorderStyle.Thin;
|
||||
bodyStyleLeft.BorderRight = BorderStyle.Thin;
|
||||
bodyStyleLeft.WrapText = true;
|
||||
|
||||
bodyStyleRight = excel.NewCellStyle(bodyFont, HorizontalAlignment.Right, VerticalAlignment.Top, true);
|
||||
bodyStyleRight.BorderTop = BorderStyle.Thin;
|
||||
bodyStyleRight.BorderBottom = BorderStyle.Thin;
|
||||
bodyStyleRight.BorderLeft = BorderStyle.Thin;
|
||||
bodyStyleRight.BorderRight = BorderStyle.Thin;
|
||||
bodyStyleRight.WrapText = true;
|
||||
|
||||
bodyStyleCenter = excel.NewCellStyle(bodyFont, HorizontalAlignment.Center, VerticalAlignment.Top, true);
|
||||
bodyStyleCenter.BorderTop = BorderStyle.Thin;
|
||||
bodyStyleCenter.BorderBottom = BorderStyle.Thin;
|
||||
bodyStyleCenter.BorderLeft = BorderStyle.Thin;
|
||||
bodyStyleCenter.BorderRight = BorderStyle.Thin;
|
||||
bodyStyleCenter.WrapText = true;
|
||||
|
||||
bodyStyleLeftNoBorder = excel.NewCellStyle(bodyFont, HorizontalAlignment.Left, VerticalAlignment.Top, true);
|
||||
bodyStyleLeftNoBorder.WrapText = true;
|
||||
|
||||
bodyStyleRightNoBorder = excel.NewCellStyle(bodyFont, HorizontalAlignment.Right, VerticalAlignment.Top, true);
|
||||
bodyStyleRightNoBorder.WrapText = true;
|
||||
|
||||
bodyStyleCenterNoBorder = excel.NewCellStyle(bodyFont, HorizontalAlignment.Center, VerticalAlignment.Top, true);
|
||||
bodyStyleCenterNoBorder.WrapText = true;
|
||||
|
||||
bodyStyleCenterS = excel.NewCellStyle(bodyFontS, HorizontalAlignment.Center, VerticalAlignment.Top, true);
|
||||
bodyStyleCenterS.BorderTop = BorderStyle.Thin;
|
||||
bodyStyleCenterS.BorderBottom = BorderStyle.Thin;
|
||||
bodyStyleCenterS.BorderLeft = BorderStyle.Thin;
|
||||
bodyStyleCenterS.BorderRight = BorderStyle.Thin;
|
||||
bodyStyleCenterS.WrapText = true;
|
||||
|
||||
bodyStyleCenterXS = excel.NewCellStyle(bodyFont6PT, HorizontalAlignment.Center, VerticalAlignment.Top, true);
|
||||
bodyStyleCenterXS.BorderTop = BorderStyle.Thin;
|
||||
bodyStyleCenterXS.BorderBottom = BorderStyle.Thin;
|
||||
bodyStyleCenterXS.BorderLeft = BorderStyle.Thin;
|
||||
bodyStyleCenterXS.BorderRight = BorderStyle.Thin;
|
||||
bodyStyleCenterXS.WrapText = true;
|
||||
|
||||
bodyNumberStyle = excel.NewCellStyle(bodyFont, HorizontalAlignment.Right, VerticalAlignment.Top, true);
|
||||
bodyNumberStyle.DataFormat = numberFormat.GetFormat("###,###,##0");
|
||||
bodyNumberStyle.BorderTop = BorderStyle.Thin;
|
||||
bodyNumberStyle.BorderBottom = BorderStyle.Thin;
|
||||
bodyNumberStyle.BorderLeft = BorderStyle.Thin;
|
||||
bodyNumberStyle.BorderRight = BorderStyle.Thin;
|
||||
bodyNumberStyle.WrapText = true;
|
||||
|
||||
bodyNumberStyle2 = excel.NewCellStyle(bodyFont, HorizontalAlignment.Right, VerticalAlignment.Top, true);
|
||||
bodyNumberStyle2.DataFormat = numberFormat.GetFormat("###,###,##0.00");
|
||||
bodyNumberStyle2.BorderTop = BorderStyle.Thin;
|
||||
bodyNumberStyle2.BorderBottom = BorderStyle.Thin;
|
||||
bodyNumberStyle2.BorderLeft = BorderStyle.Thin;
|
||||
bodyNumberStyle2.BorderRight = BorderStyle.Thin;
|
||||
bodyNumberStyle2.WrapText = true;
|
||||
|
||||
bodyNumberStyleNoBorder = excel.NewCellStyle(bodyFont, HorizontalAlignment.Right, VerticalAlignment.Top, true);
|
||||
bodyNumberStyleNoBorder.DataFormat = numberFormat.GetFormat("###,###,##0");
|
||||
bodyNumberStyleNoBorder.WrapText = true;
|
||||
|
||||
bodyNumberStyleUDBorder = excel.NewCellStyle(bodyFont, HorizontalAlignment.Right, VerticalAlignment.Top, true);
|
||||
bodyNumberStyleUDBorder.DataFormat = numberFormat.GetFormat("###,###,##0");
|
||||
bodyNumberStyleUDBorder.BorderTop = BorderStyle.Thin;
|
||||
bodyNumberStyleUDBorder.BorderBottom = BorderStyle.Thin;
|
||||
bodyNumberStyleUDBorder.WrapText = true;
|
||||
|
||||
資料來源 = new DataSet();
|
||||
}
|
||||
|
||||
private IDataFormat numberFormat;
|
||||
protected IDataFormat NumberFormat { get { return numberFormat; } }
|
||||
|
||||
protected void SetPaperAndMargin(HSSFSheet Asheet)
|
||||
{
|
||||
// 設定紙張
|
||||
Asheet.PrintSetup.PaperSize = 9; // A4
|
||||
Asheet.PrintSetup.Landscape = false; // 橫向
|
||||
|
||||
// 列印格式
|
||||
Asheet.PrintSetup.UsePage = true;
|
||||
Asheet.PrintSetup.FitWidth = 1; // 將所有欄擠進 1 頁寬
|
||||
Asheet.PrintSetup.FitHeight = 0; // 0 表示不指定幾頁
|
||||
|
||||
// 頁首頁尾
|
||||
Asheet.Footer.Left = "列印日期:&D";
|
||||
Asheet.Footer.Right = "頁數:&P";
|
||||
|
||||
// 紙張邊界
|
||||
Asheet.PrintSetup.HeaderMargin = 0d;
|
||||
Asheet.PrintSetup.FooterMargin = 0.3d;
|
||||
Asheet.SetMargin(MarginType.TopMargin, 0.5d);
|
||||
Asheet.SetMargin(MarginType.BottomMargin, 0.5d);
|
||||
Asheet.SetMargin(MarginType.LeftMargin, 0.3d);
|
||||
Asheet.SetMargin(MarginType.RightMargin, 0.3d);
|
||||
}
|
||||
|
||||
protected string MinuteToTime(int minute)
|
||||
{
|
||||
int hh = minute / 60;
|
||||
int mm = minute % 60;
|
||||
|
||||
if (以時分顯示時數)
|
||||
return String.Format("{0:##0}:{1:00}", hh, mm);
|
||||
else
|
||||
return hh.ToString();
|
||||
}
|
||||
|
||||
public abstract MemoryStream 產生報表();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Configuration;
|
||||
using System.Web;
|
||||
using System.Web.Security;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Web.UI.WebControls.WebParts;
|
||||
using System.Web.UI.HtmlControls;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
/// <summary>
|
||||
/// Summary description for ReportParameter
|
||||
/// </summary>
|
||||
public class ReportParameter
|
||||
{
|
||||
private SortedList<string, string> _paramList = new SortedList<string, string>();
|
||||
|
||||
public ReportParameter()
|
||||
{
|
||||
}
|
||||
|
||||
public void Add(string name, string value)
|
||||
{
|
||||
if (!_paramList.ContainsKey(name))
|
||||
_paramList.Add(name, value);
|
||||
else
|
||||
_paramList[name] = value;
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
_paramList.Clear();
|
||||
}
|
||||
|
||||
public string Save(string fileName, bool random)
|
||||
{
|
||||
string realFileName = GetRealFileName(fileName, random);
|
||||
if (File.Exists(realFileName))
|
||||
File.Delete(realFileName);
|
||||
using (StreamWriter sw = File.CreateText(realFileName))
|
||||
{
|
||||
for (int i = 0; i < _paramList.Count; i++)
|
||||
{
|
||||
sw.WriteLine(String.Format("{0}={1}", _paramList.Keys[i], _paramList.Values[i]));
|
||||
}
|
||||
sw.Close();
|
||||
}
|
||||
return realFileName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 為檔案名稱加上隨機字尾
|
||||
/// </summary>
|
||||
private string GetRealFileName(string fileName, bool random)
|
||||
{
|
||||
if (!random)
|
||||
return fileName;
|
||||
|
||||
string ext = Path.GetExtension(fileName);
|
||||
string s = Path.ChangeExtension(fileName, null);
|
||||
do
|
||||
{
|
||||
Random r = new Random();
|
||||
int suffix = r.Next(int.MaxValue);
|
||||
fileName = String.Format("{0}_{1:x8}{2}", s, suffix, ext);
|
||||
}
|
||||
while (File.Exists(fileName));
|
||||
|
||||
return fileName;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,220 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Configuration;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
|
||||
/// <summary>
|
||||
/// 畫薪資條
|
||||
/// </summary>
|
||||
public class SalaryStrip
|
||||
{
|
||||
public string 公司名稱 = "";
|
||||
public string 薪資別 = "";
|
||||
public string 發薪年月 = "";
|
||||
public string 部門 = "";
|
||||
public string 員工代號 = "";
|
||||
public string 姓名 = "";
|
||||
public string 職務 = "";
|
||||
|
||||
public int 公司提繳 = 0;
|
||||
public int 津貼合計 = 0;
|
||||
public int 課稅金額 = 0;
|
||||
public int 應發金額 = 0;
|
||||
public int 員工累計 = 0;
|
||||
public int 扣款合計 = 0;
|
||||
public int 所得稅 = 0;
|
||||
public int 實發金額 = 0;
|
||||
public int 公司累計 = 0;
|
||||
public string 帳號 = "";
|
||||
public int 薪資條樣板 = 0;
|
||||
|
||||
public bool 列印公司提繳 = true;
|
||||
public bool 列印津貼合計 = true;
|
||||
public bool 列印課稅金額 = true;
|
||||
public bool 列印應發金額 = true;
|
||||
public bool 列印員工累計 = true;
|
||||
public bool 列印扣款合計 = true;
|
||||
public bool 列印所得稅 = true;
|
||||
public bool 列印實發金額 = true;
|
||||
public bool 列印公司累計 = true;
|
||||
public bool 列印帳號 = true;
|
||||
|
||||
#region 私用變數
|
||||
|
||||
private Font companyFont = new Font("細明體", 18, FontStyle.Bold);
|
||||
private Font titleFont = new Font("細明體", 11, FontStyle.Regular);
|
||||
private Font detailFont = new Font("細明體", 10, FontStyle.Regular);
|
||||
|
||||
// 定義各點位置
|
||||
private PointF pt公司名稱 = new PointF(379, 35);
|
||||
private PointF pt薪資別 = new PointF(100, 76);
|
||||
private PointF pt發薪年月 = new PointF(633, 76);
|
||||
private PointF pt部門 = new PointF(100, 98);
|
||||
private PointF pt員工代號 = new PointF(290, 98);
|
||||
private PointF pt姓名 = new PointF(442, 98);
|
||||
private PointF pt職務 = new PointF(633, 98);
|
||||
|
||||
private PointF pt加項1 = new PointF(40, 180);
|
||||
private PointF pt減項1 = new PointF(267, 180);
|
||||
private PointF pt出勤1 = new PointF(494, 180);
|
||||
private PointF pt加項2 = new PointF(126, 180);
|
||||
private PointF pt減項2 = new PointF(352, 180);
|
||||
private PointF pt出勤2 = new PointF(668, 180);
|
||||
|
||||
private PointF pt公司提繳 = new PointF(192, 404);
|
||||
private PointF pt津貼合計 = new PointF(343, 404);
|
||||
private PointF pt課稅金額 = new PointF(494, 404);
|
||||
private PointF pt應發金額 = new PointF(645, 404);
|
||||
private PointF pt員工累計 = new PointF(192, 424);
|
||||
private PointF pt扣款合計 = new PointF(343, 424);
|
||||
private PointF pt所得稅 = new PointF(494, 424);
|
||||
private PointF pt實發金額 = new PointF(645, 424);
|
||||
private PointF pt公司累計 = new PointF(192, 443);
|
||||
private PointF pt帳號 = new PointF(343, 443);
|
||||
|
||||
// 定義加項名稱
|
||||
private List<string> PlusNames = new List<string>();
|
||||
private List<int> PlusAmounts = new List<int>();
|
||||
|
||||
// 定義減項名稱
|
||||
private List<string> MinusNames = new List<string>();
|
||||
private List<int> MinusAmounts = new List<int>();
|
||||
|
||||
// 定義出勤名稱
|
||||
private List<string> PresentNames = new List<string>();
|
||||
private List<string> PresentAmounts = new List<string>();
|
||||
|
||||
#endregion
|
||||
|
||||
#region 私用方法
|
||||
|
||||
private string[] 薪資條樣板檔案 = { @"picture\SalaryStrip.dib", @"picture\SalaryStrip_Bonus.dib" };
|
||||
|
||||
private void DrawTitle(Graphics g)
|
||||
{
|
||||
DrawString(g, 公司名稱, companyFont, pt公司名稱, "C");
|
||||
DrawString(g, 薪資別, titleFont, pt薪資別, "L");
|
||||
DrawString(g, 發薪年月, titleFont, pt發薪年月, "L");
|
||||
DrawString(g, 部門, titleFont, pt部門, "L");
|
||||
DrawString(g, 員工代號, titleFont, pt員工代號, "L");
|
||||
DrawString(g, 姓名, titleFont, pt姓名, "L");
|
||||
DrawString(g, 職務, titleFont, pt職務, "L");
|
||||
|
||||
if (列印公司提繳)
|
||||
DrawString(g, String.Format("{0,9:#,###,##0}", 公司提繳), titleFont, pt公司提繳, "L");
|
||||
if (列印津貼合計)
|
||||
DrawString(g, String.Format("{0,9:#,###,##0}", 津貼合計), titleFont, pt津貼合計, "L");
|
||||
if (列印課稅金額)
|
||||
DrawString(g, String.Format("{0,9:#,###,##0}", 課稅金額), titleFont, pt課稅金額, "L");
|
||||
if (列印應發金額)
|
||||
DrawString(g, String.Format("{0,9:#,###,##0}", 應發金額), titleFont, pt應發金額, "L");
|
||||
if (列印員工累計)
|
||||
DrawString(g, String.Format("{0,9:#,###,##0}", 員工累計), titleFont, pt員工累計, "L");
|
||||
if (列印扣款合計)
|
||||
DrawString(g, String.Format("{0,9:#,###,##0}", 扣款合計), titleFont, pt扣款合計, "L");
|
||||
if (列印所得稅)
|
||||
DrawString(g, String.Format("{0,9:#,###,##0}", 所得稅), titleFont, pt所得稅, "L");
|
||||
if (列印實發金額)
|
||||
DrawString(g, String.Format("{0,9:#,###,##0}", 實發金額), titleFont, pt實發金額, "L");
|
||||
if (列印公司累計)
|
||||
DrawString(g, String.Format("{0,9:#,###,##0}", 公司累計), titleFont, pt公司累計, "L");
|
||||
if (列印帳號)
|
||||
DrawString(g, 帳號, titleFont, pt帳號, "L");
|
||||
}
|
||||
|
||||
private void DrawItems(Graphics g)
|
||||
{
|
||||
for (int i = 0; i < PlusNames.Count; i++)
|
||||
g.DrawString(PlusNames[i], detailFont, Brushes.Black, pt加項1.X, pt加項1.Y + (i * 18));
|
||||
for (int i = 0; i < PlusAmounts.Count; i++)
|
||||
g.DrawString(String.Format("{0,9:#,###,##0}", PlusAmounts[i]), detailFont, Brushes.Black, pt加項2.X, pt加項2.Y + (i * 18));
|
||||
|
||||
for (int i = 0; i < MinusNames.Count; i++)
|
||||
g.DrawString(MinusNames[i], detailFont, Brushes.Black, pt減項1.X, pt減項1.Y + (i * 18));
|
||||
for (int i = 0; i < MinusAmounts.Count; i++)
|
||||
g.DrawString(String.Format("{0,9:#,###,##0}", MinusAmounts[i]), detailFont, Brushes.Black, pt減項2.X, pt減項2.Y + (i * 18));
|
||||
|
||||
for (int i = 0; i < PresentNames.Count; i++)
|
||||
g.DrawString(PresentNames[i], detailFont, Brushes.Black, pt出勤1.X, pt出勤1.Y + (i * 18));
|
||||
for (int i = 0; i < PresentAmounts.Count; i++)
|
||||
g.DrawString(String.Format("{0,6:c}", PresentAmounts[i]), detailFont, Brushes.Black, pt出勤2.X, pt出勤2.Y + (i * 18));
|
||||
}
|
||||
|
||||
private void DrawString(Graphics g, string s, Font f, PointF pt, string align)
|
||||
{
|
||||
PointF pt1 = new PointF() { X = pt.X, Y = pt.Y };
|
||||
SizeF size = g.MeasureString(s, f);
|
||||
|
||||
if (align == "R")
|
||||
pt1.X -= size.Width;
|
||||
else if (align == "C")
|
||||
pt1.X -= size.Width / 2;
|
||||
|
||||
g.DrawString(s, f, Brushes.Black, pt1);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public void AddPlus(string name, int amount)
|
||||
{
|
||||
PlusNames.Add(name);
|
||||
PlusAmounts.Add(amount);
|
||||
}
|
||||
|
||||
public void AddMinus(string name, int amount)
|
||||
{
|
||||
MinusNames.Add(name);
|
||||
MinusAmounts.Add(amount);
|
||||
}
|
||||
|
||||
public void AddPresent(string name, string amount)
|
||||
{
|
||||
PresentNames.Add(name);
|
||||
PresentAmounts.Add(amount);
|
||||
}
|
||||
|
||||
public MemoryStream Draw(string rootpath)
|
||||
{
|
||||
Image img = Image.FromFile(rootpath + 薪資條樣板檔案[薪資條樣板]);
|
||||
Graphics g = Graphics.FromImage(img);
|
||||
DrawTitle(g);
|
||||
DrawItems(g);
|
||||
MemoryStream result = new MemoryStream();
|
||||
img.Save(result, System.Drawing.Imaging.ImageFormat.Gif);
|
||||
img.Dispose();
|
||||
g.Dispose();
|
||||
return result;
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
PlusNames.Clear();
|
||||
PlusAmounts.Clear();
|
||||
MinusNames.Clear();
|
||||
MinusAmounts.Clear();
|
||||
PresentNames.Clear();
|
||||
PresentAmounts.Clear();
|
||||
|
||||
公司名稱 = "";
|
||||
薪資別 = "";
|
||||
發薪年月 = "";
|
||||
部門 = "";
|
||||
員工代號 = "";
|
||||
姓名 = "";
|
||||
職務 = "";
|
||||
|
||||
公司提繳 = 0;
|
||||
津貼合計 = 0;
|
||||
課稅金額 = 0;
|
||||
應發金額 = 0;
|
||||
員工累計 = 0;
|
||||
扣款合計 = 0;
|
||||
所得稅 = 0;
|
||||
實發金額 = 0;
|
||||
公司累計 = 0;
|
||||
帳號 = "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Web;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using NPOI.SS.UserModel;
|
||||
using NPOI.HSSF.UserModel;
|
||||
using NPOI.HSSF.Util;
|
||||
using System.IO;
|
||||
using NPOI.SS.Util;
|
||||
using Wellan.Data;
|
||||
|
||||
/// <summary>
|
||||
/// 出差申請單
|
||||
/// </summary>
|
||||
public class 出差申請單 : ExcelReportBase
|
||||
{
|
||||
public 出差申請單()
|
||||
{
|
||||
報表名稱 = "出差申請單";
|
||||
}
|
||||
|
||||
public override MemoryStream 產生報表()
|
||||
{
|
||||
BodyRowHeight = 35;
|
||||
|
||||
#region 報表抬頭
|
||||
|
||||
excel.MergeCell(0, 0, 0, 9);
|
||||
excel.SetCellValue(0, 0, String.Format("{0}\r\n承辦{1}\r\n『{2}』\r\n{3}", 公司名稱, 客戶名稱, 專案名稱, 報表名稱), headerStyle);
|
||||
excel.SetCellValue(1, 0, "月份:", titleStyleRightNoBorder);
|
||||
excel.MergeCell(1, 1, 1, 2);
|
||||
excel.SetCellValue(1, 1, 報表時間.ToString("MM月"), titleStyleLeftNoBorder);
|
||||
excel.SetCellValue(1, 3, "單位:", titleStyleRightNoBorder);
|
||||
excel.SetCellValue(1, 4, WDAC.GetStringValue(資料來源.Tables[0].Rows[0]["站別"]), titleStyleLeftNoBorder);
|
||||
excel.SetCellValue(1, 5, "職稱:", titleStyleRightNoBorder);
|
||||
excel.SetCellValue(1, 6, WDAC.GetStringValue(資料來源.Tables[0].Rows[0]["職稱"]), titleStyleLeftNoBorder);
|
||||
excel.SetCellValue(1, 7, "姓名:", titleStyleRightNoBorder);
|
||||
excel.SetCellValue(1, 8, WDAC.GetStringValue(資料來源.Tables[0].Rows[0]["BPNME"]), titleStyleLeftNoBorder);
|
||||
excel.SetRowHeight(0, HeaderRowHeight * 4);
|
||||
excel.SetRowHeight(1, BodyRowHeight);
|
||||
|
||||
excel.MergeCell(2, 0, 2, 2);
|
||||
excel.SetRangeOuterBorder(2, 0, 2, 2, BorderStyle.Thin);
|
||||
excel.SetCellValue(2, 0, "公差日期", titleStyleCenter);
|
||||
excel.SetCellValue(2, 3, "類別", titleStyleCenter);
|
||||
excel.SetCellValue(2, 4, "開始時間", titleStyleCenter);
|
||||
excel.SetCellValue(2, 5, "結束時間", titleStyleCenter);
|
||||
excel.SetCellValue(2, 6, "時數", titleStyleCenter);
|
||||
excel.SetCellValue(2, 7, "公差地點", titleStyleCenter);
|
||||
excel.SetCellValue(2, 8, "公差事由", titleStyleCenter);
|
||||
excel.SetCellValue(2, 9, "備註", titleStyleCenter);
|
||||
excel.SetRowHeight(2, BodyRowHeight);
|
||||
|
||||
#endregion
|
||||
|
||||
#region 報表資料
|
||||
int rowId = 3;
|
||||
foreach (DataRow r in 資料來源.Tables[0].Rows)
|
||||
{
|
||||
excel.SetCellValue(rowId, 0, WDAC.GetDateTimeValue(r["RPRDT"]).ToString("MM月dd日"), titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 1, "~", titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 2, WDAC.GetDateTimeValue(r["RPEDT"]).ToString("MM月dd日"), titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 3, WDAC.GetStringValue(r["類別"]), titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 4, WDAC.GetStringValue(r["RPRTM"]), titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 5, WDAC.GetStringValue(r["RPETM"]), titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 6, MinuteToTime(WDAC.GetInt32Value(r["RPTCT"])), titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 7, WDAC.GetStringValue(r["RPPLC"]), titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 8, WDAC.GetStringValue(r["RPRSN"]), bodyStyleCenterS);
|
||||
excel.SetCellValue(rowId, 9, WDAC.GetStringValue(r["RPDOC"]), bodyStyleCenterS);
|
||||
excel.SetRowHeight(rowId, BodyRowHeight);
|
||||
rowId++;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 表尾批示
|
||||
|
||||
//excel.MergeCell(rowId + 2, 0, rowId + 2, 9);
|
||||
//excel.SetCellValue(rowId + 2, 0, "申請人: 計畫督導: 人事單位:", titleStyleLeftNoBorder);
|
||||
//excel.SetRowHeight(rowId + 2, BodyRowHeight);
|
||||
|
||||
//excel.MergeCell(rowId + 1, 1, rowId + 1, 3);
|
||||
//excel.MergeCell(rowId + 2, 1, rowId + 2, 3);
|
||||
//excel.SetCellValue(rowId + 1, 1, "申請人", titleStyleCenter);
|
||||
//excel.SetRangeOuterBorder(rowId + 1, 1, rowId + 1, 3, BorderStyle.Thin);
|
||||
//excel.SetRangeOuterBorder(rowId + 2, 1, rowId + 2, 3, BorderStyle.Thin);
|
||||
|
||||
//excel.MergeCell(rowId + 1, 4, rowId + 1, 6);
|
||||
//excel.MergeCell(rowId + 2, 4, rowId + 2, 6);
|
||||
//excel.SetCellValue(rowId + 1, 4, "公司計畫督導", titleStyleCenter);
|
||||
//excel.SetRangeOuterBorder(rowId + 1, 4, rowId + 1, 6, BorderStyle.Thin);
|
||||
//excel.SetRangeOuterBorder(rowId + 2, 4, rowId + 2, 6, BorderStyle.Thin);
|
||||
|
||||
//excel.MergeCell(rowId + 1, 7, rowId + 1, 8);
|
||||
//excel.MergeCell(rowId + 2, 7, rowId + 2, 8);
|
||||
//excel.SetCellValue(rowId + 1, 7, "公司計畫主持人", titleStyleCenter);
|
||||
//excel.SetRangeOuterBorder(rowId + 1, 7, rowId + 1, 8, BorderStyle.Thin);
|
||||
//excel.SetRangeOuterBorder(rowId + 2, 7, rowId + 2, 8, BorderStyle.Thin);
|
||||
|
||||
//excel.SetRowHeight(rowId + 1, BodyRowHeight);
|
||||
//excel.SetRowHeight(rowId + 2, BodyRowHeight);
|
||||
|
||||
#endregion
|
||||
|
||||
excel.SetColumnWidth(0, 11);
|
||||
excel.SetColumnWidth(1, 4);
|
||||
excel.SetColumnWidth(2, 11);
|
||||
excel.SetColumnWidth(3, 11);
|
||||
excel.SetColumnWidth(4, 11);
|
||||
excel.SetColumnWidth(5, 11);
|
||||
excel.SetColumnWidth(6, 12);
|
||||
excel.SetColumnWidth(7, 12);
|
||||
excel.SetColumnWidth(8, 30);
|
||||
excel.SetColumnWidth(9, 15);
|
||||
|
||||
MemoryStream ms = new MemoryStream();
|
||||
workbook.Write(ms);
|
||||
return ms;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,370 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using NPOI.SS.UserModel;
|
||||
using System.IO;
|
||||
using Wellan.Data;
|
||||
using Wellan.Common;
|
||||
|
||||
/// <summary>
|
||||
/// 出缺勤情形統計表 的摘要描述
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,246 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Web;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using NPOI.SS.UserModel;
|
||||
using NPOI.HSSF.UserModel;
|
||||
using NPOI.HSSF.Util;
|
||||
using System.IO;
|
||||
using NPOI.SS.Util;
|
||||
using Wellan.Data;
|
||||
|
||||
/// <summary>
|
||||
/// 加班申請單
|
||||
/// </summary>
|
||||
public class 加班申請單 : ExcelReportBase
|
||||
{
|
||||
public 加班申請單()
|
||||
{
|
||||
報表名稱 = "加班申請單";
|
||||
}
|
||||
|
||||
public override MemoryStream 產生報表()
|
||||
{
|
||||
BodyRowHeight = 35;
|
||||
|
||||
#region 報表抬頭
|
||||
|
||||
excel.MergeCell(0, 0, 0, 8);
|
||||
excel.SetCellValue(0, 0, String.Format("{0}\r\n承辦{1}\r\n『{2}』\r\n{3}", 公司名稱, 客戶名稱, 專案名稱, 報表名稱), headerStyle);
|
||||
excel.SetCellValue(1, 0, "月份:", titleStyleRightNoBorder);
|
||||
excel.SetCellValue(1, 1, 報表時間.ToString("MM月"), titleStyleLeftNoBorder);
|
||||
excel.SetCellValue(1, 2, "單位:", titleStyleRightNoBorder);
|
||||
excel.SetCellValue(1, 3, WDAC.GetStringValue(資料來源.Tables[0].Rows[0]["站別"]), titleStyleLeftNoBorder);
|
||||
excel.SetCellValue(1, 4, "職稱:", titleStyleRightNoBorder);
|
||||
excel.SetCellValue(1, 5, WDAC.GetStringValue(資料來源.Tables[0].Rows[0]["職稱"]), titleStyleLeftNoBorder);
|
||||
excel.SetCellValue(1, 6, "姓名:", titleStyleRightNoBorder);
|
||||
excel.SetCellValue(1, 7, WDAC.GetStringValue(資料來源.Tables[0].Rows[0]["BPNME"]), titleStyleLeftNoBorder);
|
||||
excel.SetRowHeight(0, HeaderRowHeight * 4);
|
||||
excel.SetRowHeight(1, BodyRowHeight);
|
||||
|
||||
excel.SetCellValue(2, 0, "加班日期", titleStyleCenter);
|
||||
excel.SetCellValue(2, 1, "開始時間", titleStyleCenter);
|
||||
excel.SetCellValue(2, 2, "結束時間", titleStyleCenter);
|
||||
excel.SetCellValue(2, 3, "核定加班時數", titleStyleCenter);
|
||||
excel.SetCellValue(2, 4, "核定加班費時數", titleStyleCenter);
|
||||
excel.SetCellValue(2, 5, "核定補休時數", titleStyleCenter);
|
||||
excel.MergeCell(2, 6, 2, 7);
|
||||
excel.SetCellValue(2, 6, "加班事由", titleStyleCenter);
|
||||
excel.SetRangeOuterBorder(2, 6, 2, 7, BorderStyle.Thin);
|
||||
excel.SetCellValue(2, 8, "備註", titleStyleCenter);
|
||||
excel.SetRowHeight(2, BodyRowHeight * 2);
|
||||
|
||||
#endregion
|
||||
|
||||
#region 報表資料
|
||||
|
||||
int RPTC1_SUM = 0;
|
||||
int RPTC2_SUM = 0;
|
||||
int RPTC3_SUM = 0;
|
||||
int RPTC4_SUM = 0;
|
||||
int RPTC5_SUM = 0;
|
||||
int RPTCT_SUM = 0;
|
||||
int FEE_THIS = 0;
|
||||
int RST_THIS = 0;
|
||||
int RST_SUM = 0;
|
||||
int FEE_SUM = 0;
|
||||
|
||||
int rowId = 3;
|
||||
foreach (DataRow r in 資料來源.Tables[0].Rows)
|
||||
{
|
||||
int RPTCT = WDAC.GetInt32Value(r["RPTCT"]);
|
||||
RPTCT_SUM += RPTCT;
|
||||
|
||||
#region 區分假別統計
|
||||
switch (WDAC.GetStringValue(r["RPTYP"]))
|
||||
{
|
||||
case RPAR_TYPE.T11_非休息日累積補休時數:
|
||||
case RPAR_TYPE.T13_休息日累積補休時數:
|
||||
case RPAR_TYPE.T15_國定假日累積補休時數:
|
||||
case RPAR_TYPE.T17_例假日累積補休時數:
|
||||
RST_SUM += RPTCT;
|
||||
RST_THIS = RPTCT;
|
||||
FEE_THIS = 0;
|
||||
break;
|
||||
default:
|
||||
RPTC1_SUM += WDAC.GetInt32Value(r["RPTC1"]);
|
||||
RPTC2_SUM += WDAC.GetInt32Value(r["RPTC2"]);
|
||||
RPTC3_SUM += WDAC.GetInt32Value(r["RPTC3"]);
|
||||
RPTC4_SUM += WDAC.GetInt32Value(r["RPTC4"]);
|
||||
RPTC5_SUM += WDAC.GetInt32Value(r["RPTC5"]);
|
||||
FEE_SUM += RPTCT;
|
||||
RST_THIS = 0;
|
||||
FEE_THIS = RPTCT;
|
||||
break;
|
||||
}
|
||||
#endregion
|
||||
|
||||
excel.SetCellValue(rowId, 0, WDAC.GetDateTimeValue(r["RPRDT"]).ToString("MM月dd日"), titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 1, WDAC.GetStringValue(r["RPRTM"]), titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 2, WDAC.GetStringValue(r["RPETM"]), titleStyleCenter);
|
||||
|
||||
if (以時分顯示時數)
|
||||
{
|
||||
excel.SetCellValue(rowId, 3, String.Format("{0:00}:{1:00}", RPTCT / 60, RPTCT % 60), titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 4, String.Format("{0:00}:{1:00}", FEE_THIS / 60, FEE_THIS % 60), titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 5, String.Format("{0:00}:{1:00}", RST_THIS / 60, RST_THIS % 60), titleStyleCenter);
|
||||
}
|
||||
else
|
||||
{
|
||||
excel.SetCellValue(rowId, 3, String.Format("{0:00}", RPTCT / 60), titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 4, String.Format("{0:00}", FEE_THIS / 60), titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 5, String.Format("{0:00}", RST_THIS / 60), titleStyleCenter);
|
||||
}
|
||||
|
||||
excel.MergeCell(rowId, 6, rowId, 7);
|
||||
excel.SetCellValue(rowId, 6, WDAC.GetStringValue(r["RPRSN"]), bodyStyleCenterS);
|
||||
excel.SetRangeOuterBorder(rowId, 6, rowId, 7, BorderStyle.Thin);
|
||||
excel.SetCellValue(rowId, 8, WDAC.GetStringValue(r["RPDOC"]), bodyStyleCenterS);
|
||||
excel.SetRowHeight(rowId, BodyRowHeight);
|
||||
rowId++;
|
||||
}
|
||||
|
||||
#region 底下的統計
|
||||
// 左
|
||||
excel.MergeCell(rowId + 2, 0, rowId + 7, 0);
|
||||
excel.MergeCell(rowId + 2, 1, rowId + 7, 1);
|
||||
excel.MergeCell(rowId + 2, 2, rowId + 7, 2);
|
||||
excel.SetCellValue(rowId + 2, 0, "總加班時數:", titleStyleRightNoBorder);
|
||||
if (以時分顯示時數)
|
||||
excel.SetCellValue(rowId + 2, 1, String.Format("{0:00}:{1:00}", RPTCT_SUM / 60, RPTCT_SUM % 60), titleStyleCenterNoBorder);
|
||||
else
|
||||
excel.SetCellValue(rowId + 2, 1, String.Format("{0:00}", RPTCT_SUM / 60), titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(rowId + 2, 2, "hrs", titleStyleLeftNoBorder);
|
||||
excel.SetRangeOuterBorder(rowId + 2, 0, rowId + 7, 2, BorderStyle.Thin);
|
||||
|
||||
// 中
|
||||
excel.SetCellValue(rowId + 2, 3, "申請加班費:", titleStyleLeftNoBorder);
|
||||
excel.SetCellValue(rowId + 7, 3, "申請補休:", titleStyleLeftNoBorder);
|
||||
if (以時分顯示時數)
|
||||
{
|
||||
excel.SetCellValue(rowId + 2, 4, String.Format("{0:00}:{1:00}", FEE_SUM / 60, FEE_SUM % 60), titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(rowId + 7, 4, String.Format("{0:00}:{1:00}", RST_SUM / 60, RST_SUM % 60), titleStyleCenterNoBorder);
|
||||
}
|
||||
else
|
||||
{
|
||||
excel.SetCellValue(rowId + 2, 4, String.Format("{0:00}", FEE_SUM / 60), titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(rowId + 7, 4, String.Format("{0:00}", RST_SUM / 60), titleStyleCenterNoBorder);
|
||||
}
|
||||
excel.SetCellValue(rowId + 2, 5, "hrs", titleStyleLeftNoBorder);
|
||||
excel.SetCellValue(rowId + 7, 5, "hrs", titleStyleLeftNoBorder);
|
||||
excel.SetRangeOuterBorder(rowId + 2, 3, rowId + 6, 5, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(rowId + 7, 3, rowId + 7, 5, BorderStyle.Thin);
|
||||
|
||||
// 右
|
||||
excel.SetCellValue(rowId + 2, 6, "一又三分之一:", titleStyleLeftNoBorder);
|
||||
excel.SetCellValue(rowId + 3, 6, "一又三分之二:", titleStyleLeftNoBorder);
|
||||
excel.SetCellValue(rowId + 4, 6, "國定假日:", titleStyleLeftNoBorder);
|
||||
excel.SetCellValue(rowId + 5, 6, "休息日再延長:", titleStyleLeftNoBorder);
|
||||
excel.SetCellValue(rowId + 6, 6, "例假日再延長:", titleStyleLeftNoBorder);
|
||||
if (以時分顯示時數)
|
||||
{
|
||||
excel.SetCellValue(rowId + 2, 7, String.Format("{0:00}:{1:00}", RPTC1_SUM / 60, RPTC1_SUM % 60), titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(rowId + 3, 7, String.Format("{0:00}:{1:00}", RPTC2_SUM / 60, RPTC2_SUM % 60), titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(rowId + 4, 7, String.Format("{0:00}:{1:00}", RPTC3_SUM / 60, RPTC3_SUM % 60), titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(rowId + 5, 7, String.Format("{0:00}:{1:00}", RPTC4_SUM / 60, RPTC4_SUM % 60), titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(rowId + 6, 7, String.Format("{0:00}:{1:00}", RPTC5_SUM / 60, RPTC5_SUM % 60), titleStyleCenterNoBorder);
|
||||
}
|
||||
else
|
||||
{
|
||||
excel.SetCellValue(rowId + 2, 7, String.Format("{0:00}", RPTC1_SUM / 60), titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(rowId + 3, 7, String.Format("{0:00}", RPTC2_SUM / 60), titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(rowId + 4, 7, String.Format("{0:00}", RPTC3_SUM / 60), titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(rowId + 5, 7, String.Format("{0:00}", RPTC4_SUM / 60), titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(rowId + 6, 7, String.Format("{0:00}", RPTC5_SUM / 60), titleStyleCenterNoBorder);
|
||||
}
|
||||
excel.SetCellValue(rowId + 2, 8, "hrs", titleStyleLeftNoBorder);
|
||||
excel.SetCellValue(rowId + 3, 8, "hrs", titleStyleLeftNoBorder);
|
||||
excel.SetCellValue(rowId + 4, 8, "hrs", titleStyleLeftNoBorder);
|
||||
excel.SetCellValue(rowId + 5, 8, "hrs", titleStyleLeftNoBorder);
|
||||
excel.SetCellValue(rowId + 6, 8, "hrs", titleStyleLeftNoBorder);
|
||||
|
||||
excel.SetRangeOuterBorder(rowId + 2, 6, rowId + 2, 8, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(rowId + 3, 6, rowId + 3, 8, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(rowId + 4, 6, rowId + 4, 8, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(rowId + 5, 6, rowId + 5, 8, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(rowId + 6, 6, rowId + 6, 8, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(rowId + 7, 6, rowId + 7, 8, BorderStyle.Thin);
|
||||
|
||||
excel.SetRowHeight(rowId + 2, BodyRowHeight);
|
||||
excel.SetRowHeight(rowId + 3, BodyRowHeight);
|
||||
excel.SetRowHeight(rowId + 4, BodyRowHeight);
|
||||
excel.SetRowHeight(rowId + 5, BodyRowHeight);
|
||||
excel.SetRowHeight(rowId + 6, BodyRowHeight);
|
||||
excel.SetRowHeight(rowId + 7, BodyRowHeight);
|
||||
|
||||
rowId += 7;
|
||||
#endregion
|
||||
|
||||
#region 表尾批示
|
||||
|
||||
//excel.MergeCell(rowId + 7, 0, rowId + 7, 8);
|
||||
//excel.SetCellValue(rowId + 7, 0, "申請人: 計畫督導: 人事單位:", titleStyleLeftNoBorder);
|
||||
//excel.SetRowHeight(rowId + 7, BodyRowHeight);
|
||||
|
||||
//excel.MergeCell(rowId + 2, 0, rowId + 2, 2);
|
||||
//excel.MergeCell(rowId + 3, 0, rowId + 3, 2);
|
||||
//excel.SetCellValue(rowId + 2, 0, "申請人", titleStyleCenter);
|
||||
//excel.SetRangeOuterBorder(rowId + 2, 0, rowId + 2, 2, BorderStyle.Thin);
|
||||
//excel.SetRangeOuterBorder(rowId + 3, 0, rowId + 3, 2, BorderStyle.Thin);
|
||||
|
||||
//excel.MergeCell(rowId + 2, 3, rowId + 2, 5);
|
||||
//excel.MergeCell(rowId + 3, 3, rowId + 3, 5);
|
||||
//excel.SetCellValue(rowId + 2, 3, "公司計畫督導", titleStyleCenter);
|
||||
//excel.SetRangeOuterBorder(rowId + 2, 3, rowId + 2, 5, BorderStyle.Thin);
|
||||
//excel.SetRangeOuterBorder(rowId + 3, 3, rowId + 3, 5, BorderStyle.Thin);
|
||||
|
||||
//excel.MergeCell(rowId + 2, 6, rowId + 2, 8);
|
||||
//excel.MergeCell(rowId + 3, 6, rowId + 3, 8);
|
||||
//excel.SetCellValue(rowId + 2, 6, "公司計畫主持人", titleStyleCenter);
|
||||
//excel.SetRangeOuterBorder(rowId + 2, 6, rowId + 2, 8, BorderStyle.Thin);
|
||||
//excel.SetRangeOuterBorder(rowId + 3, 6, rowId + 3, 8, BorderStyle.Thin);
|
||||
|
||||
//excel.SetRowHeight(rowId + 2, BodyRowHeight);
|
||||
//excel.SetRowHeight(rowId + 3, BodyRowHeight);
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
excel.SetColumnWidth(0, 15);
|
||||
excel.SetColumnWidth(1, 12);
|
||||
excel.SetColumnWidth(2, 12);
|
||||
excel.SetColumnWidth(3, 15);
|
||||
excel.SetColumnWidth(4, 15);
|
||||
excel.SetColumnWidth(5, 15);
|
||||
excel.SetColumnWidth(6, 15);
|
||||
excel.SetColumnWidth(7, 15);
|
||||
excel.SetColumnWidth(8, 15);
|
||||
|
||||
MemoryStream ms = new MemoryStream();
|
||||
workbook.Write(ms);
|
||||
return ms;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,491 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Web;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using NPOI.SS.UserModel;
|
||||
using NPOI.HSSF.UserModel;
|
||||
using NPOI.HSSF.Util;
|
||||
using System.IO;
|
||||
using NPOI.SS.Util;
|
||||
using Wellan.Common;
|
||||
using Wellan.Data;
|
||||
using System.Linq;
|
||||
using Microsoft.Win32;
|
||||
|
||||
/// <summary>
|
||||
/// 加班費印領清冊 的摘要描述
|
||||
/// </summary>
|
||||
public class 加班費印領清冊 : ExcelReportBase
|
||||
{
|
||||
public 加班費印領清冊()
|
||||
{
|
||||
報表名稱 = "加班費明細表";
|
||||
}
|
||||
|
||||
private int r = 2;
|
||||
private DataRow[] data;
|
||||
private int 加班費加總 = 0;
|
||||
private int bodyBeginRow, dataBeginRow;
|
||||
|
||||
public override MemoryStream 產生報表()
|
||||
{
|
||||
// 只要領加班費的紀錄
|
||||
data = 資料來源.Tables[0].Select(
|
||||
string.Format("RPTYP = '{0}' OR RPTYP = '{1}' OR RPTYP = '{2}' OR RPTYP = '{3}'",
|
||||
RPAR_TYPE.T12_非休息日請領加班費,
|
||||
RPAR_TYPE.T14_休息日請領加班費,
|
||||
RPAR_TYPE.T16_國定假日請領加班費,
|
||||
RPAR_TYPE.T18_例假日請領加班費) ,
|
||||
"RPRDT");
|
||||
|
||||
foreach (DataRow r in data)
|
||||
{
|
||||
加班費加總 += WDAC.GetInt32Value(r["RPAC1"])
|
||||
+ WDAC.GetInt32Value(r["RPAC2"])
|
||||
+ WDAC.GetInt32Value(r["RPAC3"])
|
||||
+ WDAC.GetInt32Value(r["RPAC4"])
|
||||
+ WDAC.GetInt32Value(r["RPAC5"]);
|
||||
}
|
||||
|
||||
產生抬頭();
|
||||
產生表身();
|
||||
產生結尾();
|
||||
設定欄寬及列印範圍();
|
||||
|
||||
MemoryStream ms = new MemoryStream();
|
||||
workbook.Write(ms);
|
||||
return ms;
|
||||
}
|
||||
|
||||
private void 產生抬頭()
|
||||
{
|
||||
excel.MergeCell(r, 0, r, 13);
|
||||
excel.SetCellValue(r, 0, 公司名稱, headerStyle);
|
||||
excel.SetRowHeight(r, 30);
|
||||
r++;
|
||||
|
||||
excel.MergeCell(r, 0, r, 13);
|
||||
excel.SetCellValue(r, 0, 專案名稱, headerStyle);
|
||||
excel.SetRowHeight(r, 30);
|
||||
r++;
|
||||
|
||||
excel.MergeCell(r, 0, r, 13);
|
||||
excel.SetCellValue(r, 0, 報表名稱, headerStyle);
|
||||
excel.SetRowHeight(r, 30);
|
||||
r++;
|
||||
|
||||
excel.MergeCell(r, 0, r, 13);
|
||||
excel.SetCellValue(r, 0, "金額(此欄填寫數字)", bodyStyleCenter);
|
||||
excel.SetRowHeight(r, 20);
|
||||
r++;
|
||||
|
||||
excel.MergeCell(r, 0, r, 3);
|
||||
excel.SetCellValue(r, 0, "萬", bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r, 0, r, 3, BorderStyle.Thin);
|
||||
excel.MergeCell(r, 4, r, 6);
|
||||
excel.SetCellValue(r, 4, "仟", bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r, 4, r, 6, BorderStyle.Thin);
|
||||
excel.MergeCell(r, 7, r, 7);
|
||||
excel.SetCellValue(r, 7, "佰", bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r, 7, r, 7, BorderStyle.Thin);
|
||||
excel.MergeCell(r, 8, r, 10);
|
||||
excel.SetCellValue(r, 8, "拾", bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r, 8, r, 10, BorderStyle.Thin);
|
||||
excel.MergeCell(r, 11, r, 13);
|
||||
excel.SetCellValue(r, 11, "元", bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r, 11, r, 13, BorderStyle.Thin);
|
||||
excel.SetRowHeight(r, 30);
|
||||
r++;
|
||||
|
||||
string s加班費加總 = String.Format("{0:00000}", 加班費加總) + "00000";
|
||||
excel.MergeCell(r, 0, r, 3);
|
||||
excel.SetCellValue(r, 0, s加班費加總[0].ToString(), bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r, 0, r, 3, BorderStyle.Thin);
|
||||
excel.MergeCell(r, 4, r, 6);
|
||||
excel.SetCellValue(r, 4, s加班費加總[1].ToString(), bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r, 4, r, 6, BorderStyle.Thin);
|
||||
excel.MergeCell(r, 7, r, 7);
|
||||
excel.SetCellValue(r, 7, s加班費加總[2].ToString(), bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r, 7, r, 7, BorderStyle.Thin);
|
||||
excel.MergeCell(r, 8, r, 10);
|
||||
excel.SetCellValue(r, 8, s加班費加總[3].ToString(), bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r, 8, r, 10, BorderStyle.Thin);
|
||||
excel.MergeCell(r, 11, r, 13);
|
||||
excel.SetCellValue(r, 11, s加班費加總[4].ToString(), bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r, 11, r, 13, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(r - 2, 0, r, 13, BorderStyle.Thick);
|
||||
excel.SetRowHeight(r, 25);
|
||||
r++;
|
||||
|
||||
excel.SetCellValue(r, 11, String.Format("{0:yyyy}年度", 報表時間, WGuard1.TaiwanCulture), bodyStyleRightNoBorder);
|
||||
excel.SetCellValue(r, 12, String.Format("{0:MM}", 報表時間), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(r, 13, "月", bodyStyleLeftNoBorder);
|
||||
excel.SetRowHeight(r, 25);
|
||||
r++;
|
||||
|
||||
bodyBeginRow = r;
|
||||
excel.MergeCell(r, 0, r, 1);
|
||||
excel.SetCellValue(r, 0, "姓名", bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r, 0, r, 1, BorderStyle.Thin);
|
||||
excel.MergeCell(r, 2, r, 5);
|
||||
excel.SetCellValue(r, 2, WDAC.GetStringValue(資料來源.Tables[0].Rows[0]["BPNME"]), bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r, 2, r, 5, BorderStyle.Thin);
|
||||
excel.SetCellValue(r, 6, "單位", bodyStyleCenter);
|
||||
excel.MergeCell(r, 7, r, 10);
|
||||
excel.SetCellValue(r, 7, WDAC.GetStringValue(資料來源.Tables[0].Rows[0]["站別"]), bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r, 7, r, 10, BorderStyle.Thin);
|
||||
excel.SetCellValue(r, 11, "職稱", bodyStyleCenter);
|
||||
excel.MergeCell(r, 12, r, 13);
|
||||
excel.SetCellValue(r, 12, WDAC.GetStringValue(資料來源.Tables[0].Rows[0]["職稱"]), bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r, 12, r, 13, BorderStyle.Thin);
|
||||
excel.SetRowHeight(r, 35);
|
||||
r++;
|
||||
|
||||
excel.MergeCell(r, 0, r, 6);
|
||||
excel.SetCellValue(r, 0, "加班日及起迄時間", bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r, 0, r, 6, BorderStyle.Thin);
|
||||
excel.MergeCell(r, 7, r + 1, 8);
|
||||
excel.SetCellValue(r, 7, "加班時數", bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r, 7, r + 1, 8, BorderStyle.Thin);
|
||||
excel.MergeCell(r, 9, r + 1, 10);
|
||||
excel.SetCellValue(r, 9, "加班費\n金額", bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r, 9, r + 1, 10, BorderStyle.Thin);
|
||||
//excel.MergeCell(r, 11, r + 1, 11);
|
||||
//excel.SetCellValue(r, 11, "蓋章", bodyStyleCenter);
|
||||
//excel.SetRangeOuterBorder(r, 11, r + 1, 11, BorderStyle.Thin);
|
||||
excel.MergeCell(r, 11, r + 1, 13);
|
||||
excel.SetCellValue(r, 11, "備註", bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r, 11, r + 1, 13, BorderStyle.Thin);
|
||||
|
||||
excel.SetCellValue(r + 1, 0, "月", bodyStyleCenter);
|
||||
excel.SetCellValue(r + 1, 1, "日", bodyStyleCenter);
|
||||
excel.MergeCell(r + 1, 2, r + 1, 3);
|
||||
excel.SetCellValue(r + 1, 2, "起", bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r + 1, 2, r + 1, 3, BorderStyle.Thin);
|
||||
excel.MergeCell(r + 1, 4, r + 1, 5);
|
||||
excel.SetCellValue(r + 1, 4, "至", bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r + 1, 4, r + 1, 5, BorderStyle.Thin);
|
||||
excel.SetCellValue(r + 1, 6, "迄", bodyStyleCenter);
|
||||
|
||||
// 畫雙線
|
||||
excel.SetRangeOuterBorder(r - 1, 0, r - 1, 13, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Double, BorderStyle.Thin);
|
||||
excel.SetRowHeight(r, 25);
|
||||
excel.SetRowHeight(r + 1, 25);
|
||||
r += 2;
|
||||
dataBeginRow = r;
|
||||
}
|
||||
|
||||
private void 產生表身()
|
||||
{
|
||||
List<OverTimeItem> oneDayItems = new List<OverTimeItem>();
|
||||
|
||||
TimeCalc timeCalc = new TimeCalc();
|
||||
|
||||
foreach (DataRow row in data)
|
||||
{
|
||||
timeCalc.Init(WDAC.GetStringValue(row["RPNUM"]), WDAC.GetDateTimeValue(row["RPRDT"]));
|
||||
|
||||
int rptc1, rptc2, rptc3, rptc4, rptc5, rpac1, rpac2, rpac3, rpac4, rpac5;
|
||||
string rptyp;
|
||||
rptc1 = WDAC.GetInt32Value(row["RPTC1"]);
|
||||
rptc2 = WDAC.GetInt32Value(row["RPTC2"]);
|
||||
rptc3 = WDAC.GetInt32Value(row["RPTC3"]);
|
||||
rptc4 = WDAC.GetInt32Value(row["RPTC4"]);
|
||||
rptc5 = WDAC.GetInt32Value(row["RPTC5"]);
|
||||
rpac1 = WDAC.GetInt32Value(row["RPAC1"]);
|
||||
rpac2 = WDAC.GetInt32Value(row["RPAC2"]);
|
||||
rpac3 = WDAC.GetInt32Value(row["RPAC3"]);
|
||||
rpac4 = WDAC.GetInt32Value(row["RPAC4"]);
|
||||
rpac5 = WDAC.GetInt32Value(row["RPAC5"]);
|
||||
rptyp = WDAC.GetStringValue(row["RPTYP"]);
|
||||
|
||||
oneDayItems.Clear();
|
||||
string beginTime = WDAC.GetStringValue(row["RPRTM"]);
|
||||
|
||||
switch (rptyp)
|
||||
{
|
||||
case RPAR_TYPE.T12_非休息日請領加班費:
|
||||
case RPAR_TYPE.T14_休息日請領加班費:
|
||||
case RPAR_TYPE.T18_例假日請領加班費:
|
||||
var skiprest = rptyp != RPAR_TYPE.T12_非休息日請領加班費;
|
||||
if (rptc1 > 0)
|
||||
{
|
||||
var endtime = TimeAddMinutes(beginTime, rptc1, timeCalc.午休開始, timeCalc.午休結束, skiprest);
|
||||
oneDayItems.Add(new OverTimeItem()
|
||||
{
|
||||
BeginTime = beginTime,
|
||||
EndTime = endtime,
|
||||
TimeName = "一又三分之一",
|
||||
Hours = (double)rptc1 / 60D,
|
||||
Amount = rpac1
|
||||
});
|
||||
beginTime = endtime;
|
||||
}
|
||||
if (rptc2 > 0)
|
||||
{
|
||||
var endtime = TimeAddMinutes(beginTime, rptc2, timeCalc.午休開始, timeCalc.午休結束, skiprest);
|
||||
oneDayItems.Add(new OverTimeItem()
|
||||
{
|
||||
BeginTime = beginTime,
|
||||
EndTime = endtime,
|
||||
TimeName = "一又三分之二",
|
||||
Hours = (double)rptc2 / 60D,
|
||||
Amount = rpac2
|
||||
});
|
||||
beginTime = endtime;
|
||||
}
|
||||
if (rptc3 > 0)
|
||||
{
|
||||
var endtime = TimeAddMinutes(beginTime, rptc3, timeCalc.午休開始, timeCalc.午休結束, skiprest);
|
||||
oneDayItems.Add(new OverTimeItem()
|
||||
{
|
||||
BeginTime = beginTime,
|
||||
EndTime = endtime,
|
||||
TimeName = "國定假日",
|
||||
Hours = (double)rptc3 / 60D,
|
||||
Amount = rpac3
|
||||
});
|
||||
beginTime = endtime;
|
||||
}
|
||||
if (rptc4 > 0)
|
||||
{
|
||||
var endtime = TimeAddMinutes(beginTime, rptc4, timeCalc.午休開始, timeCalc.午休結束, skiprest);
|
||||
oneDayItems.Add(new OverTimeItem()
|
||||
{
|
||||
BeginTime = beginTime,
|
||||
EndTime = endtime,
|
||||
TimeName = "休息日再延長",
|
||||
Hours = (double)rptc4 / 60D,
|
||||
Amount = rpac4
|
||||
});
|
||||
beginTime = endtime;
|
||||
}
|
||||
if (rptc5 > 0)
|
||||
{
|
||||
var endtime = TimeAddMinutes(beginTime, rptc5, timeCalc.午休開始, timeCalc.午休結束, skiprest);
|
||||
oneDayItems.Add(new OverTimeItem()
|
||||
{
|
||||
BeginTime = beginTime,
|
||||
EndTime = endtime,
|
||||
TimeName = "例假日再延長",
|
||||
Hours = (double)rptc5 / 60D,
|
||||
Amount = rpac5
|
||||
});
|
||||
beginTime = endtime;
|
||||
}
|
||||
break;
|
||||
case RPAR_TYPE.T16_國定假日請領加班費:
|
||||
if (rptc3 > 0)
|
||||
{
|
||||
var endtime = TimeAddMinutes(beginTime, rptc3, timeCalc.午休開始, timeCalc.午休結束, false);
|
||||
oneDayItems.Add(new OverTimeItem()
|
||||
{
|
||||
BeginTime = beginTime,
|
||||
EndTime = endtime,
|
||||
TimeName = "國定假日",
|
||||
Hours = (double)rptc3 / 60D,
|
||||
Amount = rpac3
|
||||
});
|
||||
beginTime = endtime;
|
||||
}
|
||||
if (rptc1 > 0)
|
||||
{
|
||||
var endtime = TimeAddMinutes(beginTime, rptc1, timeCalc.午休開始, timeCalc.午休結束, false);
|
||||
oneDayItems.Add(new OverTimeItem()
|
||||
{
|
||||
BeginTime = beginTime,
|
||||
EndTime = endtime,
|
||||
TimeName = "國定假日延長(9-10)",
|
||||
Hours = (double)rptc1 / 60D,
|
||||
Amount = rpac1
|
||||
});
|
||||
beginTime = endtime;
|
||||
}
|
||||
if (rptc2 > 0)
|
||||
{
|
||||
var endtime = TimeAddMinutes(beginTime, rptc2, timeCalc.午休開始, timeCalc.午休結束, false);
|
||||
oneDayItems.Add(new OverTimeItem()
|
||||
{
|
||||
BeginTime = beginTime,
|
||||
EndTime = endtime,
|
||||
TimeName = "國定假日延長(11-12)",
|
||||
Hours = (double)rptc2 / 60D,
|
||||
Amount = rpac2
|
||||
});
|
||||
beginTime = endtime;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
for (int i = 0; i < oneDayItems.Count; i++)
|
||||
{
|
||||
OverTimeItem item = oneDayItems[i];
|
||||
|
||||
excel.SetCellValue(r + i, 0, String.Format("{0:MM}", row["RPRDT"]), bodyStyleCenter);
|
||||
excel.SetCellValue(r + i, 1, String.Format("{0:dd}", row["RPRDT"]), bodyStyleCenter);
|
||||
|
||||
excel.MergeCell(r + i, 11, r + i, 13);
|
||||
excel.SetCellValue(r + i, 11, String.Format("{0}", row["RPDOC"]), bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r + i, 11, r + i, 13, BorderStyle.Thin);
|
||||
|
||||
excel.MergeCell(r + i, 2, r + i, 3);
|
||||
excel.SetCellValue(r + i, 2, item.BeginTime, bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r + i, 2, r + i, 3, BorderStyle.Thin);
|
||||
|
||||
excel.MergeCell(r + i, 4, r + i, 5);
|
||||
excel.SetCellValue(r + i, 4, "~", bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r + i, 4, r + i, 5, BorderStyle.Thin);
|
||||
|
||||
excel.SetCellValue(r + i, 6, item.EndTime, bodyStyleCenter);
|
||||
|
||||
excel.SetCellValue(r + i, 7, item.TimeName, bodyStyleCenter);
|
||||
|
||||
excel.SetCellValue(r + i, 8, item.Hours, bodyStyleCenter);
|
||||
|
||||
excel.MergeCell(r + i, 9, r + i, 10);
|
||||
excel.SetCellValue(r + i, 9, item.Amount, bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r + i, 9, r + i, 10, BorderStyle.Thin);
|
||||
|
||||
excel.SetRowHeight(r + i, 35);
|
||||
}
|
||||
|
||||
r += oneDayItems.Count;
|
||||
|
||||
}
|
||||
|
||||
// 蓋章
|
||||
//excel.MergeCell(dataBeginRow, 11, r - 1, 11);
|
||||
//excel.SetCellValue(dataBeginRow, 11, "", bodyStyleCenter);
|
||||
//excel.SetRangeOuterBorder(dataBeginRow, 11, r - 1, 11, BorderStyle.Thin);
|
||||
|
||||
// 合計
|
||||
excel.SetCellValue(r, 6, "合計", bodyStyleCenter);
|
||||
excel.SetCellFormula(r, 7, String.Format("SUM({0}:{1})", excel.RCtoA1(dataBeginRow, 8), excel.RCtoA1(r - 1, 8)), bodyStyleCenter);
|
||||
excel.SetCellValue(r, 8, "小時", bodyStyleCenter);
|
||||
excel.SetCellFormula(r, 9, String.Format("SUM({0}:{1})", excel.RCtoA1(dataBeginRow, 9), excel.RCtoA1(r - 1, 9)), bodyStyleCenter);
|
||||
excel.SetCellValue(r, 10, "元", bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r, 7, r, 7, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.None);
|
||||
excel.SetRangeOuterBorder(r, 8, r, 8, BorderStyle.Thin, BorderStyle.None, BorderStyle.Thin, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(r, 9, r, 9, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.None);
|
||||
excel.SetRangeOuterBorder(r, 10, r, 10, BorderStyle.Thin, BorderStyle.None, BorderStyle.Thin, BorderStyle.Thin);
|
||||
excel.SetRowHeight(r, 25);
|
||||
r++;
|
||||
}
|
||||
|
||||
private void 產生結尾()
|
||||
{
|
||||
excel.MergeCell(r, 0, r, 3);
|
||||
excel.SetCellValue(r, 0, "茲收到加班費新台幣", bodyStyleCenter);
|
||||
excel.MergeCell(r, 4, r, 9);
|
||||
excel.SetCellValue(r, 4, WGuard1.WNTSA(加班費加總, "", true), bodyStyleRight);
|
||||
excel.MergeCell(r, 10, r, 13);
|
||||
excel.SetCellValue(r, 10, "此 據 (金額請大寫)", bodyStyleCenter);
|
||||
excel.SetRowHeight(r, 30);
|
||||
excel.SetRangeOuterBorder(r, 0, r, 3, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.None);
|
||||
excel.SetRangeOuterBorder(r, 4, r, 9, BorderStyle.Thin, BorderStyle.None, BorderStyle.Thin, BorderStyle.None);
|
||||
excel.SetRangeOuterBorder(r, 10, r, 13, BorderStyle.Thin, BorderStyle.None, BorderStyle.Thin, BorderStyle.Thin);
|
||||
r++;
|
||||
|
||||
excel.MergeCell(r, 0, r, 5);
|
||||
excel.SetCellValue(r, 0, "申請人", bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r, 0, r, 5, BorderStyle.Thin);
|
||||
excel.MergeCell(r, 6, r, 9);
|
||||
excel.SetCellValue(r, 6, "計劃督導", bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r, 6, r, 9, BorderStyle.Thin);
|
||||
excel.MergeCell(r, 10, r, 13);
|
||||
excel.SetCellValue(r, 10, "計劃主持人", bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r, 10, r, 13, BorderStyle.Thin);
|
||||
excel.SetRowHeight(r, 30);
|
||||
r++;
|
||||
|
||||
excel.MergeCell(r, 0, r, 5);
|
||||
excel.SetCellValue(r, 0, "", bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r, 0, r, 5, BorderStyle.Thin);
|
||||
excel.MergeCell(r, 6, r, 9);
|
||||
excel.SetCellValue(r, 6, "", bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r, 6, r, 9, BorderStyle.Thin);
|
||||
excel.MergeCell(r, 10, r, 13);
|
||||
excel.SetCellValue(r, 10, "", bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r, 10, r, 13, BorderStyle.Thin);
|
||||
excel.SetRowHeight(r, 50);
|
||||
|
||||
excel.SetRangeOuterBorder(bodyBeginRow, 0, r, 13, BorderStyle.Thick);
|
||||
}
|
||||
|
||||
private void 設定欄寬及列印範圍()
|
||||
{
|
||||
excel.SetColumnWidth(0, 6);
|
||||
excel.SetColumnWidth(1, 6);
|
||||
excel.SetColumnWidth(2, 2);
|
||||
excel.SetColumnWidth(3, 7);
|
||||
excel.SetColumnWidth(4, 3);
|
||||
excel.SetColumnWidth(5, 5);
|
||||
excel.SetColumnWidth(6, 11);
|
||||
excel.SetColumnWidth(7, 18);
|
||||
excel.SetColumnWidth(8, 7);
|
||||
excel.SetColumnWidth(9, 8);
|
||||
excel.SetColumnWidth(10, 3);
|
||||
excel.SetColumnWidth(11, 11);
|
||||
excel.SetColumnWidth(12, 7);
|
||||
excel.SetColumnWidth(13, 8);
|
||||
}
|
||||
|
||||
private string TimeAddMinutes(string time, int addMinutes, string restBegin, string restEnd, bool skipRest)
|
||||
{
|
||||
int restBeginHour = 0;
|
||||
int restBeginMin = 0;
|
||||
int restEndHour = 0;
|
||||
int restEndMin = 0;
|
||||
int restBeginTime = 0;
|
||||
int restEndTime = 0;
|
||||
if (!string.IsNullOrEmpty(restBegin))
|
||||
{
|
||||
string[] tp1 = restBegin.Split(':');
|
||||
if (int.TryParse(tp1[0], out restBeginHour) && int.TryParse(tp1[1], out restBeginMin))
|
||||
restBeginTime = restBeginHour * 60 + restBeginMin;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(restEnd))
|
||||
{
|
||||
string[] tp1 = restEnd.Split(':');
|
||||
if (int.TryParse(tp1[0], out restEndHour) && int.TryParse(tp1[1], out restEndMin))
|
||||
restEndTime = restEndHour * 60 + restEndMin;
|
||||
}
|
||||
|
||||
string[] timepart = time.Split(':');
|
||||
int hour, min;
|
||||
if (int.TryParse(timepart[0], out hour) && int.TryParse(timepart[1], out min))
|
||||
{
|
||||
int beginTime = hour * 60 + min;
|
||||
int extraAddMinutes = 0;
|
||||
|
||||
if (beginTime <= restBeginTime && beginTime + addMinutes >= restBeginTime)
|
||||
{
|
||||
int tempEndTime = beginTime + addMinutes;
|
||||
// 跨越中午休息時間,要摳掉
|
||||
if (tempEndTime >= restEndTime && skipRest)
|
||||
extraAddMinutes = restEndTime - restBeginTime;
|
||||
// 跨進,但未跨越,不要摳掉
|
||||
if (tempEndTime < restEndTime)
|
||||
// extraAddMinutes = (int)Math.Truncate((restEndTime - tempEndTime).TotalMinutes);
|
||||
extraAddMinutes = 0;
|
||||
}
|
||||
|
||||
var result = beginTime + addMinutes + extraAddMinutes;
|
||||
return string.Format("{0:00}:{1:00}", (int)Math.Truncate((double)result / (double)60), result % 60);
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class OverTimeItem
|
||||
{
|
||||
public string BeginTime { get; set; }
|
||||
public string EndTime { get; set; }
|
||||
public string TimeName { get; set; }
|
||||
public double Hours { get; set; }
|
||||
public double Amount { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using NPOI.SS.UserModel;
|
||||
using System.IO;
|
||||
using Wellan.Data;
|
||||
using Wellan.Common;
|
||||
|
||||
/// <summary>
|
||||
/// 加班費明細 的摘要描述
|
||||
/// </summary>
|
||||
public class 加班費明細 : ExcelReportBase
|
||||
{
|
||||
public 加班費明細()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
base.Init();
|
||||
titleStyleCenterNoBorder.SetFont(bodyFont);
|
||||
bodyStyleCenterNoBorder.SetFont(bodyFont);
|
||||
bodyStyleLeftNoBorder.SetFont(bodyFont8PT);
|
||||
bodyNumberStyleNoBorder.SetFont(bodyFont);
|
||||
titleStyleRightNoBorder.SetFont(bodyFont);
|
||||
titleStyleLeftNoBorder.SetFont(bodyFont);
|
||||
}
|
||||
|
||||
public override MemoryStream 產生報表()
|
||||
{
|
||||
#region 報表抬頭
|
||||
|
||||
var row = 0;
|
||||
|
||||
excel.MergeCell(row, 0, row, 15, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, 公司名稱, headerStyle);
|
||||
excel.SetRowHeight(row, 20);
|
||||
row++;
|
||||
excel.MergeCell(row, 0, row, 15, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, string.Format("承辦{0}", 客戶名稱), headerStyle);
|
||||
excel.SetRowHeight(row, 20);
|
||||
row++;
|
||||
excel.MergeCell(row, 0, row, 15, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, string.Format("『{0}』", 專案名稱), headerStyle);
|
||||
excel.SetRowHeight(row, 20);
|
||||
row++;
|
||||
excel.MergeCell(row, 0, row, 15, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, string.Format("{0}【{1}{2}】", 報表名稱, 年度, 月份), headerStyle);
|
||||
excel.SetRowHeight(row, 20);
|
||||
row++;
|
||||
|
||||
excel.MergeCell(row, 4, row, 14, BorderStyle.None);
|
||||
excel.SetCellValue(row, 4, "加班時數 / 金額", 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, string.Format("前段*{0}", 報表參數["前段"]), titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 5, "小計", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 6, string.Format("後段*{0}", 報表參數["後段"]), titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 7, "小計", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 8, string.Format("休息日再延長*{0}", 報表參數["休息日延長"]), titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 9, "小計", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 10, string.Format("假日*{0}", 報表參數["假日"]), titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 11, "小計", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 12, string.Format("例假日再延長*{0}", 報表參數["例假日延長"]), titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 13, "小計", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 14, "請領金額", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 15, "備註", titleStyleCenterNoBorder);
|
||||
excel.SetRowHeight(row, 24);
|
||||
row++;
|
||||
|
||||
#endregion
|
||||
|
||||
#region 報表資料
|
||||
|
||||
int beginRow = row;
|
||||
int serial = 1;
|
||||
int SST01_SUM = 0;
|
||||
int SST02_SUM = 0;
|
||||
int SST03_SUM = 0;
|
||||
int SST21_SUM = 0;
|
||||
int SST22_SUM = 0;
|
||||
|
||||
foreach (DataRow r in 資料來源.Tables[0].Rows)
|
||||
{
|
||||
var 月薪 = WDAC.GetInt32Value(r["SSP00"]) + WDAC.GetInt32Value(r["SSP02"]);
|
||||
var 加班費合計 = WDAC.GetInt32Value(r["SSP06"])
|
||||
+ WDAC.GetInt32Value(r["SSP07"])
|
||||
+ WDAC.GetInt32Value(r["SSP08"])
|
||||
+ WDAC.GetInt32Value(r["SSP13"])
|
||||
+ WDAC.GetInt32Value(r["SSP14"]);
|
||||
|
||||
excel.SetCellValue(row, 0, serial, bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 1, WDAC.GetStringValue(r["SSBRHX"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 2, WDAC.GetStringValue(r["BPNME"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 3, 月薪, bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 5, WDAC.GetInt32Value(r["SSP06"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 7, WDAC.GetInt32Value(r["SSP07"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 9, WDAC.GetInt32Value(r["SSP13"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 11, WDAC.GetInt32Value(r["SSP08"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 13, WDAC.GetInt32Value(r["SSP14"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 14, 加班費合計, bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 15, WDAC.GetStringValue(r["SSC02"]), bodyStyleLeftNoBorder);
|
||||
|
||||
if (以時分顯示時數)
|
||||
{
|
||||
excel.SetCellValue(row, 4, string.Format("{0:#00}:{1:00}", r["SST01"], r["SST01M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 6, string.Format("{0:#00}:{1:00}", r["SST02"], r["SST02M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 8, string.Format("{0:#00}:{1:00}", r["SST21"], r["SST21M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 10, string.Format("{0:#00}:{1:00}", r["SST03"], r["SST03M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 12, string.Format("{0:#00}:{1:00}", r["SST22"], r["SST22M"]), bodyStyleCenterNoBorder);
|
||||
}
|
||||
else
|
||||
{
|
||||
excel.SetCellValue(row, 4, WDAC.GetInt32Value(r["SST01"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 6, WDAC.GetInt32Value(r["SST02"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 8, WDAC.GetInt32Value(r["SST21"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 10, WDAC.GetInt32Value(r["SST03"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 12, WDAC.GetInt32Value(r["SST22"]), bodyNumberStyleNoBorder);
|
||||
}
|
||||
|
||||
SST01_SUM += WDAC.GetInt32Value(r["SST01"]) * 60 + WDAC.GetInt32Value(r["SST01M"]);
|
||||
SST02_SUM += WDAC.GetInt32Value(r["SST02"]) * 60 + WDAC.GetInt32Value(r["SST02M"]);
|
||||
SST03_SUM += WDAC.GetInt32Value(r["SST03"]) * 60 + WDAC.GetInt32Value(r["SST03M"]);
|
||||
SST21_SUM += WDAC.GetInt32Value(r["SST21"]) * 60 + WDAC.GetInt32Value(r["SST21M"]);
|
||||
SST22_SUM += WDAC.GetInt32Value(r["SST22"]) * 60 + WDAC.GetInt32Value(r["SST22M"]);
|
||||
|
||||
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, 7, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 7), excel.RCtoA1(row - 1, 7)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 9, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 9), excel.RCtoA1(row - 1, 9)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 11, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 11), excel.RCtoA1(row - 1, 11)), 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);
|
||||
|
||||
if (以時分顯示時數)
|
||||
{
|
||||
excel.SetCellValue(row, 4, MinuteToTime(SST01_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 6, MinuteToTime(SST02_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 8, MinuteToTime(SST21_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 10, MinuteToTime(SST03_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 12, MinuteToTime(SST22_SUM), bodyStyleCenterNoBorder);
|
||||
}
|
||||
else
|
||||
{
|
||||
excel.SetCellFormula(row, 4, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 4), excel.RCtoA1(row - 1, 4)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 6, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 6), excel.RCtoA1(row - 1, 6)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 8, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 8), excel.RCtoA1(row - 1, 8)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 10, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 10), excel.RCtoA1(row - 1, 10)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 12, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 12), excel.RCtoA1(row - 1, 12)), bodyNumberStyleNoBorder);
|
||||
}
|
||||
row++;
|
||||
|
||||
excel.MergeCell(row, 0, row, 5, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, "承辦人:", titleStyleLeftNoBorder);
|
||||
excel.MergeCell(row, 6, row, 10, BorderStyle.None);
|
||||
excel.SetCellValue(row, 6, "業務主管:", titleStyleLeftNoBorder);
|
||||
excel.MergeCell(row, 11, row, 15, BorderStyle.None);
|
||||
excel.SetCellValue(row, 11, "公司章:", 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, 50);
|
||||
|
||||
MemoryStream ms = new MemoryStream();
|
||||
workbook.Write(ms);
|
||||
return ms;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using NPOI.SS.UserModel;
|
||||
using System.IO;
|
||||
using Wellan.Data;
|
||||
using Wellan.Common;
|
||||
|
||||
/// <summary>
|
||||
/// 各項法定提撥費用明細表 的摘要描述
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using NPOI.SS.UserModel;
|
||||
using System.IO;
|
||||
using Wellan.Data;
|
||||
using Wellan.Common;
|
||||
|
||||
/// <summary>
|
||||
/// 外勤工作明細表 的摘要描述
|
||||
/// </summary>
|
||||
public class 外勤工作明細表 : ExcelReportBase
|
||||
{
|
||||
public 外勤工作明細表()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
base.Init();
|
||||
titleStyleCenterNoBorder.SetFont(bodyFont);
|
||||
bodyStyleCenterNoBorder.SetFont(bodyFont);
|
||||
bodyNumberStyleNoBorder.SetFont(bodyFont);
|
||||
bodyStyleLeftNoBorder.SetFont(bodyFont8PT);
|
||||
titleStyleRightNoBorder.SetFont(bodyFont);
|
||||
titleStyleLeftNoBorder.SetFont(bodyFont);
|
||||
}
|
||||
|
||||
public override MemoryStream 產生報表()
|
||||
{
|
||||
#region 報表抬頭
|
||||
|
||||
var row = 0;
|
||||
|
||||
excel.MergeCell(row, 0, row, 7, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, 公司名稱, headerStyle);
|
||||
excel.SetRowHeight(row, 20);
|
||||
row++;
|
||||
excel.MergeCell(row, 0, row, 7, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, string.Format("承辦{0}", 客戶名稱), headerStyle);
|
||||
excel.SetRowHeight(row, 20);
|
||||
row++;
|
||||
excel.MergeCell(row, 0, row, 7, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, string.Format("『{0}』", 專案名稱), headerStyle);
|
||||
excel.SetRowHeight(row, 20);
|
||||
row++;
|
||||
excel.MergeCell(row, 0, row, 7, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, string.Format("{0}【{1}{2}】", 報表名稱, 年度, 月份), headerStyle);
|
||||
excel.SetRowHeight(row, 20);
|
||||
row++;
|
||||
|
||||
excel.MergeCell(row, 4, row, 5, BorderStyle.None);
|
||||
excel.SetCellValue(row, 4, "差旅費", 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);
|
||||
row++;
|
||||
|
||||
#endregion
|
||||
|
||||
#region 報表資料
|
||||
|
||||
int beginRow = row;
|
||||
int serial = 1;
|
||||
|
||||
foreach (DataRow r in 資料來源.Tables[0].Rows)
|
||||
{
|
||||
var 月薪 = WDAC.GetInt32Value(r["SSP00"]) + WDAC.GetInt32Value(r["SSP02"]);
|
||||
var 差旅費 = WDAC.GetInt32Value(r["SSP09"])
|
||||
+ WDAC.GetInt32Value(r["SSP10"]);
|
||||
|
||||
excel.SetCellValue(row, 0, serial, bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 1, WDAC.GetStringValue(r["SSBRHX"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 2, WDAC.GetStringValue(r["BPNME"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 3, 月薪, bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 4, WDAC.GetInt32Value(r["SSP10"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 5, WDAC.GetInt32Value(r["SSP09"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 6, 差旅費, bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 7, WDAC.GetStringValue(r["SSC07"]), bodyStyleLeftNoBorder);
|
||||
|
||||
row++;
|
||||
serial++;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 合計及表尾批示
|
||||
excel.MergeCell(row, 0, row, 1, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, "合計", titleStyleLeftNoBorder);
|
||||
|
||||
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);
|
||||
row++;
|
||||
|
||||
excel.MergeCell(row, 0, row, 2, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, "承辦人:", titleStyleLeftNoBorder);
|
||||
excel.MergeCell(row, 3, row, 5, BorderStyle.None);
|
||||
excel.SetCellValue(row, 3, "業務主管:", titleStyleLeftNoBorder);
|
||||
excel.MergeCell(row, 6, row, 7, BorderStyle.None);
|
||||
excel.SetCellValue(row, 6, "公司章:", 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, 80);
|
||||
|
||||
MemoryStream ms = new MemoryStream();
|
||||
workbook.Write(ms);
|
||||
return ms;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,223 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Web;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using NPOI.SS.UserModel;
|
||||
using NPOI.HSSF.UserModel;
|
||||
using NPOI.HSSF.Util;
|
||||
using System.IO;
|
||||
using NPOI.SS.Util;
|
||||
using Wellan.Data;
|
||||
using System.Linq;
|
||||
using System.Diagnostics.Eventing.Reader;
|
||||
|
||||
/// <summary>
|
||||
/// 差勤日報表
|
||||
/// </summary>
|
||||
public class 差勤日報表 : ExcelReportBase
|
||||
{
|
||||
|
||||
public 差勤日報表()
|
||||
{
|
||||
報表名稱 = "差勤日報表";
|
||||
}
|
||||
|
||||
public DateTime 開始日期 { get; set; }
|
||||
public DateTime 結束日期 { get; set; }
|
||||
|
||||
public List<ProjectEmployeeItem> 人員Data { get; set; }
|
||||
public List<差勤日報表Item> 請假Data { get; set; }
|
||||
public List<差勤日報表Item> 加班Data { get; set; }
|
||||
public List<差勤日報表Item> 出差Data { get; set; }
|
||||
public List<RASNBRHItem> 站別分組 { get; set; }
|
||||
|
||||
private RparDAC rparDao = new RparDAC();
|
||||
|
||||
public override MemoryStream 產生報表()
|
||||
{
|
||||
var groupIdList = new List<string>();
|
||||
foreach (var 站別 in 站別分組)
|
||||
{
|
||||
if (!groupIdList.Contains(站別.GroupID))
|
||||
groupIdList.Add(站別.GroupID);
|
||||
}
|
||||
|
||||
var row = 0;
|
||||
foreach (var groupId in groupIdList)
|
||||
{
|
||||
var 本組站別 = 站別分組.FindAll(p => p.GroupID.CompareTo(groupId) == 0);
|
||||
var branchID = String.Join(",", (from 站別 in 本組站別 select 站別.BranchID).ToArray());
|
||||
var branchName = String.Join("+", (from 站別 in 本組站別 select 站別.BranchName).ToArray());
|
||||
|
||||
row += 產生單位報表(row, branchName, branchID) + 2;
|
||||
}
|
||||
|
||||
excel.SetColumnWidth(0, 8);
|
||||
excel.SetColumnWidth(1, 20);
|
||||
excel.SetColumnWidth(2, 40);
|
||||
excel.SetColumnWidth(3, 20);
|
||||
excel.SetColumnWidth(4, 40);
|
||||
excel.SetColumnWidth(5, 20);
|
||||
excel.SetColumnWidth(6, 40);
|
||||
excel.SetColumnWidth(7, 60);
|
||||
excel.SetColumnWidth(8, 20);
|
||||
|
||||
MemoryStream ms = new MemoryStream();
|
||||
workbook.Write(ms);
|
||||
return ms;
|
||||
}
|
||||
|
||||
|
||||
public int 產生單位報表(int startRow, string branchName, string branchID)
|
||||
{
|
||||
var rows = 報表抬頭(startRow, branchName);
|
||||
rows += 報表明細與結尾(startRow + rows, branchID);
|
||||
return rows;
|
||||
}
|
||||
|
||||
public int 報表抬頭(int startRow, string branchName)
|
||||
{
|
||||
excel.MergeCell(startRow + 0, 0, startRow + 1, 0);
|
||||
excel.SetCellValue(startRow + 0, 0, "單位", titleStyleCenter);
|
||||
excel.SetRangeOuterBorder(startRow + 0, 0, startRow + 1, 0, BorderStyle.Thin);
|
||||
|
||||
excel.MergeCell(startRow + 0, 1, startRow + 1, 1);
|
||||
excel.SetCellValue(startRow + 0, 1, branchName, titleStyleCenter);
|
||||
excel.SetRangeOuterBorder(startRow + 0, 1, startRow + 1, 1, BorderStyle.Thin);
|
||||
|
||||
excel.MergeCell(startRow + 0, 2, startRow + 0, 3);
|
||||
excel.SetCellValue(startRow + 0, 2, String.Format("日期-{0:MM月dd日}", 開始日期), titleStyleCenter);
|
||||
excel.SetRangeOuterBorder(startRow + 0, 2, startRow + 0, 3, BorderStyle.Thin);
|
||||
|
||||
excel.MergeCell(startRow + 1, 2, startRow + 1, 3);
|
||||
excel.SetCellValue(startRow + 1, 2, "加班申請", titleStyleCenter);
|
||||
excel.SetRangeOuterBorder(startRow + 1, 2, startRow + 1, 3, BorderStyle.Thin);
|
||||
|
||||
excel.MergeCell(startRow + 0, 4, startRow + 0, 7);
|
||||
excel.SetCellValue(startRow + 0, 4, String.Format("日期-{0:MM月dd日}", 結束日期), titleStyleCenter);
|
||||
excel.SetRangeOuterBorder(startRow + 0, 4, startRow + 0, 7, BorderStyle.Thin);
|
||||
|
||||
excel.MergeCell(startRow + 1, 4, startRow + 1, 5);
|
||||
excel.SetCellValue(startRow + 1, 4, "請假申請", titleStyleCenter);
|
||||
excel.SetRangeOuterBorder(startRow + 1, 4, startRow + 1, 5, BorderStyle.Thin);
|
||||
|
||||
excel.MergeCell(startRow + 1, 6, startRow + 1, 7);
|
||||
excel.SetCellValue(startRow + 1, 6, "出差申請", titleStyleCenter);
|
||||
excel.SetRangeOuterBorder(startRow + 1, 6, startRow + 1, 7, BorderStyle.Thin);
|
||||
|
||||
excel.MergeCell(startRow + 0, 8, startRow + 1, 8);
|
||||
excel.SetCellValue(startRow + 0, 8, "備註說明", titleStyleCenter);
|
||||
excel.SetRangeOuterBorder(startRow + 0, 8, startRow + 1, 8, BorderStyle.Thin);
|
||||
|
||||
excel.SetCellValue(startRow + 2, 0, "序號", titleStyleCenter);
|
||||
excel.SetCellValue(startRow + 2, 1, "姓名", titleStyleCenter);
|
||||
excel.SetCellValue(startRow + 2, 2, "起迄時間", titleStyleCenter);
|
||||
excel.SetCellValue(startRow + 2, 3, "時數", titleStyleCenter);
|
||||
excel.SetCellValue(startRow + 2, 4, "起迄時間", titleStyleCenter);
|
||||
excel.SetCellValue(startRow + 2, 5, "假別/事由", titleStyleCenter);
|
||||
excel.SetCellValue(startRow + 2, 6, "起迄時間", titleStyleCenter);
|
||||
excel.SetCellValue(startRow + 2, 7, "地點", titleStyleCenter);
|
||||
excel.SetCellValue(startRow + 2, 8, "剩餘補休時數", titleStyleCenter);
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
||||
public int 報表明細與結尾(int startRow, string branchID)
|
||||
{
|
||||
int rows = 0;
|
||||
|
||||
var 人員Data1 = 人員Data.FindAll(p => branchID.Contains(p.BPBRH)).OrderBy(p => p.BPENO);
|
||||
|
||||
foreach (var 人員Item in 人員Data1)
|
||||
{
|
||||
excel.SetCellValue(startRow + rows, 0, rows + 1, bodyStyleCenter);
|
||||
excel.SetCellValue(startRow + rows, 1, 人員Item.BPNME, bodyStyleCenter);
|
||||
|
||||
var 加班 = "";
|
||||
var 加班時數 = 0D;
|
||||
foreach (var 加班Item in 加班Data.FindAll(p => p.員工編號 == 人員Item.BPENO).OrderBy(p => p.起日))
|
||||
{
|
||||
加班 += (加班.Length > 0 ? "\n" : "") + String.Format("{0:yyyy/MM/dd} {1}~{2}", 加班Item.起日, 加班Item.起時, 加班Item.迄時);
|
||||
加班時數 += 加班Item.時數;
|
||||
}
|
||||
excel.SetCellValue(startRow + rows, 2, 加班, bodyStyleCenter);
|
||||
if (加班時數 > 0)
|
||||
excel.SetCellValue(startRow + rows, 3, (int)加班時數, bodyStyleCenter);
|
||||
else
|
||||
excel.SetCellValue(startRow + rows, 3, "", bodyStyleCenter);
|
||||
|
||||
|
||||
var 請假 = "";
|
||||
var 請假假別 = "";
|
||||
foreach (var 請假Item in 請假Data.FindAll(p => p.員工編號 == 人員Item.BPENO).OrderBy(p => p.起日))
|
||||
{
|
||||
請假 += (請假.Length > 0 ? "\n" : "")
|
||||
+ (請假Item.起日 == 請假Item.迄日
|
||||
? String.Format("{0:yyyy/MM/dd} {1}~{2}", 請假Item.起日, 請假Item.起時, 請假Item.迄時)
|
||||
: String.Format("{0:yyyy/MM/dd} {1}~{2:yyyy/MM/dd} {3}", 請假Item.起日, 請假Item.起時, 請假Item.迄日, 請假Item.迄時));
|
||||
請假假別 += (請假假別.Length > 0 ? "\n" : "") + 請假Item.類別名稱;
|
||||
}
|
||||
|
||||
excel.SetCellValue(startRow + rows, 4, 請假, bodyStyleCenter);
|
||||
excel.SetCellValue(startRow + rows, 5, 請假假別, bodyStyleCenter);
|
||||
|
||||
var 出差 = "";
|
||||
var 出差地點 = "";
|
||||
foreach (var 出差Item in 出差Data.FindAll(p => p.員工編號 == 人員Item.BPENO).OrderBy(p => p.起日))
|
||||
{
|
||||
出差 += (出差.Length > 0 ? "\n" : "")
|
||||
+ (出差Item.起日 == 出差Item.迄日
|
||||
? String.Format("{0:yyyy/MM/dd} {1}~{2}", 出差Item.起日, 出差Item.起時, 出差Item.迄時)
|
||||
: String.Format("{0:yyyy/MM/dd} {1}~{2:yyyy/MM/dd} {3}", 出差Item.起日, 出差Item.起時, 出差Item.迄日, 出差Item.迄時));
|
||||
出差地點 += (出差地點.Length > 0 ? "\n" : "") + 出差Item.出差地點;
|
||||
}
|
||||
|
||||
excel.SetCellValue(startRow + rows, 6, 出差, bodyStyleCenter);
|
||||
excel.SetCellValue(startRow + rows, 7, 出差地點, bodyStyleCenter);
|
||||
|
||||
|
||||
var 補休分數 = 0D;
|
||||
var 補休明細 = "";
|
||||
foreach (var 補休Item in rparDao.取得補休明細資料(人員Item.BPENO))
|
||||
{
|
||||
補休分數 += 補休Item.可用時數 * 60 + 補休Item.可用分數;
|
||||
if (以時分顯示時數)
|
||||
補休明細 += (補休明細.Length > 0 ? "\n" : "")
|
||||
+ String.Format("{0}:{1:00} {2:yyyy/MM/dd}", 補休Item.可用時數, 補休Item.可用分數, 補休Item.有效期限);
|
||||
else
|
||||
補休明細 += (補休明細.Length > 0 ? "\n" : "")
|
||||
+ String.Format("{0}H {1:yyyy/MM/dd}", 補休Item.可用時數, 補休Item.有效期限);
|
||||
}
|
||||
|
||||
if (補休分數 > 0) {
|
||||
if (以時分顯示時數)
|
||||
excel.SetCellValue(startRow + rows, 8, String.Format("{0}:{1:00}\n{2}", (int)補休分數 / 60, (int)補休分數 % 60, 補休明細), bodyStyleCenter);
|
||||
else
|
||||
excel.SetCellValue(startRow + rows, 8, String.Format("{0}H\n{1}", (int)補休分數 / 60, 補休明細), bodyStyleCenter);
|
||||
}
|
||||
else
|
||||
excel.SetCellValue(startRow + rows, 8, "", bodyStyleCenter);
|
||||
|
||||
excel.SetRowHeight(startRow + rows, 35);
|
||||
|
||||
rows++;
|
||||
}
|
||||
|
||||
excel.SetCellValue(startRow + rows, 0, "小計", bodyStyleCenter);
|
||||
excel.SetCellValue(startRow + rows, 1, String.Format("共 {0} 位", 人員Data1.ToList().Count), bodyStyleCenter);
|
||||
excel.SetCellValue(startRow + rows, 2, "總申請時數", bodyStyleCenter);
|
||||
if (人員Data1.ToList().Count > 0)
|
||||
excel.SetCellFormula(startRow + rows, 3, String.Format("SUM({0}:{1})", excel.RCtoA1(startRow, 3), excel.RCtoA1(startRow + rows - 1, 3)) , bodyStyleCenter);
|
||||
else
|
||||
excel.SetCellValue(startRow + rows, 3, 0, bodyStyleCenter);
|
||||
excel.SetCellValue(startRow + rows, 4, "", bodyStyleCenter);
|
||||
excel.SetCellValue(startRow + rows, 5, "", bodyStyleCenter);
|
||||
excel.SetCellValue(startRow + rows, 6, "", bodyStyleCenter);
|
||||
excel.SetCellValue(startRow + rows, 7, "", bodyStyleCenter);
|
||||
excel.SetCellValue(startRow + rows, 8, "", bodyStyleCenter);
|
||||
|
||||
rows++;
|
||||
return rows;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Web;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using NPOI.SS.UserModel;
|
||||
using NPOI.HSSF.UserModel;
|
||||
using NPOI.HSSF.Util;
|
||||
using System.IO;
|
||||
using NPOI.SS.Util;
|
||||
using Wellan.Data;
|
||||
|
||||
/// <summary>
|
||||
/// 差勤月報表
|
||||
/// </summary>
|
||||
public class 差勤月報表 : ExcelReportBase
|
||||
{
|
||||
public 差勤月報表()
|
||||
{
|
||||
報表名稱 = "差勤月報表";
|
||||
}
|
||||
|
||||
public override MemoryStream 產生報表()
|
||||
{
|
||||
BodyRowHeight = 35;
|
||||
|
||||
#region 報表抬頭
|
||||
|
||||
excel.MergeCell(0, 0, 0, 10);
|
||||
excel.SetCellValue(0, 0, String.Format("{0}\r\n承辦{1}\r\n『{2}』\r\n{3}", 公司名稱, 客戶名稱, 專案名稱, 報表名稱), headerStyle);
|
||||
excel.SetCellValue(1, 0, "月份:", titleStyleRightNoBorder);
|
||||
excel.SetCellValue(1, 1, 報表時間.ToString("MM月"), titleStyleLeftNoBorder);
|
||||
excel.SetCellValue(1, 2, "單位:", titleStyleRightNoBorder);
|
||||
excel.SetCellValue(1, 3, WDAC.GetStringValue(資料來源.Tables[0].Rows[0]["單位"]), titleStyleLeftNoBorder);
|
||||
excel.SetCellValue(1, 4, "職稱:", titleStyleRightNoBorder);
|
||||
excel.SetCellValue(1, 5, WDAC.GetStringValue(資料來源.Tables[0].Rows[0]["職稱"]), titleStyleLeftNoBorder);
|
||||
excel.SetCellValue(1, 6, "姓名:", titleStyleRightNoBorder);
|
||||
excel.SetCellValue(1, 7, WDAC.GetStringValue(資料來源.Tables[0].Rows[0]["姓名"]), titleStyleLeftNoBorder);
|
||||
excel.SetRowHeight(0, HeaderRowHeight * 4);
|
||||
excel.SetRowHeight(1, BodyRowHeight);
|
||||
|
||||
excel.MergeCell(2, 0, 2, 1);
|
||||
excel.SetRangeOuterBorder(2, 0, 2, 1, BorderStyle.Thin);
|
||||
excel.SetCellValue(2, 0, "日期", titleStyleCenter);
|
||||
excel.SetCellValue(2, 2, "出勤別", titleStyleCenter);
|
||||
excel.SetCellValue(2, 3, "實際上班", titleStyleCenter);
|
||||
excel.SetCellValue(2, 4, "出差外出", titleStyleCenter);
|
||||
excel.SetCellValue(2, 5, "出差返回", titleStyleCenter);
|
||||
excel.SetCellValue(2, 6, "實際下班", titleStyleCenter);
|
||||
excel.SetCellValue(2, 7, "請假", titleStyleCenter);
|
||||
excel.SetCellValue(2, 8, "加班", titleStyleCenter);
|
||||
excel.SetCellValue(2, 9, "公差", titleStyleCenter);
|
||||
excel.SetCellValue(2, 10, "備註", titleStyleCenter);
|
||||
excel.SetRowHeight(2, BodyRowHeight);
|
||||
|
||||
#endregion
|
||||
|
||||
#region 報表資料
|
||||
|
||||
int rowId = 3;
|
||||
ICellStyle rowStyle;
|
||||
|
||||
foreach (DataRow r in 資料來源.Tables[0].Rows)
|
||||
{
|
||||
string 請假 = WDAC.GetStringValue(r["請假"]);
|
||||
string 加班 = WDAC.GetStringValue(r["加班"]);
|
||||
string 公差 = WDAC.GetStringValue(r["公差"]);
|
||||
string 出勤別 = WDAC.GetStringValue(r["出勤別"]);
|
||||
|
||||
if (出勤別 == "上班")
|
||||
rowStyle = titleStyleCenter;
|
||||
else
|
||||
rowStyle = titleStyleCenterYellowBGC;
|
||||
|
||||
excel.SetCellValue(rowId, 0, WDAC.GetDateTimeValue(r["日期"]).ToString("MM月dd日"), rowStyle);
|
||||
excel.SetCellValue(rowId, 1, WDAC.GetDateTimeValue(r["日期"]).ToString("dddd"), rowStyle);
|
||||
excel.SetCellValue(rowId, 2, 出勤別, rowStyle);
|
||||
excel.SetCellValue(rowId, 3, WDAC.GetStringValue(r["上班"]), rowStyle);
|
||||
excel.SetCellValue(rowId, 4, WDAC.GetStringValue(r["出差外出"]), rowStyle);
|
||||
excel.SetCellValue(rowId, 5, WDAC.GetStringValue(r["出差返回"]), rowStyle);
|
||||
excel.SetCellValue(rowId, 6, WDAC.GetStringValue(r["下班"]), rowStyle);
|
||||
|
||||
if (請假 != "0:00")
|
||||
excel.SetCellValue(rowId, 7, 請假, rowStyle);
|
||||
else
|
||||
excel.SetCellValue(rowId, 7, "", rowStyle);
|
||||
|
||||
if (加班 != "0:00")
|
||||
excel.SetCellValue(rowId, 8, 加班, rowStyle);
|
||||
else
|
||||
excel.SetCellValue(rowId, 8, "", rowStyle);
|
||||
|
||||
if (公差 != "0:00")
|
||||
excel.SetCellValue(rowId, 9, 公差, rowStyle);
|
||||
else
|
||||
excel.SetCellValue(rowId, 9, "", rowStyle);
|
||||
|
||||
excel.SetCellValue(rowId, 10, string.Format("{0} {1} {2}", r["班別名稱"], r["班別時間"], r["出勤異常"]), rowStyle);
|
||||
excel.SetRowHeight(rowId, BodyRowHeight);
|
||||
rowId++;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 表尾批示
|
||||
|
||||
//excel.MergeCell(rowId + 2, 0, rowId + 2, 8);
|
||||
//excel.SetCellValue(rowId + 2, 0, "申請人: 計畫督導: 人事單位:", titleStyleLeftNoBorder);
|
||||
//excel.SetRowHeight(rowId + 2, BodyRowHeight);
|
||||
|
||||
#endregion
|
||||
|
||||
excel.SetColumnWidth(0, 11);
|
||||
excel.SetColumnWidth(1, 11);
|
||||
excel.SetColumnWidth(2, 10);
|
||||
excel.SetColumnWidth(3, 15);
|
||||
excel.SetColumnWidth(4, 15);
|
||||
excel.SetColumnWidth(5, 15);
|
||||
excel.SetColumnWidth(6, 15);
|
||||
excel.SetColumnWidth(7, 15);
|
||||
excel.SetColumnWidth(8, 15);
|
||||
excel.SetColumnWidth(9, 15);
|
||||
excel.SetColumnWidth(10, 15);
|
||||
|
||||
MemoryStream ms = new MemoryStream();
|
||||
workbook.Write(ms);
|
||||
return ms;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,338 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using NPOI.SS.UserModel;
|
||||
using System.IO;
|
||||
using Wellan.Data;
|
||||
using Wellan.Common;
|
||||
|
||||
/// <summary>
|
||||
/// 支出憑證黏存單
|
||||
/// </summary>
|
||||
public class 支出憑證黏存單 : ExcelReportBase
|
||||
{
|
||||
public 支出憑證黏存單()
|
||||
{
|
||||
報表名稱 = "支出憑證黏存單";
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
base.Init();
|
||||
bodyStyleCenterXS.SetFont(bodyFont8PT);
|
||||
}
|
||||
|
||||
public override MemoryStream 產生報表()
|
||||
{
|
||||
int 總金額 = 0;
|
||||
int 總天數 = 0;
|
||||
List<string> 出差事由List = new List<string>();
|
||||
string 出差事由 = "";
|
||||
|
||||
#region 先加總所有金額以及產生摘要
|
||||
|
||||
foreach (DataRow r in 資料來源.Tables[0].Rows)
|
||||
{
|
||||
總天數 += (WDAC.GetDateTimeValue(r["RPEDT"]) - WDAC.GetDateTimeValue(r["RPRDT"])).Days + 1;
|
||||
出差事由List.Add(WDAC.GetStringValue(r["RPRSN"]));
|
||||
}
|
||||
|
||||
for (int i = 0; i < 出差事由List.Count; i++)
|
||||
{
|
||||
出差事由 += String.Format("{0}.{1}\n", i + 1, 出差事由List[i]);
|
||||
}
|
||||
if (出差事由.Length > 0)
|
||||
出差事由 = 出差事由.Substring(0, 出差事由.Length - 1);
|
||||
|
||||
foreach (DataRow r in 資料來源.Tables[1].Rows)
|
||||
{
|
||||
總金額 += WDAC.GetInt32Value(r["總計"]);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 報表抬頭
|
||||
|
||||
excel.MergeCell(0, 0, 0, 16);
|
||||
excel.SetCellValue(0, 0, String.Format("{0}\n承辦{1}\n『{2}』\n{3}", 公司名稱, 客戶名稱, 專案名稱, 報表名稱), headerStyle);
|
||||
|
||||
excel.MergeCell(1, 0, 1, 16);
|
||||
excel.SetCellValue(1, 0, String.Format("所屬年度:{0}年度", WGuard1.WNTSA(報表時間.Year - WGuard1.CY11, "", false)), titleStyleLeftNoBorder);
|
||||
excel.MergeCell(1, 0, 1, 16);
|
||||
|
||||
excel.MergeCell(2, 0, 2, 4);
|
||||
excel.SetCellValue(2, 0, "傳票(付款憑單)編號:", titleStyleLeftNoBorder);
|
||||
excel.MergeCell(2, 15, 2, 16);
|
||||
excel.SetCellValue(2, 15, "黏貼單據___張", titleStyleRightNoBorder);
|
||||
excel.SetRangeOuterBorder(2, 0, 2, 16, BorderStyle.Thin);
|
||||
|
||||
excel.MergeCell(3, 0, 5, 1);
|
||||
excel.SetCellValue(3, 0, "第 號", titleStyleCenterNoBorder);
|
||||
excel.SetRangeOuterBorder(3, 0, 5, 1, BorderStyle.Thin);
|
||||
excel.MergeCell(3, 2, 3, 7);
|
||||
excel.SetCellValue(3, 2, "金 額", titleStyleCenterNoBorder);
|
||||
excel.SetRangeOuterBorder(3, 2, 3, 7, BorderStyle.Thin);
|
||||
excel.SetCellValue(4, 2, "拾", titleStyleCenter);
|
||||
excel.SetCellValue(4, 3, "萬", titleStyleCenter);
|
||||
excel.SetCellValue(4, 4, "仟", titleStyleCenter);
|
||||
excel.SetCellValue(4, 5, "佰", titleStyleCenter);
|
||||
excel.SetCellValue(4, 6, "拾", titleStyleCenter);
|
||||
excel.SetCellValue(4, 7, "元", titleStyleCenter);
|
||||
|
||||
string s總金額 = String.Format("{0:000000}", 總金額);
|
||||
excel.SetCellValue(5, 2, Convert.ToString(s總金額[0]), titleStyleCenter);
|
||||
excel.SetCellValue(5, 3, Convert.ToString(s總金額[1]), titleStyleCenter);
|
||||
excel.SetCellValue(5, 4, Convert.ToString(s總金額[2]), titleStyleCenter);
|
||||
excel.SetCellValue(5, 5, Convert.ToString(s總金額[3]), titleStyleCenter);
|
||||
excel.SetCellValue(5, 6, Convert.ToString(s總金額[4]), titleStyleCenter);
|
||||
excel.SetCellValue(5, 7, Convert.ToString(s總金額[5]), titleStyleCenter);
|
||||
|
||||
excel.MergeCell(3, 8, 4, 10);
|
||||
excel.SetCellValue(3, 8, "用途別", titleStyleCenterNoBorder);
|
||||
excel.SetRangeOuterBorder(3, 8, 4, 10, BorderStyle.Thin);
|
||||
excel.MergeCell(5, 8, 5, 10);
|
||||
excel.SetCellValue(5, 8, "用途摘要", titleStyleCenterNoBorder);
|
||||
excel.SetRangeOuterBorder(5, 8, 5, 10, BorderStyle.Thin);
|
||||
excel.MergeCell(3, 11, 4, 16);
|
||||
excel.SetCellValue(3, 11, "國內旅費", titleStyleLeftNoBorder);
|
||||
excel.SetRangeOuterBorder(3, 11, 4, 16, BorderStyle.Thin);
|
||||
excel.MergeCell(5, 11, 5, 16);
|
||||
excel.SetCellValue(5, 11, String.Format("{0:MM}月出差", 報表時間), titleStyleLeftNoBorder);
|
||||
excel.SetRangeOuterBorder(5, 11, 5, 16, BorderStyle.Thin);
|
||||
|
||||
excel.MergeCell(6, 8, 6, 12);
|
||||
excel.SetCellValue(6, 8, "國內出差旅費報告單", headerStyle);
|
||||
excel.MergeCell(6, 13, 6, 16);
|
||||
excel.SetCellValue(6, 13, String.Format("{0:填表日期:yyyy年MM月dd日}", DateTime.UtcNow.AddHours(8).Date), titleStyleRightNoBorder);
|
||||
excel.SetRangeOuterBorder(6, 0, 6, 16, BorderStyle.Thin);
|
||||
|
||||
excel.MergeCell(7, 0, 7, 2);
|
||||
excel.MergeCell(7, 3, 7, 6);
|
||||
excel.MergeCell(7, 7, 7, 8);
|
||||
excel.MergeCell(7, 9, 7, 11);
|
||||
excel.MergeCell(7, 12, 7, 13);
|
||||
excel.MergeCell(7, 14, 7, 16);
|
||||
excel.SetCellValue(7, 0, "姓 名", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(7, 3, WDAC.GetStringValue(資料來源.Tables[0].Rows[0]["BPNME"]), titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(7, 7, "單 位", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(7, 9, WDAC.GetStringValue(資料來源.Tables[0].Rows[0]["站別"]), titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(7, 12, "職 稱", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(7, 14, WDAC.GetStringValue(資料來源.Tables[0].Rows[0]["職稱"]), titleStyleCenterNoBorder);
|
||||
excel.SetRangeOuterBorder(7, 0, 7, 2, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(7, 3, 7, 6, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(7, 7, 7, 8, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(7, 9, 7, 11, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(7, 12, 7, 13, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(7, 14, 7, 16, BorderStyle.Thin);
|
||||
|
||||
excel.MergeCell(8, 0, 8, 2);
|
||||
excel.MergeCell(8, 3, 8, 16);
|
||||
excel.SetCellValue(8, 0, "出差事由", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(8, 3, 出差事由, titleStyleLeftNoBorder);
|
||||
excel.SetRangeOuterBorder(8, 0, 8, 2, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(8, 3, 8, 16, BorderStyle.Thin);
|
||||
|
||||
excel.MergeCell(9, 0, 9, 16);
|
||||
excel.SetCellValue(9, 0, String.Format("中華民國 {0:yyyy} 年 {0:MM} 月 {0:dd} 日 至 {1:yyyy} 年 {1:MM} 月 {1:dd} 日止 共計 {2} 天 附單據___張",
|
||||
報表時間, 報表時間.AddMonths(1).AddDays(-1), 總天數), titleStyleCenterNoBorder);
|
||||
excel.SetRangeOuterBorder(9, 0, 9, 16, BorderStyle.Thin);
|
||||
|
||||
excel.MergeCell(10, 0, 10, 1);
|
||||
excel.MergeCell(10, 2, 11, 4);
|
||||
excel.MergeCell(10, 5, 11, 7);
|
||||
excel.MergeCell(10, 8, 10, 11);
|
||||
excel.MergeCell(10, 12, 11, 12);
|
||||
excel.MergeCell(10, 13, 11, 13);
|
||||
excel.MergeCell(10, 14, 11, 14);
|
||||
excel.MergeCell(10, 15, 11, 15);
|
||||
excel.MergeCell(10, 16, 11, 16);
|
||||
excel.SetCellValue(10, 0, String.Format("{0:yyyy}年", 報表時間), titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(11, 0, "月", titleStyleCenter);
|
||||
excel.SetCellValue(11, 1, "日", titleStyleCenter);
|
||||
excel.SetCellValue(10, 2, "起訖地點", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(10, 5, "工作摘要", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(10, 8, "交通費", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(11, 8, "捷運\n及\n汽車", titleStyleCenter);
|
||||
excel.SetCellValue(11, 9, "火\n車", titleStyleCenter);
|
||||
excel.SetCellValue(11, 10, "高\n鐵", titleStyleCenter);
|
||||
excel.SetCellValue(11, 11, "飛\n機", titleStyleCenter);
|
||||
excel.SetCellValue(10, 12, "住宿費\n+\n過路費", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(10, 13, "雜費", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(10, 14, "單據\n號數", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(10, 15, "總計", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(10, 16, "備註", titleStyleCenterNoBorder);
|
||||
excel.SetRangeOuterBorder(10, 0, 10, 1, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(10, 2, 11, 4, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(10, 5, 11, 7, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(10, 8, 10, 11, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(10, 12, 11, 12, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(10, 13, 11, 13, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(10, 14, 11, 14, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(10, 15, 11, 15, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(10, 16, 11, 16, BorderStyle.Thin);
|
||||
|
||||
excel.SetRowHeight(0, HeaderRowHeight * 4);
|
||||
excel.SetRowHeight(1, BodyRowHeight);
|
||||
excel.SetRowHeight(2, BodyRowHeight);
|
||||
excel.SetRowHeight(3, BodyRowHeight);
|
||||
excel.SetRowHeight(4, BodyRowHeight);
|
||||
excel.SetRowHeight(5, BodyRowHeight * 2);
|
||||
excel.SetRowHeight(6, BodyRowHeight * 2);
|
||||
excel.SetRowHeight(7, BodyRowHeight);
|
||||
excel.SetRowHeight(8, BodyRowHeight * (資料來源.Tables[0].Rows.Count > 4 ? 資料來源.Tables[0].Rows.Count : 4));
|
||||
excel.SetRowHeight(9, BodyRowHeight);
|
||||
excel.SetRowHeight(10, BodyRowHeight);
|
||||
excel.SetRowHeight(11, BodyRowHeight * 2);
|
||||
|
||||
#endregion
|
||||
|
||||
#region 報表資料
|
||||
|
||||
int rowId = 12;
|
||||
int beginRow = 12;
|
||||
foreach (DataRow r in 資料來源.Tables[1].Rows)
|
||||
{
|
||||
DataRow[] master = 資料來源.Tables[0].Select("RPREN='" + WDAC.GetStringValue(r["單號"]) + "'");
|
||||
|
||||
excel.SetCellValue(rowId, 0, String.Format("{0:MM}", r["日期"]), bodyStyleCenter);
|
||||
excel.SetCellValue(rowId, 1, String.Format("{0:dd}", r["日期"]), bodyStyleCenter);
|
||||
excel.MergeCell(rowId, 2, rowId, 4);
|
||||
excel.SetCellValue(rowId, 2, WDAC.GetStringValue(r["起地點"]) + "~" + WDAC.GetStringValue(r["迄地點"]), bodyStyleCenterS);
|
||||
excel.SetRangeOuterBorder(rowId, 2, rowId, 4, BorderStyle.Thin);
|
||||
|
||||
excel.MergeCell(rowId, 5, rowId, 7);
|
||||
出差事由 = WDAC.GetStringValue(master[0]["RPRSN"]);
|
||||
if (master.Length > 0 && 出差事由List.Contains(出差事由))
|
||||
excel.SetCellValue(rowId, 5, String.Format("同出差事由 {0}", 出差事由List.IndexOf(出差事由) + 1), bodyStyleCenterS);
|
||||
else
|
||||
excel.SetCellValue(rowId, 5, "", bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(rowId, 5, rowId, 7, BorderStyle.Thin);
|
||||
|
||||
excel.SetCellValue(rowId, 8, WDAC.GetDoubleValue(r["捷運"]) + WDAC.GetDoubleValue(r["汽車"]), bodyStyleCenter);
|
||||
excel.SetCellValue(rowId, 9, WDAC.GetDoubleValue(r["火車"]), bodyStyleCenter);
|
||||
excel.SetCellValue(rowId, 10, WDAC.GetDoubleValue(r["高鐵"]), bodyStyleCenter);
|
||||
excel.SetCellValue(rowId, 11, WDAC.GetDoubleValue(r["飛機"]), bodyStyleCenter);
|
||||
excel.SetCellValue(rowId, 12, WDAC.GetDoubleValue(r["住宿費"]) + WDAC.GetDoubleValue(r["過路費"]), bodyStyleCenter);
|
||||
excel.SetCellValue(rowId, 13, WDAC.GetDoubleValue(r["雜費"]), bodyStyleCenter);
|
||||
excel.SetCellValue(rowId, 14, WDAC.GetStringValue(r["單據號數"]), bodyStyleCenter);
|
||||
excel.SetCellValue(rowId, 15, WDAC.GetDoubleValue(r["總計"]), bodyStyleCenter);
|
||||
excel.SetCellValue(rowId, 16, WDAC.GetStringValue(r["備註"]), bodyStyleCenterXS);
|
||||
|
||||
excel.SetRowHeight(rowId, (int)(BodyRowHeight * 1.5));
|
||||
rowId++;
|
||||
}
|
||||
|
||||
// 補空行
|
||||
if (資料來源.Tables[1].Rows.Count < 10)
|
||||
{
|
||||
for (int n = 資料來源.Tables[1].Rows.Count; n < 10; n++)
|
||||
{
|
||||
excel.SetCellValue(rowId, 0, "", bodyStyleCenter);
|
||||
excel.SetCellValue(rowId, 1, "", bodyStyleCenter);
|
||||
excel.MergeCell(rowId, 2, rowId, 4);
|
||||
excel.SetCellValue(rowId, 2, "", bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(rowId, 2, rowId, 4, BorderStyle.Thin);
|
||||
|
||||
excel.MergeCell(rowId, 5, rowId, 7);
|
||||
excel.SetCellValue(rowId, 5, "", bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(rowId, 5, rowId, 7, BorderStyle.Thin);
|
||||
|
||||
excel.SetCellValue(rowId, 8, "", bodyStyleCenter);
|
||||
excel.SetCellValue(rowId, 9, "", bodyStyleCenter);
|
||||
excel.SetCellValue(rowId, 10, "", bodyStyleCenter);
|
||||
excel.SetCellValue(rowId, 11, "", bodyStyleCenter);
|
||||
excel.SetCellValue(rowId, 12, "", bodyStyleCenter);
|
||||
excel.SetCellValue(rowId, 13, "", bodyStyleCenter);
|
||||
excel.SetCellValue(rowId, 14, "", bodyStyleCenter);
|
||||
excel.SetCellValue(rowId, 15, "", bodyStyleCenter);
|
||||
excel.SetCellValue(rowId, 16, "", bodyStyleCenter);
|
||||
|
||||
excel.SetRowHeight(rowId, (int)(BodyRowHeight * 0.8));
|
||||
|
||||
rowId++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region 合計及表尾批示
|
||||
excel.MergeCell(rowId, 0, rowId, 4);
|
||||
excel.SetCellValue(rowId, 0, "合 計", titleStyleCenter);
|
||||
excel.SetRangeOuterBorder(rowId, 0, rowId, 4, BorderStyle.Thin);
|
||||
excel.MergeCell(rowId, 5, rowId, 7);
|
||||
excel.SetRangeOuterBorder(rowId, 5, rowId, 7, BorderStyle.Thin);
|
||||
excel.SetCellFormula(rowId, 8, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 8), excel.RCtoA1(rowId - 1, 8)), bodyStyleCenter);
|
||||
excel.SetCellFormula(rowId, 9, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 9), excel.RCtoA1(rowId - 1, 9)), bodyStyleCenter);
|
||||
excel.SetCellFormula(rowId, 10, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 10), excel.RCtoA1(rowId - 1, 10)), bodyStyleCenter);
|
||||
excel.SetCellFormula(rowId, 11, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 11), excel.RCtoA1(rowId - 1, 11)), bodyStyleCenter);
|
||||
excel.SetCellFormula(rowId, 12, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 12), excel.RCtoA1(rowId - 1, 12)), bodyStyleCenter);
|
||||
excel.SetCellFormula(rowId, 13, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 13), excel.RCtoA1(rowId - 1, 13)), bodyStyleCenter);
|
||||
excel.SetCellValue(rowId, 14, "", titleStyleCenter);
|
||||
excel.SetCellFormula(rowId, 15, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 15), excel.RCtoA1(rowId - 1, 15)), bodyStyleCenter);
|
||||
excel.SetCellValue(rowId, 16, "", titleStyleCenter);
|
||||
excel.SetRowHeight(rowId, BodyRowHeight);
|
||||
|
||||
rowId++;
|
||||
excel.MergeCell(rowId, 0, rowId, 4);
|
||||
excel.MergeCell(rowId, 5, rowId, 9);
|
||||
excel.MergeCell(rowId, 10, rowId, 13);
|
||||
excel.MergeCell(rowId, 14, rowId, 16);
|
||||
|
||||
if (專案編號.Length >= 6 && 專案編號.Substring(專案編號.Length - 6, 6) == "B00001")
|
||||
{
|
||||
excel.SetCellValue(rowId, 0, "申 請 人", titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 5, "單 位 主 管", titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 10, "財 會 經 辦", titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 14, "人 資 單 位", titleStyleCenter);
|
||||
}
|
||||
else
|
||||
{
|
||||
excel.SetCellValue(rowId, 0, "申 請 人", titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 5, "計 畫 督 導", titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 10, "人 事 單 位", titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 14, "財 務 主 管", titleStyleCenter);
|
||||
}
|
||||
excel.SetRangeOuterBorder(rowId, 0, rowId, 4, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(rowId, 5, rowId, 9, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(rowId, 10, rowId, 13, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(rowId, 14, rowId, 16, BorderStyle.Thin);
|
||||
excel.SetRowHeight(rowId, BodyRowHeight);
|
||||
|
||||
rowId++;
|
||||
excel.MergeCell(rowId, 0, rowId, 4);
|
||||
excel.SetCellValue(rowId, 0, WDAC.GetStringValue(資料來源.Tables[0].Rows[0]["BPNME"]), bodyStyleCenter);
|
||||
excel.MergeCell(rowId, 5, rowId, 9);
|
||||
excel.MergeCell(rowId, 10, rowId, 13);
|
||||
excel.MergeCell(rowId, 14, rowId, 16);
|
||||
excel.SetRangeOuterBorder(rowId, 0, rowId, 4, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(rowId, 5, rowId, 9, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(rowId, 10, rowId, 13, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(rowId, 14, rowId, 16, BorderStyle.Thin);
|
||||
excel.SetRowHeight(rowId, BodyRowHeight * 3);
|
||||
|
||||
#endregion
|
||||
|
||||
excel.SetColumnWidth(0, 4);
|
||||
excel.SetColumnWidth(1, 4);
|
||||
excel.SetColumnWidth(2, 4);
|
||||
excel.SetColumnWidth(3, 4);
|
||||
excel.SetColumnWidth(4, 4);
|
||||
excel.SetColumnWidth(5, 4);
|
||||
excel.SetColumnWidth(6, 4);
|
||||
excel.SetColumnWidth(7, 4);
|
||||
excel.SetColumnWidth(8, 7);
|
||||
excel.SetColumnWidth(9, 7);
|
||||
excel.SetColumnWidth(10, 7);
|
||||
excel.SetColumnWidth(11, 7);
|
||||
excel.SetColumnWidth(12, 7);
|
||||
excel.SetColumnWidth(13, 7);
|
||||
excel.SetColumnWidth(14, 7);
|
||||
excel.SetColumnWidth(15, 9);
|
||||
excel.SetColumnWidth(16, 20);
|
||||
|
||||
MemoryStream ms = new MemoryStream();
|
||||
workbook.Write(ms);
|
||||
return ms;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using NPOI.SS.UserModel;
|
||||
using System.IO;
|
||||
using Wellan.Data;
|
||||
using Wellan.Common;
|
||||
|
||||
/// <summary>
|
||||
/// 薪資清冊 的摘要描述
|
||||
/// </summary>
|
||||
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, 20, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, 公司名稱, headerStyle);
|
||||
excel.SetRowHeight(row, 20);
|
||||
row++;
|
||||
excel.MergeCell(row, 0, row, 20, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, string.Format("承辦{0}", 客戶名稱), headerStyle);
|
||||
excel.SetRowHeight(row, 20);
|
||||
row++;
|
||||
excel.MergeCell(row, 0, row, 20, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, string.Format("『{0}』", 專案名稱.Trim()), headerStyle);
|
||||
excel.SetRowHeight(row, 20);
|
||||
row++;
|
||||
excel.MergeCell(row, 0, row, 20, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, string.Format("{0}【{1}{2}】", 報表名稱, 年度, 月份), headerStyle);
|
||||
excel.SetRowHeight(row, 20);
|
||||
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.SetCellValue(row, 20, "實領薪資", titleStyleCenterNoBorder);
|
||||
excel.SetRowHeight(row, 26);
|
||||
row++;
|
||||
|
||||
#endregion
|
||||
|
||||
#region 報表資料
|
||||
|
||||
int beginRow = row;
|
||||
int serial = 1;
|
||||
foreach (DataRow r in 資料來源.Tables[0].Rows)
|
||||
{
|
||||
var 月薪 = WDAC.GetInt32Value(r["SSP00"]) + WDAC.GetInt32Value(r["SSP02"]);
|
||||
var 應領薪資 = 月薪
|
||||
+ WDAC.GetInt32Value(r["SSP01"])
|
||||
+ WDAC.GetInt32Value(r["SSP03"])
|
||||
+ WDAC.GetInt32Value(r["SSP04"])
|
||||
+ WDAC.GetInt32Value(r["SSP05"])
|
||||
- WDAC.GetInt32Value(r["SSS01"])
|
||||
- WDAC.GetInt32Value(r["SSS02"])
|
||||
- WDAC.GetInt32Value(r["SSS09"]);
|
||||
var 加班費 = WDAC.GetInt32Value(r["SSP06"])
|
||||
+ WDAC.GetInt32Value(r["SSP07"])
|
||||
+ WDAC.GetInt32Value(r["SSP08"])
|
||||
+ WDAC.GetInt32Value(r["SSP13"])
|
||||
+ WDAC.GetInt32Value(r["SSP14"]);
|
||||
var 外勤工作費 = WDAC.GetInt32Value(r["SSP09"])
|
||||
+ WDAC.GetInt32Value(r["SSP10"])
|
||||
+ WDAC.GetInt32Value(r["SSP12"]);
|
||||
var 其他加扣 = WDAC.GetInt32Value(r["SSP99"]) - WDAC.GetInt32Value(r["SSS99"]);
|
||||
var 實領薪資 = 應領薪資
|
||||
+ 外勤工作費
|
||||
+ 加班費
|
||||
+ WDAC.GetInt32Value(r["SSP11"])
|
||||
- WDAC.GetInt32Value(r["SSS04"])
|
||||
- WDAC.GetInt32Value(r["SSS05"])
|
||||
- WDAC.GetInt32Value(r["SSS06"])
|
||||
- WDAC.GetInt32Value(r["SSS07"])
|
||||
+ 其他加扣;
|
||||
|
||||
excel.SetCellValue(row, 0, serial, bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 1, WDAC.GetStringValue(r["SSBRHX"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 2, WDAC.GetStringValue(r["BPJME"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 3, WDAC.GetStringValue(r["BPNME"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 4, string.Format("{0:yyyy/MM/dd}", r["BPSDY"], WGuard1.TaiwanCulture), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 5, string.Format("{0:yyyy/MM/dd}", r["RASDT"], WGuard1.TaiwanCulture), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 6, WDAC.GetInt32Value(r["BPSRM"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 7, 月薪, bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 8, WDAC.GetInt32Value(r["SSP05"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 9, WDAC.GetInt32Value(r["SSS02"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 10, WDAC.GetInt32Value(r["SSS01"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 11, WDAC.GetInt32Value(r["SSS09"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 12, 應領薪資, bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 13, 加班費, bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 14, 外勤工作費, bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 15, WDAC.GetInt32Value(r["SSS04"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 16, WDAC.GetInt32Value(r["SSS05"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 17, WDAC.GetInt32Value(r["SSS07"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 18, WDAC.GetInt32Value(r["SSS06"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 19, 其他加扣, bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 20, 實領薪資, bodyNumberStyleNoBorder);
|
||||
row++;
|
||||
serial++;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 合計及表尾批示
|
||||
excel.MergeCell(row, 0, row, 1, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, "合計", titleStyleLeftNoBorder);
|
||||
|
||||
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);
|
||||
excel.SetCellFormula(row, 20, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 20), excel.RCtoA1(row - 1, 20)), bodyNumberStyleNoBorder);
|
||||
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, 20, BorderStyle.None);
|
||||
excel.SetCellValue(row, 14, "公司章:", titleStyleLeftNoBorder);
|
||||
|
||||
#endregion
|
||||
|
||||
excel.SetColumnWidth(0, 6);
|
||||
excel.SetColumnWidth(1, 10);
|
||||
excel.SetColumnWidth(2, 14);
|
||||
excel.SetColumnWidth(3, 10);
|
||||
excel.SetColumnWidth(4, 12);
|
||||
excel.SetColumnWidth(5, 12);
|
||||
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);
|
||||
excel.SetColumnWidth(20, 10);
|
||||
|
||||
MemoryStream ms = new MemoryStream();
|
||||
workbook.Write(ms);
|
||||
return ms;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,264 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using NPOI.SS.UserModel;
|
||||
using System.IO;
|
||||
using Wellan.Data;
|
||||
using Wellan.Common;
|
||||
|
||||
/// <summary>
|
||||
/// 請假明細 的摘要描述
|
||||
/// </summary>
|
||||
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, 22, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, 公司名稱, headerStyle);
|
||||
excel.SetRowHeight(row, 20);
|
||||
row++;
|
||||
excel.MergeCell(row, 0, row, 22, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, string.Format("承辦{0}", 客戶名稱), headerStyle);
|
||||
excel.SetRowHeight(row, 20);
|
||||
row++;
|
||||
excel.MergeCell(row, 0, row, 22, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, string.Format("『{0}』", 專案名稱), headerStyle);
|
||||
excel.SetRowHeight(row, 20);
|
||||
row++;
|
||||
excel.MergeCell(row, 0, row, 22, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, string.Format("{0}【{1}{2}】", 報表名稱, 年度, 月份), headerStyle);
|
||||
excel.SetRowHeight(row, 20);
|
||||
row++;
|
||||
|
||||
excel.MergeCell(row, 4, row, 20, BorderStyle.None);
|
||||
excel.SetCellValue(row, 4, "請假時數 / 金額", 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.SetCellValue(row, 20, "小計", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 21, "合計金額", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 22, "備註", titleStyleCenterNoBorder);
|
||||
excel.SetRowHeight(row, 18);
|
||||
row++;
|
||||
|
||||
#endregion
|
||||
|
||||
#region 報表資料
|
||||
|
||||
int beginRow = row;
|
||||
int serial = 1;
|
||||
var SST05_SUM = 0;
|
||||
var SST06_SUM = 0;
|
||||
var SST10_SUM = 0;
|
||||
var SST12_SUM = 0;
|
||||
var SST20_SUM = 0;
|
||||
var SST11_SUM = 0;
|
||||
var SST13_SUM = 0;
|
||||
var SST14_SUM = 0;
|
||||
var SST09_SUM = 0;
|
||||
var SST07_SUM = 0;
|
||||
var SST16_SUM = 0;
|
||||
var SST19_SUM = 0;
|
||||
var SST23_SUM = 0;
|
||||
var SST08_SUM = 0;
|
||||
var SST15_SUM = 0;
|
||||
|
||||
foreach (DataRow r in 資料來源.Tables[0].Rows)
|
||||
{
|
||||
var 月薪 = WDAC.GetInt32Value(r["SSP00"]) + WDAC.GetInt32Value(r["SSP02"]);
|
||||
var 無薪小計 = WDAC.GetInt32Value(r["SSS02"]) + WDAC.GetInt32Value(r["SSS09"]);
|
||||
var 扣款合計 = WDAC.GetInt32Value(r["SSS01"]) + WDAC.GetInt32Value(r["SSS02"]) + WDAC.GetInt32Value(r["SSS09"]);
|
||||
|
||||
excel.SetCellValue(row, 0, serial, bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 1, WDAC.GetStringValue(r["SSBRHX"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 2, WDAC.GetStringValue(r["BPNME"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 3, 月薪, bodyNumberStyleNoBorder);
|
||||
|
||||
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"]);
|
||||
SST12_SUM += WDAC.GetInt32Value(r["SST12"]) * 60 + WDAC.GetInt32Value(r["SST12M"]);
|
||||
SST20_SUM += WDAC.GetInt32Value(r["SST20"]) * 60 + WDAC.GetInt32Value(r["SST20M"]);
|
||||
SST11_SUM += WDAC.GetInt32Value(r["SST11"]) * 60 + WDAC.GetInt32Value(r["SST11M"]);
|
||||
SST13_SUM += WDAC.GetInt32Value(r["SST13"]) * 60 + WDAC.GetInt32Value(r["SST13M"]);
|
||||
SST14_SUM += WDAC.GetInt32Value(r["SST14"]) * 60 + WDAC.GetInt32Value(r["SST14M"]);
|
||||
SST09_SUM += WDAC.GetInt32Value(r["SST09"]) * 60 + WDAC.GetInt32Value(r["SST09M"]);
|
||||
SST07_SUM += WDAC.GetInt32Value(r["SST07"]) * 60 + WDAC.GetInt32Value(r["SST07M"]);
|
||||
SST16_SUM += WDAC.GetInt32Value(r["SST16"]) * 60 + WDAC.GetInt32Value(r["SST16M"]);
|
||||
SST19_SUM += WDAC.GetInt32Value(r["SST19"]) * 60 + WDAC.GetInt32Value(r["SST19M"]);
|
||||
SST23_SUM += WDAC.GetInt32Value(r["SST23"]) * 60 + WDAC.GetInt32Value(r["SST23M"]);
|
||||
SST08_SUM += WDAC.GetInt32Value(r["SST08"]) * 60 + WDAC.GetInt32Value(r["SST08M"]);
|
||||
SST15_SUM += WDAC.GetInt32Value(r["SST15"]) * 60 + WDAC.GetInt32Value(r["SST15M"]);
|
||||
|
||||
if (以時分顯示時數)
|
||||
{
|
||||
excel.SetCellValue(row, 4, string.Format("{0:#00}:{1:00}", r["SST05"], r["SST05M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 5, string.Format("{0:#00}:{1:00}", r["SST06"], r["SST06M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 6, string.Format("{0:#00}:{1:00}", r["SST10"], r["SST10M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 7, string.Format("{0:#00}:{1:00}", r["SST12"], r["SST12M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 8, string.Format("{0:#00}:{1:00}", r["SST20"], r["SST20M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 9, string.Format("{0:#00}:{1:00}", r["SST11"], r["SST11M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 10, string.Format("{0:#00}:{1:00}", r["SST13"], r["SST13M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 11, string.Format("{0:#00}:{1:00}", r["SST14"], r["SST14M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 12, string.Format("{0:#00}:{1:00}", r["SST09"], r["SST09M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 13, string.Format("{0:#00}:{1:00}", r["SST07"], r["SST07M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 14, string.Format("{0:#00}:{1:00}", r["SST16"], r["SST16M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 15, string.Format("{0:#00}:{1:00}", r["SST19"], r["SST19M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 16, string.Format("{0:#00}:{1:00}", r["SST23"], r["SST23M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 17, 無薪小計, bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 18, string.Format("{0:#00}:{1:00}", r["SST08"], r["SST08M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 19, string.Format("{0:#00}:{1:00}", r["SST15"], r["SST15M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 20, WDAC.GetInt32Value(r["SSS01"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 21, 扣款合計, bodyNumberStyleNoBorder);
|
||||
}
|
||||
else
|
||||
{
|
||||
excel.SetCellValue(row, 4, WDAC.GetInt32Value(r["SST05"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 5, WDAC.GetInt32Value(r["SST06"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 6, WDAC.GetInt32Value(r["SST10"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 7, WDAC.GetInt32Value(r["SST12"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 8, WDAC.GetInt32Value(r["SST20"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 9, WDAC.GetInt32Value(r["SST11"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 10, WDAC.GetInt32Value(r["SST13"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 11, WDAC.GetInt32Value(r["SST14"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 12, WDAC.GetInt32Value(r["SST09"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 13, WDAC.GetInt32Value(r["SST07"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 14, WDAC.GetInt32Value(r["SST16"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 15, WDAC.GetInt32Value(r["SST19"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 16, WDAC.GetInt32Value(r["SST23"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 17, 無薪小計, bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 18, WDAC.GetInt32Value(r["SST08"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 19, WDAC.GetInt32Value(r["SST15"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 20, WDAC.GetInt32Value(r["SSS01"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 21, 扣款合計, bodyNumberStyleNoBorder);
|
||||
}
|
||||
row++;
|
||||
serial++;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 合計及表尾批示
|
||||
excel.MergeCell(row, 0, row, 1, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, "合計", titleStyleLeftNoBorder);
|
||||
|
||||
if (以時分顯示時數)
|
||||
{
|
||||
excel.SetCellValue(row, 4, MinuteToTime(SST05_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 5, MinuteToTime(SST06_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 6, MinuteToTime(SST10_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 7, MinuteToTime(SST12_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 8, MinuteToTime(SST20_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 9, MinuteToTime(SST11_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 10, MinuteToTime(SST13_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 11, MinuteToTime(SST14_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 12, MinuteToTime(SST09_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 13, MinuteToTime(SST07_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 14, MinuteToTime(SST16_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 15, MinuteToTime(SST19_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 16, MinuteToTime(SST23_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellFormula(row, 17, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 17), excel.RCtoA1(row - 1, 17)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 18, MinuteToTime(SST08_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 19, MinuteToTime(SST15_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellFormula(row, 20, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 20), excel.RCtoA1(row - 1, 20)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 21, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 21), excel.RCtoA1(row - 1, 21)), bodyNumberStyleNoBorder);
|
||||
}
|
||||
else
|
||||
{
|
||||
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);
|
||||
excel.SetCellFormula(row, 20, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 20), excel.RCtoA1(row - 1, 20)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 21, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 21), excel.RCtoA1(row - 1, 21)), bodyNumberStyleNoBorder);
|
||||
}
|
||||
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, 22, 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);
|
||||
excel.SetColumnWidth(20, 10);
|
||||
excel.SetColumnWidth(21, 10);
|
||||
excel.SetColumnWidth(22, 10);
|
||||
|
||||
MemoryStream ms = new MemoryStream();
|
||||
workbook.Write(ms);
|
||||
return ms;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,211 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Web;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using NPOI.SS.UserModel;
|
||||
using NPOI.HSSF.UserModel;
|
||||
using NPOI.HSSF.Util;
|
||||
using System.IO;
|
||||
using NPOI.SS.Util;
|
||||
using Wellan.Data;
|
||||
using System.Linq;
|
||||
|
||||
/// <summary>
|
||||
/// 請假申請單
|
||||
/// </summary>
|
||||
public class 請假申請單 : ExcelReportBase
|
||||
{
|
||||
public 請假申請單()
|
||||
{
|
||||
報表名稱 = "請假申請單";
|
||||
}
|
||||
|
||||
public override MemoryStream 產生報表()
|
||||
{
|
||||
BodyRowHeight = 35;
|
||||
TimeCalc timeCalc = new TimeCalc();
|
||||
|
||||
#region 報表抬頭
|
||||
|
||||
excel.MergeCell(0, 0, 0, 9);
|
||||
excel.SetCellValue(0, 0, String.Format("{0}\r\n承辦{1}\r\n『{2}』\r\n{3}", 公司名稱, 客戶名稱, 專案名稱, 報表名稱), headerStyle);
|
||||
excel.SetCellValue(1, 0, "月份:", titleStyleRightNoBorder);
|
||||
excel.MergeCell(1, 1, 1, 2);
|
||||
excel.SetCellValue(1, 1, 報表時間.ToString("MM月"), titleStyleLeftNoBorder);
|
||||
excel.SetCellValue(1, 3, "單位:", titleStyleRightNoBorder);
|
||||
excel.SetCellValue(1, 4, WDAC.GetStringValue(資料來源.Tables[0].Rows[0]["站別"]), titleStyleLeftNoBorder);
|
||||
excel.SetCellValue(1, 5, "職稱:", titleStyleRightNoBorder);
|
||||
excel.SetCellValue(1, 6, WDAC.GetStringValue(資料來源.Tables[0].Rows[0]["職稱"]), titleStyleLeftNoBorder);
|
||||
excel.SetCellValue(1, 7, "姓名:", titleStyleRightNoBorder);
|
||||
excel.SetCellValue(1, 8, WDAC.GetStringValue(資料來源.Tables[0].Rows[0]["BPNME"]), titleStyleLeftNoBorder);
|
||||
excel.SetRowHeight(0, HeaderRowHeight * 4);
|
||||
excel.SetRowHeight(1, BodyRowHeight);
|
||||
|
||||
excel.MergeCell(2, 0, 2, 2);
|
||||
excel.SetRangeOuterBorder(2, 0, 2, 2, BorderStyle.Thin);
|
||||
excel.SetCellValue(2, 0, "請假日期", titleStyleCenter);
|
||||
excel.SetCellValue(2, 3, "開始時間", titleStyleCenter);
|
||||
excel.SetCellValue(2, 4, "結束時間", titleStyleCenter);
|
||||
excel.SetCellValue(2, 5, "請假類別", titleStyleCenter);
|
||||
excel.SetCellValue(2, 6, "請假時數", titleStyleCenter);
|
||||
excel.SetCellValue(2, 7, "代理人", titleStyleCenter);
|
||||
excel.SetCellValue(2, 8, "請假事由", titleStyleCenter);
|
||||
excel.SetCellValue(2, 9, "備註", titleStyleCenter);
|
||||
excel.SetRowHeight(2, BodyRowHeight);
|
||||
|
||||
#endregion
|
||||
|
||||
#region 報表資料
|
||||
|
||||
DateTime 月初 = 報表時間;
|
||||
DateTime 月底 = 報表時間.AddMonths(1).AddDays(-1);
|
||||
|
||||
var summarys = new List<Summary>()
|
||||
{
|
||||
new Summary() { Title = "補休" , RparTyps = new List<string>() { RPAR_TYPE.T00_補休 } },
|
||||
new Summary() { Title = "特休" , RparTyps = new List<string>() { RPAR_TYPE.T01_特休 } } ,
|
||||
new Summary() { Title = "事假" , RparTyps = new List<string>() { RPAR_TYPE.T02_事假 } },
|
||||
new Summary() { Title = "病假" , RparTyps = new List<string>() { RPAR_TYPE.T03_病假 } },
|
||||
new Summary() { Title = "喪假" , RparTyps = new List<string>() { RPAR_TYPE.T04_喪假 } },
|
||||
new Summary() { Title = "產假" , RparTyps = new List<string>() { RPAR_TYPE.T05_產假 } },
|
||||
new Summary() { Title = "婚假" , RparTyps = new List<string>() { RPAR_TYPE.T06_婚假 } },
|
||||
new Summary() { Title = "陪產假" , RparTyps = new List<string>() { RPAR_TYPE.T07_陪產假 } },
|
||||
new Summary() { Title = "公假(出)" , RparTyps = new List<string>() { RPAR_TYPE.T08_公假 } },
|
||||
new Summary() { Title = "公傷假" , RparTyps = new List<string>() { RPAR_TYPE.T09_公傷假 } },
|
||||
new Summary() { Title = "生理假" , RparTyps = new List<string>() { RPAR_TYPE.T0A_生理假 } },
|
||||
new Summary() { Title = "家庭照顧假" , RparTyps = new List<string>() { RPAR_TYPE.T0B_家庭照顧假 } },
|
||||
new Summary() { Title = "育嬰假" , RparTyps = new List<string>() { RPAR_TYPE.T0C_育嬰假 } },
|
||||
new Summary() { Title = "原民祭儀假" , RparTyps = new List<string>() { RPAR_TYPE.T0D_原民祭儀假 } },
|
||||
new Summary() { Title = "產檢假" , RparTyps = new List<string>() { RPAR_TYPE.T0E_產檢假 } },
|
||||
new Summary() { Title = "其他假別(一)", RparTyps = new List<string>() { RPAR_TYPE.T0F_防疫照顧假,
|
||||
RPAR_TYPE.T0G_無薪假,
|
||||
RPAR_TYPE.T0H_防疫隔離假 } }
|
||||
};
|
||||
|
||||
int 總時數 = 0;
|
||||
|
||||
int rowId = 3;
|
||||
foreach (DataRow r in 資料來源.Tables[0].Rows)
|
||||
{
|
||||
DateTime 起日 = WDAC.GetDateTimeValue(r["RPRDT"]);
|
||||
DateTime 迄日 = WDAC.GetDateTimeValue(r["RPEDT"]);
|
||||
string 起時 = WDAC.GetStringValue(r["RPRTM"]);
|
||||
string 迄時 = WDAC.GetStringValue(r["RPETM"]);
|
||||
string 類別 = WDAC.GetStringValue(r["RPTYP"]);
|
||||
|
||||
if (起日 < 月初)
|
||||
{
|
||||
起日 = 月初;
|
||||
起時 = timeCalc.上班時間;
|
||||
}
|
||||
if (迄日 > 月底)
|
||||
{
|
||||
迄日 = 月底;
|
||||
迄時 = timeCalc.下班時間;
|
||||
}
|
||||
|
||||
//Double 時數 = WDAC.GetDoubleValue(r["RPTCT"]) / 60;
|
||||
int 時數 = timeCalc.計算請假總時數(WDAC.GetStringValue(資料來源.Tables[0].Rows[0]["RPNUM"]), 起日, 迄日, 起時, 迄時, 類別, !以時分顯示時數);
|
||||
總時數 += 時數;
|
||||
|
||||
#region 區分假別統計
|
||||
var summary = summarys.FirstOrDefault(p => p.RparTyps.Contains(類別));
|
||||
if (summary != null) {
|
||||
summary.Minutes += 時數;
|
||||
}
|
||||
#endregion
|
||||
|
||||
excel.SetCellValue(rowId, 0, 起日.ToString("MM月dd日"), titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 1, "~", titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 2, 迄日.ToString("MM月dd日"), titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 3, 起時, titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 4, 迄時, titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 5, WDAC.GetStringValue(r["類別"]), titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 6, MinuteToTime(時數), titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 7, WDAC.GetStringValue(r["RPAGT"]), titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 8, WDAC.GetStringValue(r["RPRSN"]), bodyStyleCenterS);
|
||||
excel.SetCellValue(rowId, 9, WDAC.GetStringValue(r["RPDOC"]), bodyStyleCenterS);
|
||||
excel.SetRowHeight(rowId, BodyRowHeight);
|
||||
rowId++;
|
||||
}
|
||||
|
||||
#region 底下的統計
|
||||
var summaryRows = summarys.Count + 1;
|
||||
|
||||
excel.MergeCell(rowId + 2, 2, rowId + summaryRows, 3);
|
||||
excel.MergeCell(rowId + 2, 4, rowId + summaryRows, 4);
|
||||
excel.MergeCell(rowId + 2, 5, rowId + summaryRows, 5);
|
||||
excel.SetCellValue(rowId + 2, 2, "總請假時數:", titleStyleRightNoBorder);
|
||||
excel.SetCellValue(rowId + 2, 4, MinuteToTime(總時數), titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(rowId + 2, 5, "hrs", titleStyleLeftNoBorder);
|
||||
excel.SetRangeOuterBorder(rowId + 2, 2, rowId + summaryRows, 5, BorderStyle.Thin);
|
||||
|
||||
var rr = 2;
|
||||
foreach (var symmary in summarys)
|
||||
{
|
||||
excel.SetCellValue(rowId + rr, 6, symmary.Title + ":", titleStyleLeftNoBorder);
|
||||
excel.SetCellValue(rowId + rr, 7, MinuteToTime(symmary.Minutes), titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(rowId + rr, 8, "hrs", titleStyleLeftNoBorder);
|
||||
excel.SetRangeOuterBorder(rowId + rr, 6, rowId + rr, 8, BorderStyle.Thin);
|
||||
excel.SetRowHeight(rowId + rr, BodyRowHeight);
|
||||
rr++;
|
||||
}
|
||||
|
||||
rowId += summaryRows;
|
||||
#endregion
|
||||
|
||||
#region 表尾批示
|
||||
|
||||
//excel.MergeCell(rowId + 10, 0, rowId + 10, 9);
|
||||
//excel.SetCellValue(rowId + 10, 0, "申請人: 計畫督導: 人事單位:", titleStyleLeftNoBorder);
|
||||
//excel.SetRowHeight(rowId + 10, BodyRowHeight);
|
||||
|
||||
//excel.MergeCell(rowId + 1, 1, rowId + 1, 3);
|
||||
//excel.MergeCell(rowId + 2, 1, rowId + 2, 3);
|
||||
//excel.SetCellValue(rowId + 1, 1, "申請人", titleStyleCenter);
|
||||
//excel.SetRangeOuterBorder(rowId + 1, 1, rowId + 1, 3, BorderStyle.Thin);
|
||||
//excel.SetRangeOuterBorder(rowId + 2, 1, rowId + 2, 3, BorderStyle.Thin);
|
||||
|
||||
//excel.MergeCell(rowId + 1, 4, rowId + 1, 6);
|
||||
//excel.MergeCell(rowId + 2, 4, rowId + 2, 6);
|
||||
//excel.SetCellValue(rowId + 1, 4, "公司計畫督導", titleStyleCenter);
|
||||
//excel.SetRangeOuterBorder(rowId + 1, 4, rowId + 1, 6, BorderStyle.Thin);
|
||||
//excel.SetRangeOuterBorder(rowId + 2, 4, rowId + 2, 6, BorderStyle.Thin);
|
||||
|
||||
//excel.MergeCell(rowId + 1, 7, rowId + 1, 8);
|
||||
//excel.MergeCell(rowId + 2, 7, rowId + 2, 8);
|
||||
//excel.SetCellValue(rowId + 1, 7, "公司計畫主持人", titleStyleCenter);
|
||||
//excel.SetRangeOuterBorder(rowId + 1, 7, rowId + 1, 8, BorderStyle.Thin);
|
||||
//excel.SetRangeOuterBorder(rowId + 2, 7, rowId + 2, 8, BorderStyle.Thin);
|
||||
|
||||
//excel.SetRowHeight(rowId + 1, BodyRowHeight);
|
||||
//excel.SetRowHeight(rowId + 2, BodyRowHeight);
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
excel.SetColumnWidth(0, 11);
|
||||
excel.SetColumnWidth(1, 4);
|
||||
excel.SetColumnWidth(2, 11);
|
||||
excel.SetColumnWidth(3, 11);
|
||||
excel.SetColumnWidth(4, 11);
|
||||
excel.SetColumnWidth(5, 11);
|
||||
excel.SetColumnWidth(6, 18);
|
||||
excel.SetColumnWidth(7, 12);
|
||||
excel.SetColumnWidth(8, 20);
|
||||
excel.SetColumnWidth(9, 15);
|
||||
|
||||
MemoryStream ms = new MemoryStream();
|
||||
workbook.Write(ms);
|
||||
return ms;
|
||||
}
|
||||
}
|
||||
|
||||
class Summary
|
||||
{
|
||||
public string Title;
|
||||
public int Minutes;
|
||||
public List<string> RparTyps;
|
||||
}
|
||||
Reference in New Issue
Block a user