Merge branch 'master' of http://8.130.121.29:3000/Develop/Piolot_RepotForm_PeiHao
This commit is contained in:
commit
031ca9c828
@ -101,17 +101,38 @@ namespace Pilot.Report.Exploitation.AccountsReceivable
|
||||
// 创建一个单元格样式-------------------------------
|
||||
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.BorderBottom = BorderStyle.Thin;
|
||||
cellStyle.BorderLeft = BorderStyle.Thin;
|
||||
cellStyle.BorderRight = BorderStyle.Thin;
|
||||
// 设置水平居中对齐
|
||||
cellStyle.Alignment = HorizontalAlignment.Center;
|
||||
cellStyle.Alignment = HorizontalAlignment.Right;
|
||||
// 设置垂直居中对齐
|
||||
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();
|
||||
@ -121,6 +142,12 @@ namespace Pilot.Report.Exploitation.AccountsReceivable
|
||||
cellStyle2.BorderBottom = BorderStyle.Thin;
|
||||
cellStyle2.BorderLeft = BorderStyle.Thin;
|
||||
cellStyle2.BorderRight = BorderStyle.Thin;
|
||||
//设置字体和大小
|
||||
cellStyle2.SetFont(font1);
|
||||
// 设置垂直居中对齐
|
||||
cellStyle2.VerticalAlignment = VerticalAlignment.Center;
|
||||
//自动换行
|
||||
cellStyle2.WrapText = true;
|
||||
|
||||
// 创建单元格样式---------------------------------------
|
||||
ICellStyle style = workbook.CreateCellStyle();
|
||||
@ -134,7 +161,8 @@ namespace Pilot.Report.Exploitation.AccountsReceivable
|
||||
// 创建字体并设置为加粗
|
||||
IFont font = workbook.CreateFont();
|
||||
font.IsBold = true; // 设置字体加粗
|
||||
|
||||
font.FontName = "Times New Roman";
|
||||
font.FontHeightInPoints = 10;
|
||||
// 将字体应用到单元格样式
|
||||
style.SetFont(font);
|
||||
|
||||
@ -144,7 +172,8 @@ namespace Pilot.Report.Exploitation.AccountsReceivable
|
||||
// 创建字体并设置为加粗
|
||||
IFont font2 = workbook.CreateFont();
|
||||
font2.IsBold = true; // 设置字体加粗
|
||||
|
||||
font2.FontName = "Times New Roman";
|
||||
font2.FontHeightInPoints = 10;
|
||||
// 将字体应用到单元格样式
|
||||
style2.SetFont(font2);
|
||||
|
||||
@ -157,15 +186,17 @@ namespace Pilot.Report.Exploitation.AccountsReceivable
|
||||
style3.BorderLeft = BorderStyle.Thin;
|
||||
style3.BorderRight = BorderStyle.Thin;
|
||||
// 设置水平居中对齐
|
||||
style3.Alignment = HorizontalAlignment.Center;
|
||||
style3.Alignment = HorizontalAlignment.Right;
|
||||
// 设置垂直居中对齐
|
||||
style3.VerticalAlignment = VerticalAlignment.Center;
|
||||
// 创建字体并设置为加粗
|
||||
IFont font3 = workbook.CreateFont();
|
||||
font3.IsBold = true; // 设置字体加粗
|
||||
font3.FontName = "Times New Roman";
|
||||
font3.FontHeightInPoints = 10;
|
||||
// 将字体应用到单元格样式
|
||||
style3.SetFont(font3);
|
||||
style3.DataFormat = workbook.CreateDataFormat().GetFormat("0.00");
|
||||
style3.DataFormat = workbook.CreateDataFormat().GetFormat("#,##0.00");
|
||||
|
||||
|
||||
// 创建一个单元格样式-------------------------------
|
||||
@ -182,7 +213,36 @@ namespace Pilot.Report.Exploitation.AccountsReceivable
|
||||
style4.VerticalAlignment = VerticalAlignment.Center;
|
||||
// 将字体应用到单元格样式
|
||||
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);
|
||||
|
||||
|
||||
// 创建单元格样式---------------------------------------
|
||||
ICellStyle style6 = workbook.CreateCellStyle();
|
||||
|
||||
// 创建字体并设置为加粗
|
||||
IFont font5 = workbook.CreateFont();
|
||||
font5.FontName = "Times New Roman";
|
||||
font5.FontHeightInPoints = 10;
|
||||
//font5.IsBold = true; // 设置字体加粗
|
||||
|
||||
// 将字体应用到单元格样式
|
||||
style6.SetFont(font5);
|
||||
#endregion
|
||||
|
||||
#region 获取金额汇总数据
|
||||
@ -219,7 +279,7 @@ namespace Pilot.Report.Exploitation.AccountsReceivable
|
||||
//将新创建或获取的单元格的值修改
|
||||
cell22.SetCellValue("");
|
||||
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 + " 客户您好,我公司已根据合同/订单的要求向贵公司交付相关产品并请验收确认,鉴于我公司对贵公司已通知发货部分的交付义务已完成,");
|
||||
cell2.SetCellValue(fClient);
|
||||
@ -244,7 +304,7 @@ namespace Pilot.Report.Exploitation.AccountsReceivable
|
||||
|
||||
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 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);
|
||||
@ -261,7 +321,7 @@ namespace Pilot.Report.Exploitation.AccountsReceivable
|
||||
// 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 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;
|
||||
@ -272,12 +332,12 @@ namespace Pilot.Report.Exploitation.AccountsReceivable
|
||||
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 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 c13 = rowi.CreateCell(12); c13.SetCellValue(list[i]["Remark"].ToString()); c13.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;
|
||||
n++;
|
||||
if(list[i]["Number"].ToString() == "合计")
|
||||
{
|
||||
c1.CellStyle = style3;
|
||||
c1.CellStyle = style5;
|
||||
c2.CellStyle = style3;
|
||||
c3.CellStyle = style3;
|
||||
c4.CellStyle = style3;
|
||||
@ -289,7 +349,7 @@ namespace Pilot.Report.Exploitation.AccountsReceivable
|
||||
c10.CellStyle = style3;
|
||||
c11.CellStyle = style3;
|
||||
c12.CellStyle = style3;
|
||||
c13.CellStyle = style3;
|
||||
//c13.CellStyle = style3;
|
||||
}
|
||||
}
|
||||
|
||||
@ -302,9 +362,9 @@ namespace Pilot.Report.Exploitation.AccountsReceivable
|
||||
IRow rr1 = sheet2.GetRow(15);
|
||||
IRow rr2 = sheet2.GetRow(16);
|
||||
IRow rr3 = sheet2.GetRow(17);
|
||||
ICell cc1 = rr1.GetCell(6);
|
||||
ICell cc2 = rr2.GetCell(6);
|
||||
ICell cc3 = rr3.GetCell(6);
|
||||
ICell cc1 = rr1.GetCell(6 + 1);
|
||||
ICell cc2 = rr2.GetCell(6 + 1);
|
||||
ICell cc3 = rr3.GetCell(6 + 1);
|
||||
cc1.SetCellValue(Convert.ToDouble(YFHpriceSum));
|
||||
cc2.SetCellValue(Convert.ToDouble(YFPpriceSum));
|
||||
cc3.SetCellValue(Convert.ToDouble(priceSum));
|
||||
@ -339,11 +399,11 @@ namespace Pilot.Report.Exploitation.AccountsReceivable
|
||||
}
|
||||
ICell CR1 = r1.CreateCell(i);
|
||||
CR1.SetCellValue(test1);
|
||||
if (i == 4 || i == 5 || i == 7 || i == 8 || i == 9)
|
||||
if (i == 4 + 1 || i == 5 + 1 || i == 7 + 1 || i == 8 + 1 || i == 9 + 1)
|
||||
{
|
||||
CR1.CellStyle = style;
|
||||
}
|
||||
else if(i == 6)
|
||||
else if(i == 6 + 1)
|
||||
{
|
||||
CR1.SetCellValue(Convert.ToDouble(test1));
|
||||
CR1.CellStyle = style4;
|
||||
@ -364,11 +424,11 @@ namespace Pilot.Report.Exploitation.AccountsReceivable
|
||||
}
|
||||
ICell CR1 = r2.CreateCell(i);
|
||||
CR1.SetCellValue(test1);
|
||||
if (i == 4 || i == 5 || i == 7 || i == 8 || i == 9)
|
||||
if (i == 4 + 1 || i == 5 + 1 || i == 7 + 1 || i == 8 + 1 || i == 9 + 1)
|
||||
{
|
||||
CR1.CellStyle = style;
|
||||
}
|
||||
else if (i == 6)
|
||||
else if (i == 6 + 1)
|
||||
{
|
||||
CR1.SetCellValue(Convert.ToDouble(test1));
|
||||
CR1.CellStyle = style4;
|
||||
@ -389,11 +449,11 @@ namespace Pilot.Report.Exploitation.AccountsReceivable
|
||||
}
|
||||
ICell CR1 = r3.CreateCell(i);
|
||||
CR1.SetCellValue(test1);
|
||||
if (i == 4 || i == 5 || i == 7 || i == 8 || i == 9)
|
||||
if (i == 4 + 1 || i == 5 + 1 || i == 7 + 1 || i == 8 + 1 || i == 9 + 1)
|
||||
{
|
||||
CR1.CellStyle = style;
|
||||
}
|
||||
else if (i == 6)
|
||||
else if (i == 6 + 1)
|
||||
{
|
||||
CR1.SetCellValue(Convert.ToDouble(test1));
|
||||
CR1.CellStyle = style4;
|
||||
@ -431,6 +491,10 @@ namespace Pilot.Report.Exploitation.AccountsReceivable
|
||||
{
|
||||
CR1.CellStyle = style2;
|
||||
}
|
||||
else
|
||||
{
|
||||
CR1.CellStyle = style6;
|
||||
}
|
||||
}
|
||||
|
||||
//第六行
|
||||
@ -447,6 +511,10 @@ namespace Pilot.Report.Exploitation.AccountsReceivable
|
||||
{
|
||||
CR1.CellStyle = style2;
|
||||
}
|
||||
else
|
||||
{
|
||||
CR1.CellStyle = style6;
|
||||
}
|
||||
}
|
||||
|
||||
//第七行
|
||||
@ -463,6 +531,10 @@ namespace Pilot.Report.Exploitation.AccountsReceivable
|
||||
{
|
||||
CR1.CellStyle = style2;
|
||||
}
|
||||
else
|
||||
{
|
||||
CR1.CellStyle = style6;
|
||||
}
|
||||
}
|
||||
|
||||
//合并单元格
|
||||
@ -471,12 +543,12 @@ namespace Pilot.Report.Exploitation.AccountsReceivable
|
||||
// 合并单元格的起始行、结束行、起始列和结束列
|
||||
int firstRow = n + i; // 比如第一行
|
||||
int lastRow = n + i; // 合并到第三行(0-based index)
|
||||
int firstCol = 4; // 比如第一列
|
||||
int firstCol2 = 7; // 比如第一列
|
||||
int firstCol = 4 + 1; // 比如第一列
|
||||
int firstCol2 = 7 + 1; // 比如第一列
|
||||
int firstCol3 = 0; // 比如第一列
|
||||
int lastCol = 5; // 合并到第三列(0-based index)
|
||||
int lastCol2 = 9; // 合并到第三列(0-based index)
|
||||
int lastCol3 = 3; // 合并到第三列(0-based index)
|
||||
int lastCol = 5 + 1; // 合并到第三列(0-based index)
|
||||
int lastCol2 = 9 + 1; // 合并到第三列(0-based index)
|
||||
int lastCol3 = 3 + 1; // 合并到第三列(0-based index)
|
||||
// 创建CellRangeAddress对象
|
||||
CellRangeAddress cellRangeAddress = new CellRangeAddress(firstRow, lastRow, firstCol, lastCol);
|
||||
CellRangeAddress cellRangeAddress2 = new CellRangeAddress(firstRow, lastRow, firstCol2, lastCol2);
|
||||
@ -488,6 +560,8 @@ namespace Pilot.Report.Exploitation.AccountsReceivable
|
||||
}
|
||||
//移除第二个工作表
|
||||
workbook.RemoveSheetAt(1);
|
||||
//重命名工作表
|
||||
workbook.SetSheetName(0,string.Format("简易版{0}",DateTime.Now.ToString("yyyy-MM-dd")));
|
||||
#endregion
|
||||
|
||||
#region Excel代码2
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user