//拷贝
sheet.Cells["6:12"].Copy(sheet.Cells["1:2"]);
//边框无
sheet.Cells[(i * 6 + i + j), 2].Style.Border.Right.Style = ExcelBorderStyle.None;
//设边框颜色
sheet.Cells[5, 5 + i].Style.Border.Right.Style = ExcelBorderStyle.Thin;
sheet.Cells[5, 5 + i].Style.Border.Right.Color.SetColor(Color.FromArgb(223, 223, 223));
//背景色
sheet.Cells[5, 5 + i].Style.Fill.PatternType = ExcelFillStyle.Solid;
sheet.Cells[5, 5 + i].Style.Fill.BackgroundColor.SetColor(Color.FromArgb(89, 89, 89));
//垂直居中
sheet.Cells[5, 5 + i].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
//上下居中
sheet.Cells[5, 5 + i].Style.VerticalAlignment = ExcelVerticalAlignment.Center;
//字体颜色
sheet.Cells[5, 5 + i].Style.Font.Color.SetColor(Color.FromArgb(255, 255, 255));
using (ExcelPackage p = new ExcelPackage(fi))
{
foreach (ExcelWorksheet sheet in p.Workbook.Worksheets)
{
//Template
switch (selectProject)
{
case "0":
for (int i = 2; i < rtList.Count; i++)
{
sheet.Cells["6:12"].Copy(sheet.Cells[(i * 6 + i - 1) + ":" + (i * 6 + i + 5)]);
if (i == rtList.Count - 1)
{
for (int j = -1; j < 6; j++)
{
sheet.Cells[(i * 6 + i + j), 2].Style.Border.Right.Style = ExcelBorderStyle.None;
sheet.Cells[(i * 6 + i + j), 1].Style.Border.Right.Style = ExcelBorderStyle.None;
}
}
}
break;
case "1":
for (int i = 2; i < rtList.Count; i++)
{
sheet.Cells["6:7"].Copy(sheet.Cells[(6 + i + i - 2) + ":" + (6 + i + i - 1)]);
if (i == rtList.Count - 1)
{
sheet.Cells[(6 + i + i - 2 ), 1, (6 + i + i - 1),1].Style.Border.Right.Style = ExcelBorderStyle.None;
sheet.Cells[(6 + i + i - 2), 2, (6 + i + i - 1), 2].Style.Border.Right.Style = ExcelBorderStyle.None;
sheet.Cells[(6 + i + i - 2), 3, (6 + i + i - 1), 3].Style.Border.Left.Style = ExcelBorderStyle.None;
sheet.Cells[(6 + i + i - 2), 2, (6 + i + i - 1), 2].Style.Border.Left.Style = ExcelBorderStyle.None;
}
}
break;
case "2":
for (int i = 2; i < rtList.Count; i++)
{
sheet.Cells["6:9"].Copy(sheet.Cells[(i * 4 + 2) + ":" + (i * 4 + 5)]);
if (i == rtList.Count - 1)
{
for (int j = 0; j < 4; j++)
{
sheet.Cells[(i * 4 + 2 + j), 2].Style.Border.Right.Style = ExcelBorderStyle.None;
sheet.Cells[(i * 4 + 2 + j), 1].Style.Border.Right.Style = ExcelBorderStyle.None;
}
}
}
break;
}
//Title
sheet.Cells[1, 2].Value = bs.MEASURES_NM.ToString();
sheet.Cells[2, 2].Value = bs.MEASURES_OVERVIEW.ToString();
sheet.Cells[3, 2].Value = bs.BEGIN_DATE.ToString() + " ~ " + bs.END_DATE.ToString();
//TableTitle
sheet.Cells[5, 1].Value="分類";
sheet.Cells[5, 2].Value="媒体属性";
sheet.Cells[5, 3].Value="ASP/ASID/AS名/運営者";
sheet.Cells[5, 4].Value="項目";
for (int i = 0; i < rtList[0].DETAIL_TITLE.Count(); i++)
{
sheet.Cells[5, 5 + i].Value = rtList[0].DETAIL_TITLE[i].ToString().Replace("年", "/").Replace("月", "").Substring(2);
}
//Contents
int currentrow = 6;
for (int i = 1; i < rtList.Count; i++)
{
switch (selectProject)
{
case "0":
#region すべて
//1 DataRow
sheet.Cells[currentrow, 1].Value = rtList[i].PROM_NM;
sheet.Cells[currentrow, 2].Value = rtList[i].SITE_CATEGORY;
sheet.Cells[currentrow, 3].Value = rtList[i].ASP_ID;
sheet.Cells[currentrow, 4].Value = MBProject.PV数.ToString();
for (int j = 0; j < rtList[i].DETAIL.PV_CNT_LIST.Count(); j++)
{
sheet.Cells[currentrow, 5 + j].Value = rtList[i].DETAIL.PV_CNT_LIST[j].CalculateValue;
}
//2 DataRow
sheet.Cells[currentrow + 1, 3].Value = rtList[i].AS_ID;
sheet.Cells[currentrow + 1, 4].Value = MBProject.Click数.ToString();
for (int j = 0; j < rtList[i].DETAIL.CL_CNT_LIST.Count(); j++)
{
sheet.Cells[currentrow + 1, 5 + j].Value = rtList[i].DETAIL.CL_CNT_LIST[j].CalculateValue;
}
//3 DataRow
sheet.Cells[currentrow + 2, 3].Formula = "HYPERLINK(\"" + rtList[i].URL + "\",\"" + rtList[i].AS_NM + "\")";
sheet.Cells[currentrow + 2, 4].Value = MBProject.Click率.ToString();
for (int j = 0; j < rtList[i].DETAIL.CL_RATE_LIST.Count(); j++)
{
sheet.Cells[currentrow + 2, 5 + j].Value = rtList[i].DETAIL.CL_RATE_LIST[j].FormateValue;
}
//4 DataRow
sheet.Cells[currentrow + 3, 3].Value = rtList[i].UNEI_USER_NAME;
sheet.Cells[currentrow + 3, 4].Value = MBProject.申込数.ToString();
for (int j = 0; j < rtList[i].DETAIL.MOSHI_CNT_LIST.Count(); j++)
{
sheet.Cells[currentrow + 3, 5 + j].Value = rtList[i].DETAIL.MOSHI_CNT_LIST[j].CalculateValue;
}
//5 DataRow
sheet.Cells[currentrow + 4, 4].Value = MBProject.CV率.ToString();
for (int j = 0; j < rtList[i].DETAIL.CV_RATE_LIST.Count(); j++)
{
sheet.Cells[currentrow + 4, 5 + j].Value = rtList[i].DETAIL.CV_RATE_LIST[j].FormateValue;
}
//6 DataRow
sheet.Cells[currentrow + 5, 4].Value = MBProject.契約数.ToString();
for (int j = 0; j < rtList[i].DETAIL.KEIYAKU_CNT_LIST.Count(); j++)
{
sheet.Cells[currentrow + 5, 5 + j].Value = rtList[i].DETAIL.KEIYAKU_CNT_LIST[j].CalculateValue;
}
//7 DataRow
sheet.Cells[currentrow + 6, 4].Value = MBProject.契約率.ToString();
for (int j = 0; j < rtList[i].DETAIL.KEIYAKU_RATE_LIST.Count(); j++)
{
sheet.Cells[currentrow + 6, 5 + j].Value = rtList[i].DETAIL.KEIYAKU_RATE_LIST[j].FormateValue;
}
currentrow += 7;
#endregion
break;
case "1":
#region 申込数
//1 DataRow 申込数
sheet.Cells[currentrow, 1].Value = rtList[i].PROM_NM;
sheet.Cells[currentrow, 2].Value = rtList[i].SITE_CATEGORY;
sheet.Cells[currentrow, 3].Formula = "HYPERLINK(\"" + rtList[i].URL + "\",\"" + rtList[i].AS_NM + "\")";
sheet.Cells[currentrow + 1, 3].Value = rtList[i].UNEI_USER_NAME;
sheet.Cells[currentrow, 4].Value = MBProject.申込数.ToString();
for (int j = 0; j < rtList[i].DETAIL.MOSHI_CNT_LIST.Count(); j++)
{
sheet.Cells[currentrow, 5 + j].Value = rtList[i].DETAIL.MOSHI_CNT_LIST[j].CalculateValue;
}
currentrow += 2;
#endregion
break;
case "2":
#region 申込数?CV率?契約数?契約率
//1 DataRow 申込数
sheet.Cells[currentrow, 1].Value = rtList[i].PROM_NM;
sheet.Cells[currentrow, 2].Value = rtList[i].SITE_CATEGORY;
sheet.Cells[currentrow, 3].Value = rtList[i].ASP_ID;
sheet.Cells[currentrow, 4].Value = MBProject.申込数.ToString();
for (int j = 0; j < rtList[i].DETAIL.MOSHI_CNT_LIST.Count(); j++)
{
sheet.Cells[currentrow, 5 + j].Value = rtList[i].DETAIL.MOSHI_CNT_LIST[j].CalculateValue;
}
//2 DataRow CV率
sheet.Cells[currentrow + 1, 3].Value = rtList[i].AS_ID;
sheet.Cells[currentrow + 1, 4].Value = MBProject.CV率.ToString();
for (int j = 0; j < rtList[i].DETAIL.CV_RATE_LIST.Count(); j++)
{
sheet.Cells[currentrow + 1, 5 + j].Value = rtList[i].DETAIL.CV_RATE_LIST[j].FormateValue;
}
//3 DataRow 契約数
sheet.Cells[currentrow + 2, 3].Formula = "HYPERLINK(\"" + rtList[i].URL + "\",\"" + rtList[i].AS_NM + "\")";
sheet.Cells[currentrow + 2, 4].Value = MBProject.契約数.ToString();
for (int j = 0; j < rtList[i].DETAIL.KEIYAKU_CNT_LIST.Count(); j++)
{
sheet.Cells[currentrow + 2, 5 + j].Value = rtList[i].DETAIL.KEIYAKU_CNT_LIST[j].CalculateValue;
}
//4 DataRow 契約率
sheet.Cells[currentrow + 3, 3].Value = rtList[i].UNEI_USER_NAME;
sheet.Cells[currentrow + 3, 4].Value = MBProject.契約率.ToString();
for (int j = 0; j < rtList[i].DETAIL.KEIYAKU_RATE_LIST.Count(); j++)
{
sheet.Cells[currentrow + 3, 5 + j].Value = rtList[i].DETAIL.KEIYAKU_RATE_LIST[j].FormateValue;
}
currentrow += 4;
#endregion
break;
}
}
}
p.Workbook.Worksheets[1].View.TabSelected = true;
p.Save();
}