Howto:在IE中使用Excel显示ASP.NET结果? [英] Howto: Display ASP.NET Results Using Excel in IE ?

查看:121
本文介绍了Howto:在IE中使用Excel显示ASP.NET结果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



您知道如何在IE中使用Excel显示ASP.NET结果(来自ADO.NET的数据库结果)

吗?

谢谢,

解决方案

" Lukman" < LS ****** @ hotmail.com>在新闻中写道:OiQxVdy9DHA.2524

@ TK2MSFTNGP11.phx.gbl:

你知道如何显示ASP.NET结果(来自ADO.NET的数据库结果)
在IE中使用Excel?




您需要连接到Excel,生成XLS(您可以使用

Excel DB驱动程序快捷方式然后使用适当的mime类型将XLS流式传输给用户。

-

Chad Z. Hower(又名Kudzu) - http://www.hower.org/Kudzu/

编程是一门艺术反击的形式


1。将数据网格导出到Excel。
http: //www.c-sharpcorner.com/Code/20...ridToExcel.asp


2.将数据导出到HTML表并设置

Response.ContentType =" application / vnd.ms-excel"

3.将数据导出为CSV文件。


HTH,

Suresh。


----- Lukman写道:-----




你知道如何显示ASP.NET结果(来自ADO.NET的数据库结果)

在IE中使用Excel吗?

谢谢,


我有一个简单的解决方案,可以将DataGrid导出到ASP.NET中的MS Excel。我从Microsoft支持中删除了这段代码。只需创建一个名为ExportToExcel的按钮,将此代码放在Click事件中,并将代码中的DataGrid1重命名为您调用的数据网格。当您运行页面并单击按钮时,系统将提示您打开excel,或者将数据网格中的任何数据保存到您选择的Excel文件中。我希望这可以节省初学者程序员,比如我自己一些时间和精力


sub ExportToExcel_Click(发件人作为对象,e作为EventArgs


''设置Excel的内容类型

Response.ContentType =" application / vnd.ms-excel

''从Content-Type标题中删除字符集

Response.Charset ="

''关闭视图状态

Me.EnableViewState = Fals


昏暗tw As New System.IO.StringWriter(

Dim hw As New System.Web.UI.HtmlTextWriter(tw

''获取控件的HTML

DataGrid1.RenderControl(hw

''将HTML写回浏览器

Response.Write(tw.ToString()

''结束回复

Response.End(

结束我


结束苏


Hi,
Do you know how to display ASP.NET result (database result from ADO.NET)
using Excel in IE ?
Thanks,

解决方案

"Lukman" <ls******@hotmail.com> wrote in news:OiQxVdy9DHA.2524
@TK2MSFTNGP11.phx.gbl:

Do you know how to display ASP.NET result (database result from ADO.NET)
using Excel in IE ?



You need to connect to Excel, generate the XLS (you could short cut with
Excel DB drivers) then stream the XLS to the user with the proper mime type.
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"


1. Exporting a datagrid to Excel.
http://www.c-sharpcorner.com/Code/20...ridToExcel.asp

2. Export your data to a HTML table and set
Response.ContentType = "application/vnd.ms-excel"

3. Export your data as CSV file.

HTH,
Suresh.

----- Lukman wrote: -----

Hi,
Do you know how to display ASP.NET result (database result from ADO.NET)
using Excel in IE ?
Thanks,


I have looked high and low for a simple solution to export a DataGrid to MS Excel in ASP.NET. I weeded out this code from Microsoft support. Simply create a button called ExportToExcel and place this code in the Click event and rename DataGrid1 in the code to whatever your datagrid is called. When you run the page and click your button you will be prompted to open excel in ie or save whatever data is in your datagrid to an excel file of your choice. I hope this saves beginner programmers such as myself some time and effort

sub ExportToExcel_Click(sender As Object, e As EventArgs

'' Set the content type to Excel
Response.ContentType = "application/vnd.ms-excel
'' Remove the charset from the Content-Type header
Response.Charset = "
'' Turn off the view state
Me.EnableViewState = Fals

Dim tw As New System.IO.StringWriter(
Dim hw As New System.Web.UI.HtmlTextWriter(tw
'' Get the HTML for the control
DataGrid1.RenderControl(hw
'' Write the HTML back to the browser
Response.Write(tw.ToString()
'' End the response
Response.End(
End I

End Su


这篇关于Howto:在IE中使用Excel显示ASP.NET结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆