ASP.Net 海量数据导出到EXCEL (求救,问题很老,但是很急)
论坛的帖子
http://topic.csdn.net/u/20080827/11/e8eb5429-1f76-4ad5-9fe0-db217bf991e6.html
讨论海量数据导出到EXCEL ,不太适用于asp.net
还有人总结Asp.net 数据导出到EXCEL
http://www.cnblogs.com/lishengpeng1982/archive/2008/04/03/1135490.html
数据量大了(一万条以上),恐怕也不行,
我们目前采用的是下面的方法 ,6000条数据可以导出,速度也可以,数据再多就不行了,希望大家指点,谢谢了。
public void CreateExcel(System.Web.UI.Page page,string strHtml)
{
HttpResponse resp;
string strOutputHtml="";
strOutputHtml=strHtml;
string strFileName = System.DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls"; //xlsx xls
resp = page.Response;
resp.Clear();
resp.Buffer = false;
resp.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
resp.AppendHeader("Content-Disposition", "attachment;filename=" + strFileName); //inline,attachment
resp.ContentType = "application/ms-excel"; //vnd.ms-excel vnd.xls
//向HTTP输出流中写入
resp.Write(strOutputHtml);
resp.Flush();
resp.End();
}
其中方法的第二个参数 strHtml 是 html格式的数据的字符串,如下:
<html xmlns:v='urn:schemas-microsoft-com:vml' xmlns:o='urn:schemas-microsoft-com:office:office'
xmlns:w='urn:schemas-microsoft-com:office:word' xmlns:x='urn:schemas-microsoft-com:office:excel'
xmlns='http://www.w3.org/TR/REC-html40'>
<head>
<meta http-equiv='Content-Type' content='application/ms-excel; charset=gb2312'>
<meta name='ProgId' content='Excel.Sheet'>
<meta name='Generator' content='Microsoft Excel 12'>
</head>
<body lang='ZH-CN' style='tab-interval: 21.0pt; text-justify-trim: punctuation'>
<table border='1'>
<tr height='36'>
<td align='center' colspan='27' style='font-size: 18px; font-family: 宋体;'>
查询列表</td>
</tr>
<tr height='25'>
<td width='120' align='LEFT' style='font-family: 宋体; font-size: 12px;' nowrap>
WN_ID</td>
<td width='120' align='LEFT' style='font-family: 宋体; font-size: 12px;' nowrap>
WT_ID</td>
<td width='120' align='LEFT' style='font-family: 宋体; font-size: 12px;' nowrap>
WN_Name</td>
<td width='120' align='LEFT' style='font-family: 宋体; font-size: 12px;' nowrap>
WN_Code</td>
<td width='120' align='LEFT' style='font-family: 宋体; font-size: 12px;' nowrap>
WN_IsMailStone</td>
<td width='120' align='LEFT' style='font-family: 宋体; font-size: 12px;' nowrap>
WN_Status</td>
<td width='120' align='LEFT' style='font-family: 宋体; font-size: 12px;' nowrap>
Creater</td>
<td width='120' align='LEFT' style='font-family: 宋体; font-size: 12px;' nowrap>
CreateTime</td>
</tr>
<tr height='25'>
<td align='LEFT' style="font-family: 宋体; font-size: 12px; height: 25px;" x:str="\"'WN070130000007\">
WN070130000007</td>
<td align='LEFT' style="font-family: 宋体; font-size: 12px; height: 25px;" x:str="\"'WT0000000000000001\">
WT0000000000000001</td>
<td align='LEFT' style="font-family: 宋体; font-size: 12px; height: 25px;" x:str="\"'茨哈峡水电站可研设计\">
茨哈峡水电站可研设计</td>
<td align='LEFT' style="font-family: 宋体; font-size: 12px; height: 25px;" x:str="\"'200704541\">
200704541</td>
<td align='LEFT' style="font-family: 宋体; font-size: 12px; height: 25px;" x:str="\"'0\">
0</td>
<td align='LEFT' style="font-family: 宋体; font-size: 12px; height: 25px;" x:str="\"'2\">
2</td>
<td align='LEFT' style="font-family: 宋体; font-size: 12px; height: 25px;" x:str="\"'SU000000000001\">
SU000000000001</td>
</tr>
<tr height='25'>
<td align='LEFT' style='font-family: 宋体; font-size: 12px;' x:str="\"'WN070130000008\">
WN070130000008</td>
<td align='LEFT' style='font-family: 宋体; font-size: 12px;' x:str="\"'WT0000000000000001\">
WT0000000000000001</td>
<td align='LEFT' style='font-family: 宋体; font-size: 12px;' x:str="\"'山坪水电站预可研设计\">
山坪水电站预可研设计</td>
<td align='LEFT' style='font-family: 宋体; font-size: 12px;' x:str="\"'200607822\">
200607822</td>
<td align='LEFT' style='font-family: 宋体; font-size: 12px;' x:str="\"'0\">
0</td>
<td align='LEFT' style='font-family: 宋体; font-size: 12px;' x:str="\"'2\">
2</td>
<td align='LEFT' style='font-family: 宋体; font-size: 12px;' x:str="\"'SU000000000001\">
SU000000000001</td>
</tr>
</table>
</body>
</html>
[解决办法]
[解决办法]
帮你顶下
[解决办法]
}
// return to previous culture
System.Threading.Thread.CurrentThread.CurrentCulture = CurrentCI;
workbookData.Saved = false;
workbookData.SaveAs(strFileName, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Excel.XlSaveAsAccessMode. xlNoChange, Missing.Value, Missing.Value, Missing.Value, Missing.Value);
appExcel.Quit();
return true;
}
//MaxRow是设定的一个sheet得最大值,不知道能不能满足你的要求
[解决办法]
在web.config中设置 页面响应时间 ,长一些 。
[解决办法]
是否可以非即时导出,比如在系统比较清闲的时候使用数据库作业导出,然后提供下载
参考
[解决办法]
ding
[解决办法]
你说的是技术问题,还是太慢的问题啊
[解决办法]
学习
[解决办法]
顶起
[解决办法]
学做过导这么多数据的。。
[解决办法]
学习中
[解决办法]