private void Classification(DataTable dt, string[] allType, string[] citylist, ref int startIndex, ref int sheet3Index, ref int sheet6Index, Excel.Worksheet worksheet2, Excel.Worksheet worksheet3, Excel.Worksheet worksheet6, ref string filter)
{
#region 业务类型1、2(第二、三、六个sheet)
for (int m = 0; m < allType.Length; m++)//共48条
{
if (条件)
{
filter = "条件";
Category(dt, allType[m], citylist, ref startIndex, ref sheet3Index, ref sheet6Index, worksheet2, worksheet3, worksheet6, filter);
}
else if (条件)
{
filter = "条件";
Category(dt, allType[m], citylist, ref startIndex, ref sheet3Index, ref sheet6Index, worksheet2, worksheet3, worksheet6, filter);
}
else if (条件)
{
filter = "条件";
Category(dt, allType[m], citylist, ref startIndex, ref sheet3Index, ref sheet6Index, worksheet2, worksheet3, worksheet6, filter);
}
else if (条件)
{
filter = "条件";
Category(dt, allType[m], citylist, ref startIndex, ref sheet3Index, ref sheet6Index, worksheet2, worksheet3, worksheet6, filter);
}
else
{
filter = "条件";
Category(dt, allType[m], citylist, ref startIndex, ref sheet3Index, ref sheet6Index, worksheet2, worksheet3, worksheet6, filter);
}
sheet3Index++;
sheet6Index++;
}
#endregion
}
private void Category(DataTable dt, string Type, string[] citylist, ref int startIndex, ref int sheet3Index, ref int sheet6Index, Excel.Worksheet worksheet2, Excel.Worksheet worksheet3, Excel.Worksheet worksheet6,string filter)
{
#region 第二个sheet
int count;
count = (int)dt.Compute("Count(列名)", filter + "条件");
worksheet2.Cells[startIndex + 1, 4] = count;
startIndex++;
#endregion
for (int i = 0; i < citylist.Length; i++)//共16条
{
string curCity = citylist[i].ToString();
#region 第三sheet
count = (int)dt.Compute("Count(列名)", "故障地市='" + curCity + "' and " + filter);
//count = (int)dt.Compute("Count(故障地市)", "故障地市='" + curCity + "' and 业务类型 like '%" + allType[m] + "'");
if (sheet3Index == 21 || sheet3Index == 37 || sheet3Index == 45 || sheet3Index == 52 || sheet3Index == 58)
{ sheet3Index += 2; }
worksheet3.Cells[sheet3Index, 5 + i] = count;
#endregion
#region 第六个sheet
if (sheet6Index == 22 || sheet6Index == 38 || sheet6Index == 46 || sheet6Index == 53 || sheet6Index == 59)
{ sheet6Index += 2; }
count = (int)dt.Compute("Count(列名)", "列名='" + curCity + "'and " + filter + "条件");
worksheet6.Cells[6 + i * 8, sheet6Index] = count;
count = (int)dt.Compute("Count(列名)", "列名='" + curCity + "'and " + filter + "条件");
worksheet6.Cells[7 + i * 8, sheet6Index] = count;
count = (int)dt.Compute("Count(列名)", "列名='" + curCity + "'and " + filter + "条件");
worksheet6.Cells[8 + i * 8, sheet6Index] = count;
count = (int)dt.Compute("Count(列名)", "列名='" + curCity + "'and " + filter + "条件");
worksheet6.Cells[9 + i * 8, sheet6Index] = count;
count = (int)dt.Compute("Count(列名)", "列名='" + curCity + "'and " + filter + "条件'");
worksheet6.Cells[10 + i * 8, sheet6Index] = count;
count = (int)dt.Compute("Count(列名)", "列名='" + curCity + "'and " + filter + "条件");
worksheet6.Cells[11 + i * 8, sheet6Index] = count;
count = (int)dt.Compute("Count(列名)", "列名='" + curCity + "'and " + filter + "条件");
worksheet6.Cells[12 + i * 8, sheet6Index] = count;
count = (int)dt.Compute("Count(列名)", "列名='" + curCity + "'and " + filter + "条件");
worksheet6.Cells[13 + i * 8, sheet6Index] = count;
#endregion
}
}
48*16 == 768,内部还有Computer,速度非常慢,求大神支招。主要是与Excel交互。不给用数据库
---贴吧极速版 For UWP
{
#region 业务类型1、2(第二、三、六个sheet)
for (int m = 0; m < allType.Length; m++)//共48条
{
if (条件)
{
filter = "条件";
Category(dt, allType[m], citylist, ref startIndex, ref sheet3Index, ref sheet6Index, worksheet2, worksheet3, worksheet6, filter);
}
else if (条件)
{
filter = "条件";
Category(dt, allType[m], citylist, ref startIndex, ref sheet3Index, ref sheet6Index, worksheet2, worksheet3, worksheet6, filter);
}
else if (条件)
{
filter = "条件";
Category(dt, allType[m], citylist, ref startIndex, ref sheet3Index, ref sheet6Index, worksheet2, worksheet3, worksheet6, filter);
}
else if (条件)
{
filter = "条件";
Category(dt, allType[m], citylist, ref startIndex, ref sheet3Index, ref sheet6Index, worksheet2, worksheet3, worksheet6, filter);
}
else
{
filter = "条件";
Category(dt, allType[m], citylist, ref startIndex, ref sheet3Index, ref sheet6Index, worksheet2, worksheet3, worksheet6, filter);
}
sheet3Index++;
sheet6Index++;
}
#endregion
}
private void Category(DataTable dt, string Type, string[] citylist, ref int startIndex, ref int sheet3Index, ref int sheet6Index, Excel.Worksheet worksheet2, Excel.Worksheet worksheet3, Excel.Worksheet worksheet6,string filter)
{
#region 第二个sheet
int count;
count = (int)dt.Compute("Count(列名)", filter + "条件");
worksheet2.Cells[startIndex + 1, 4] = count;
startIndex++;
#endregion
for (int i = 0; i < citylist.Length; i++)//共16条
{
string curCity = citylist[i].ToString();
#region 第三sheet
count = (int)dt.Compute("Count(列名)", "故障地市='" + curCity + "' and " + filter);
//count = (int)dt.Compute("Count(故障地市)", "故障地市='" + curCity + "' and 业务类型 like '%" + allType[m] + "'");
if (sheet3Index == 21 || sheet3Index == 37 || sheet3Index == 45 || sheet3Index == 52 || sheet3Index == 58)
{ sheet3Index += 2; }
worksheet3.Cells[sheet3Index, 5 + i] = count;
#endregion
#region 第六个sheet
if (sheet6Index == 22 || sheet6Index == 38 || sheet6Index == 46 || sheet6Index == 53 || sheet6Index == 59)
{ sheet6Index += 2; }
count = (int)dt.Compute("Count(列名)", "列名='" + curCity + "'and " + filter + "条件");
worksheet6.Cells[6 + i * 8, sheet6Index] = count;
count = (int)dt.Compute("Count(列名)", "列名='" + curCity + "'and " + filter + "条件");
worksheet6.Cells[7 + i * 8, sheet6Index] = count;
count = (int)dt.Compute("Count(列名)", "列名='" + curCity + "'and " + filter + "条件");
worksheet6.Cells[8 + i * 8, sheet6Index] = count;
count = (int)dt.Compute("Count(列名)", "列名='" + curCity + "'and " + filter + "条件");
worksheet6.Cells[9 + i * 8, sheet6Index] = count;
count = (int)dt.Compute("Count(列名)", "列名='" + curCity + "'and " + filter + "条件'");
worksheet6.Cells[10 + i * 8, sheet6Index] = count;
count = (int)dt.Compute("Count(列名)", "列名='" + curCity + "'and " + filter + "条件");
worksheet6.Cells[11 + i * 8, sheet6Index] = count;
count = (int)dt.Compute("Count(列名)", "列名='" + curCity + "'and " + filter + "条件");
worksheet6.Cells[12 + i * 8, sheet6Index] = count;
count = (int)dt.Compute("Count(列名)", "列名='" + curCity + "'and " + filter + "条件");
worksheet6.Cells[13 + i * 8, sheet6Index] = count;
#endregion
}
}
48*16 == 768,内部还有Computer,速度非常慢,求大神支招。主要是与Excel交互。不给用数据库
---贴吧极速版 For UWP