利用多线程导出!!!!!!!!!!!!!!!!!!!!!!!

zhengweitao zhengweitao 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
    public string[] bb = new string[1000];
public static int w;
protected void Button1_Click(object sender, EventArgs e)
{
w = 0;

for (qq = 1; qq <= 5; qq++)
{
Thread thread = new Thread(new ThreadStart(add));
thread.Start();
}
eeee();
}

void add()
{
string str = Encoding.Default.GetString(myBytes);
myClient.Dispose();
string pattern = @"(?si)(?<=\bhref\s*=\s*"")[^""]+(?="")";
string[] ss = new string[Regex.Matches(str, pattern).Count + 1];//ss 长度不固定,
string[] aa = new string["aa","bb","cc","dd","ee","ff","gg","hh","ii","jj"];
for (int i = 0; i < ss.Length; i++)
{
if (ss[i].Equals(""))
{
bb[w] = aa[i];
w++;
}
}
}

void eeee()
{
System.Text.StringBuilder myTables = new StringBuilder();
for (int ii = 0; ii < bb.Length; ii++)
{
myTables.Append(bb[ii] + "\r\n");
}

HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.Charset = "GB2312";
HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=test.txt");
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");//设置输出流为简体中文
HttpContext.Current.Response.ContentType = "application/ms-excel";//设置输出文件类型为excel文件。
HttpContext.Current.Response.Write(myTables);
HttpContext.Current.Response.End();
}

我导出后 有的时候能按条件导出 有的时候到处的空 为什么
最好有 多线程导出代码
...全文
评论 17
收藏 已收藏
分享
返回顶部
zhengweitao
.NET社区 62,272 成员 668,968 内容