我用asp.net开发网页,oracle数据库。选定条件后查询,结果以分页表格形式显示在页面上,还要能另存为excel,我这找了个表格插件,试用时14个字段,1400条记录就要9秒,5000条记录就要80余秒了,10000条记录我没耐心等下去了我这碰到的最大的一个查询是156个字段,4000余条记录,这速度没法用啊如果不用插件,用VS自带的GridView,速度倒是挺快156个字段4000条记录10来秒就出来了,但是无法另存为excel,网上那段通用的GridView另存为excel的代码似乎只在记录数比较少的时候管用。谁碰到过这种情况啊?用的什么插件?速度如何?
贴出来看下
Me.GridView1.AllowPaging = False '先不分页,不然只能另存当前页的数据
bind()
Response.Buffer = True
Response.Charset = "GB2312"
Response.AppendHeader("Content-Disposition", "attachment;filename=FileName.xls")
Response.ContentEncoding = System.Text.Encoding.UTF7
Response.ContentType = "application/ms-excel"
Dim oStringWriter As System.IO.StringWriter = New System.IO.StringWriter
Dim oHtmlTextWriter As System.Web.UI.HtmlTextWriter = New System.Web.UI.HtmlTextWriter(oStringWriter)
Me.GridView1.RenderControl(oHtmlTextWriter)
Response.Output.Write(oStringWriter.ToString)
Response.Flush()
Response.End()
Me.GridView1.AllowPaging = True
bind()
存入excel和存入access一个样,只不过是连接access数据库和连接excel的字符串不同。其他的都基本一样。
将gridview的datasource取出来,批量更新到excel就行
Response.Output.Write(oStringWriter.ToString) 检查oStringWriter.ToString字符串中最后一条记录是否对于grid的最后一条
通过断点进行排查。
实在找不出,自己写代码导出excel