网页资讯视频图片知道文库贴吧地图采购
进入贴吧全吧搜索

 
 
 
日一二三四五六
       
       
       
       
       
       

签到排名:今日本吧第个签到,

本吧因你更精彩,明天继续来努力!

本吧签到人数:0

一键签到
成为超级会员,使用一键签到
一键签到
本月漏签0次!
0
成为超级会员,赠送8张补签卡
如何使用?
点击日历上漏签日期,即可进行补签。
连续签到:天  累计签到:天
0
超级会员单次开通12个月以上,赠送连续签到卡3张
使用连续签到卡
07月22日漏签0天
c#吧 关注:188,447贴子:822,834
  • 看贴

  • 图片

  • 吧主推荐

  • 视频

  • 游戏

  • 1回复贴,共1页
<<返回c#吧
>0< 加载中...

双层for效率问题求优化

  • 只看楼主
  • 收藏

  • 回复
  • 超级安达市
  • c#大菜鸟
    4
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
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


  • 22987平安的亲爸
  • c#牛人
    9
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
这个吧好多win10贴吧的软粉,
你说金钱买不来时间? 网管,加两块钱。 你说金钱买不来知识? 老师,这是我的学费。 你说金钱买不来爱情? 丈母娘,这是我的礼金。 你说金钱买不来健康? 医生,这是我的红包。


登录百度账号

扫二维码下载贴吧客户端

下载贴吧APP
看高清直播、视频!
  • 贴吧页面意见反馈
  • 违规贴吧举报反馈通道
  • 贴吧违规信息处理公示
  • 1回复贴,共1页
<<返回c#吧
分享到:
©2025 Baidu贴吧协议|隐私政策|吧主制度|意见反馈|网络谣言警示