This commit is contained in:
liqionghai 2025-08-28 00:32:00 +08:00
parent 2d1033548e
commit 036dbdeb9b

View File

@ -101,17 +101,38 @@ namespace Pilot.Report.Exploitation.AccountsReceivable
// 创建一个单元格样式------------------------------- // 创建一个单元格样式-------------------------------
ICellStyle cellStyle = workbook.CreateCellStyle(); ICellStyle cellStyle = workbook.CreateCellStyle();
//创建字体格式为Times New Roman字体大小为10号
IFont font1 = workbook.CreateFont();
font1.FontName = "Times New Roman";
font1.FontHeightInPoints = 10;
// 设置边框样式 // 设置边框样式
cellStyle.BorderTop = BorderStyle.Thin; cellStyle.BorderTop = BorderStyle.Thin;
cellStyle.BorderBottom = BorderStyle.Thin; cellStyle.BorderBottom = BorderStyle.Thin;
cellStyle.BorderLeft = BorderStyle.Thin; cellStyle.BorderLeft = BorderStyle.Thin;
cellStyle.BorderRight = BorderStyle.Thin; cellStyle.BorderRight = BorderStyle.Thin;
// 设置水平居中对齐 // 设置水平居中对齐
cellStyle.Alignment = HorizontalAlignment.Center; cellStyle.Alignment = HorizontalAlignment.Right;
// 设置垂直居中对齐 // 设置垂直居中对齐
cellStyle.VerticalAlignment = VerticalAlignment.Center; cellStyle.VerticalAlignment = VerticalAlignment.Center;
//设置数值格式保留两位小数 //设置数值格式保留两位小数
cellStyle.DataFormat = workbook.CreateDataFormat().GetFormat("0.00"); cellStyle.DataFormat = workbook.CreateDataFormat().GetFormat("#,##0.00");
//设置字体和大小
cellStyle.SetFont(font1);
ICellStyle cellStyle3 = workbook.CreateCellStyle();
// 设置边框样式
cellStyle3.BorderTop = BorderStyle.Thin;
cellStyle3.BorderBottom = BorderStyle.Thin;
cellStyle3.BorderLeft = BorderStyle.Thin;
cellStyle3.BorderRight = BorderStyle.Thin;
// 设置水平居中对齐
cellStyle3.Alignment = HorizontalAlignment.Center;
// 设置垂直居中对齐
cellStyle3.VerticalAlignment = VerticalAlignment.Center;
//设置字体和大小
cellStyle3.SetFont(font1);
// 创建一个单元格样式--------------------------------- // 创建一个单元格样式---------------------------------
ICellStyle cellStyle2 = workbook.CreateCellStyle(); ICellStyle cellStyle2 = workbook.CreateCellStyle();
@ -121,6 +142,8 @@ namespace Pilot.Report.Exploitation.AccountsReceivable
cellStyle2.BorderBottom = BorderStyle.Thin; cellStyle2.BorderBottom = BorderStyle.Thin;
cellStyle2.BorderLeft = BorderStyle.Thin; cellStyle2.BorderLeft = BorderStyle.Thin;
cellStyle2.BorderRight = BorderStyle.Thin; cellStyle2.BorderRight = BorderStyle.Thin;
//设置字体和大小
cellStyle2.SetFont(font1);
// 创建单元格样式--------------------------------------- // 创建单元格样式---------------------------------------
ICellStyle style = workbook.CreateCellStyle(); ICellStyle style = workbook.CreateCellStyle();
@ -134,7 +157,8 @@ namespace Pilot.Report.Exploitation.AccountsReceivable
// 创建字体并设置为加粗 // 创建字体并设置为加粗
IFont font = workbook.CreateFont(); IFont font = workbook.CreateFont();
font.IsBold = true; // 设置字体加粗 font.IsBold = true; // 设置字体加粗
font.FontName = "Times New Roman";
font.FontHeightInPoints = 10;
// 将字体应用到单元格样式 // 将字体应用到单元格样式
style.SetFont(font); style.SetFont(font);
@ -144,7 +168,8 @@ namespace Pilot.Report.Exploitation.AccountsReceivable
// 创建字体并设置为加粗 // 创建字体并设置为加粗
IFont font2 = workbook.CreateFont(); IFont font2 = workbook.CreateFont();
font2.IsBold = true; // 设置字体加粗 font2.IsBold = true; // 设置字体加粗
font2.FontName = "Times New Roman";
font2.FontHeightInPoints = 10;
// 将字体应用到单元格样式 // 将字体应用到单元格样式
style2.SetFont(font2); style2.SetFont(font2);
@ -157,15 +182,17 @@ namespace Pilot.Report.Exploitation.AccountsReceivable
style3.BorderLeft = BorderStyle.Thin; style3.BorderLeft = BorderStyle.Thin;
style3.BorderRight = BorderStyle.Thin; style3.BorderRight = BorderStyle.Thin;
// 设置水平居中对齐 // 设置水平居中对齐
style3.Alignment = HorizontalAlignment.Center; style3.Alignment = HorizontalAlignment.Right;
// 设置垂直居中对齐 // 设置垂直居中对齐
style3.VerticalAlignment = VerticalAlignment.Center; style3.VerticalAlignment = VerticalAlignment.Center;
// 创建字体并设置为加粗 // 创建字体并设置为加粗
IFont font3 = workbook.CreateFont(); IFont font3 = workbook.CreateFont();
font3.IsBold = true; // 设置字体加粗 font3.IsBold = true; // 设置字体加粗
font3.FontName = "Times New Roman";
font3.FontHeightInPoints = 10;
// 将字体应用到单元格样式 // 将字体应用到单元格样式
style3.SetFont(font3); style3.SetFont(font3);
style3.DataFormat = workbook.CreateDataFormat().GetFormat("0.00"); style3.DataFormat = workbook.CreateDataFormat().GetFormat("#,##0.00");
// 创建一个单元格样式------------------------------- // 创建一个单元格样式-------------------------------
@ -182,7 +209,23 @@ namespace Pilot.Report.Exploitation.AccountsReceivable
style4.VerticalAlignment = VerticalAlignment.Center; style4.VerticalAlignment = VerticalAlignment.Center;
// 将字体应用到单元格样式 // 将字体应用到单元格样式
style4.SetFont(font3); style4.SetFont(font3);
style4.DataFormat = workbook.CreateDataFormat().GetFormat("0.00"); style4.DataFormat = workbook.CreateDataFormat().GetFormat("#,##0.00");
// 创建一个单元格样式-------------------------------
ICellStyle style5 = workbook.CreateCellStyle();
// 设置边框样式
style5.BorderTop = BorderStyle.Thin;
style5.BorderBottom = BorderStyle.Thin;
style5.BorderLeft = BorderStyle.Thin;
style5.BorderRight = BorderStyle.Thin;
// 设置水平居中对齐
style5.Alignment = HorizontalAlignment.Center;
// 设置垂直居中对齐
style5.VerticalAlignment = VerticalAlignment.Center;
// 将字体应用到单元格样式
style5.SetFont(font3);
#endregion #endregion
#region #region
@ -219,7 +262,7 @@ namespace Pilot.Report.Exploitation.AccountsReceivable
//将新创建或获取的单元格的值修改 //将新创建或获取的单元格的值修改
cell22.SetCellValue(""); cell22.SetCellValue("");
var YFHpriceSumZW = ToChineseNumber(YFHpriceSum, Context); var YFHpriceSumZW = ToChineseNumber(YFHpriceSum, Context);
cell3.SetCellValue("贵公司截至 " + fDate + " 共欠我公司货款金额为:" + YFHpriceSum + "元(大写:" + YFHpriceSumZW + ""); cell3.SetCellValue("贵公司截至 " + (string.IsNullOrWhiteSpace(fDate) ? DateTime.Now.ToString("yyyy-MM-dd") : fDate) + " 共欠我公司货款金额为:" + YFHpriceSum.ToString("N") + "元(大写:" + YFHpriceSumZW + "");
//将新创建或获取的单元格的值修改 //将新创建或获取的单元格的值修改
cell.SetCellValue("尊敬的 " + fClient + " 客户您好,我公司已根据合同/订单的要求向贵公司交付相关产品并请验收确认,鉴于我公司对贵公司已通知发货部分的交付义务已完成,"); cell.SetCellValue("尊敬的 " + fClient + " 客户您好,我公司已根据合同/订单的要求向贵公司交付相关产品并请验收确认,鉴于我公司对贵公司已通知发货部分的交付义务已完成,");
cell2.SetCellValue(fClient); cell2.SetCellValue(fClient);
@ -244,7 +287,7 @@ namespace Pilot.Report.Exploitation.AccountsReceivable
for (var i = 0; i < list.Count; i++) for (var i = 0; i < list.Count; i++)
{ {
string date = string.IsNullOrWhiteSpace(list[i]["DATE"].ToString()) ? "" : list[i]["DATE"].ToString().Split(' ')[0]; string date = string.IsNullOrWhiteSpace(list[i]["DATE"].ToString()) ? "" : Convert.ToDateTime(list[i]["DATE"].ToString().Split(' ')[0]).ToString("yyyy/M/d");
decimal OrderAmount = string.IsNullOrWhiteSpace(list[i]["OrderAmount"].ToString()) ? 0 : Math.Round(Convert.ToDecimal(list[i]["OrderAmount"]), 2); decimal OrderAmount = string.IsNullOrWhiteSpace(list[i]["OrderAmount"].ToString()) ? 0 : Math.Round(Convert.ToDecimal(list[i]["OrderAmount"]), 2);
decimal ShipmentsAmount = string.IsNullOrWhiteSpace(list[i]["ShipmentsAmount"].ToString()) ? 0 : Math.Round(Convert.ToDecimal(list[i]["ShipmentsAmount"]), 2); decimal ShipmentsAmount = string.IsNullOrWhiteSpace(list[i]["ShipmentsAmount"].ToString()) ? 0 : Math.Round(Convert.ToDecimal(list[i]["ShipmentsAmount"]), 2);
decimal FBillAllAmount = string.IsNullOrWhiteSpace(list[i]["FBillAllAmount"].ToString()) ? 0 : Math.Round(Convert.ToDecimal(list[i]["FBillAllAmount"]), 2); decimal FBillAllAmount = string.IsNullOrWhiteSpace(list[i]["FBillAllAmount"].ToString()) ? 0 : Math.Round(Convert.ToDecimal(list[i]["FBillAllAmount"]), 2);
@ -261,7 +304,7 @@ namespace Pilot.Report.Exploitation.AccountsReceivable
// j = 12; // j = 12;
//} //}
ICell c1 = rowi.CreateCell(0); c1.SetCellValue(list[i]["Number"].ToString()); c1.CellStyle = cellStyle; ICell c1 = rowi.CreateCell(0); c1.SetCellValue(list[i]["Number"].ToString()); c1.CellStyle = cellStyle3;
ICell c2 = rowi.CreateCell(1); c2.SetCellValue(""+date+""); c2.CellStyle = cellStyle2; ICell c2 = rowi.CreateCell(1); c2.SetCellValue(""+date+""); c2.CellStyle = cellStyle2;
ICell c3 = rowi.CreateCell(2); c3.SetCellValue(list[i]["CONTRACTNUMBER"].ToString()); c3.CellStyle = cellStyle2; ICell c3 = rowi.CreateCell(2); c3.SetCellValue(list[i]["CONTRACTNUMBER"].ToString()); c3.CellStyle = cellStyle2;
ICell c4 = rowi.CreateCell(3); c4.SetCellValue(list[i]["ProjectName"].ToString()); c4.CellStyle = cellStyle2; ICell c4 = rowi.CreateCell(3); c4.SetCellValue(list[i]["ProjectName"].ToString()); c4.CellStyle = cellStyle2;
@ -272,12 +315,12 @@ namespace Pilot.Report.Exploitation.AccountsReceivable
ICell c9 = rowi.CreateCell(8); c9.SetCellValue(Convert.ToDouble(PaymentAmount )); c9.CellStyle = cellStyle; ICell c9 = rowi.CreateCell(8); c9.SetCellValue(Convert.ToDouble(PaymentAmount )); c9.CellStyle = cellStyle;
ICell c10 = rowi.CreateCell(9); c10.SetCellValue(Convert.ToDouble(ShippedDebt )); c10.CellStyle = cellStyle; ICell c10 = rowi.CreateCell(9); c10.SetCellValue(Convert.ToDouble(ShippedDebt )); c10.CellStyle = cellStyle;
ICell c11 = rowi.CreateCell(10); c11.SetCellValue(Convert.ToDouble(InvoicedDebt)); c11.CellStyle = cellStyle; ICell c11 = rowi.CreateCell(10); c11.SetCellValue(Convert.ToDouble(InvoicedDebt)); c11.CellStyle = cellStyle;
ICell c12 = rowi.CreateCell(11); c12.SetCellValue(list[i]["IsEnded"].ToString()); c12.CellStyle = cellStyle2; ICell c12 = rowi.CreateCell(11); c12.SetCellValue(list[i]["IsEnded"].ToString()); c12.CellStyle = cellStyle3;
ICell c13 = rowi.CreateCell(12); c13.SetCellValue(list[i]["Remark"].ToString()); c13.CellStyle = cellStyle2; //ICell c13 = rowi.CreateCell(12); c13.SetCellValue(list[i]["Remark"].ToString()); c13.CellStyle = cellStyle2;
n++; n++;
if(list[i]["Number"].ToString() == "合计") if(list[i]["Number"].ToString() == "合计")
{ {
c1.CellStyle = style3; c1.CellStyle = style5;
c2.CellStyle = style3; c2.CellStyle = style3;
c3.CellStyle = style3; c3.CellStyle = style3;
c4.CellStyle = style3; c4.CellStyle = style3;
@ -289,7 +332,7 @@ namespace Pilot.Report.Exploitation.AccountsReceivable
c10.CellStyle = style3; c10.CellStyle = style3;
c11.CellStyle = style3; c11.CellStyle = style3;
c12.CellStyle = style3; c12.CellStyle = style3;
c13.CellStyle = style3; //c13.CellStyle = style3;
} }
} }