在ASP.NET中將資料直接輸出成Excel內容 (轉)
在ASP.NET中將資料直接輸出成Excel內容 (轉)[@more@].mengxianhui.com.ExcelExport"%>
w3c//DTD HTML 4.0 Transitional//EN">
ExcelExport
microsoft .NET 7.0">
7.0">
script">
intellisense/">
RM id="Form1" method="post" runat="server">
edItemStyle Font-Bold="True" ForeColor="#663399" BackColor="#FFCC66">
是 Web 窗體設計器所必需的。
buggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System., ByVal e As System.EventArgs) _
Handles MyBase.Init
'CODEGEN: 此方法呼叫是 Web 窗體設計器所必需的
'不要使用程式碼編輯器修改它。
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
'在此處放置初始化頁的程式碼
' 定義是否是 SERVER 資料庫,這裡為False
Dim blnIsSQLServer As System.Boolean = False
Dim strSQL As String
Dim objDataset As New DataSet()
Dim objConn As Object
Dim strCnn As String
If blnIsSQLServer Then
strCnn = "User ID=sa;Initial Catalog=Northwind;Data =.NetSDK;"
objConn = New System.Data.SqlClient.SqlConnection(strCnn)
objConn.Open()
Dim objAdapter As New System.Data.SqlClient.SqlDataAdapter()
strSQL = "Select * from customers where country='USA'"
objAdapter.SelectCommand = New System.Data.SqlClient.SqlCommand(strSQL, objConn)
objAdapter.Fill(objDataset)
Else
strCnn = "Provr=Microsoft.Jet.OLE.4.0;Data Source=" + Server.MapPath("Test.mdb")
objConn = New System.Data.OleDb.OleDbConnection(strCnn)
objConn.Open()
Dim objAdapter As New System.Data.OleDb.OleDbDataAdapter()
strSQL = "Select Top 10 Title From Document"
objAdapter.SelectCommand = New System.Data.OleDb.OleDbCommand(strSQL, objConn)
objAdapter.Fill(objDataset)
End If
Dim oView As New DataView(objDataset.Tables(0))
DataGrid1.DataSource = oView
DataGrid1.DataBind()
objConn.Close()
objConn.Dispose()
objConn = Nothing
If Request.QueryString("bExcel") = "1" Then
Response.ContentType = "application/vnd.ms-excel"
' 從Content-Type header中去除charset設定
Response.Charset = ""
' 關閉 ViewState
Me.EnableViewState = False
Dim tw As New System.IO.StringWriter()
Dim hw As New System.Web.UI.HtmlTextWriter(tw)
' 獲取control的HTML
DataGrid1.RenderControl(hw)
' 把HTML寫回瀏覽器
Response.Write(tw.ToString())
Response.End()
End If
End Sub
End Class
在中將資料直接輸出成內容
本文實現了將中的資料直接輸出到Excel格式並在裡輸出。下面就是實現的例子:
playground.com/Exam/Data2ExcelDemo.htm" target=_target>檢視例子
ExcelExport.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10748419/viewspace-988555/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 將Excel表格內容直接轉換成圖片Excel
- set serveroutput on 在PL/SQL中輸出內容ServerSQL
- 將 SAP ABAP 內表內容本地匯出成 Excel 檔案試讀版Excel
- php如何將資料匯出成excel表格呢?PHPExcel
- vue+element將資料匯出成excel表格VueExcel
- python中將xmind轉成excelPythonExcel
- 如何將資料庫中的資料導成 excel 檔案資料庫Excel
- laravel結合maatwebsite/excel包,匯出excel,將部分內容設定不可LaravelWebExcel
- php 讀取excel中的內容到mysql 資料庫PHPExcelMySql資料庫
- Android:將View的內容對映成Bitmap轉圖片匯出AndroidView
- 在Excel中設定當資料輸入錯誤時提示出錯信Excel
- Java實現將txt中的內容寫入到excel中JavaExcel
- js根據checkbox的選中轉態輸出整行內容JS
- excel日期格式轉換中,怎樣將“/”轉換成“-”Excel
- 在ASP.NET Core中用HttpClient(一)——獲取資料和內容ASP.NETHTTPclient
- 高效資料傳輸:Java透過繫結快速將資料匯出至ExcelJavaExcel
- 將Excel中的資料匯入至MsSQLSERVER中(示例) (轉)ExcelSQLServer
- 將oracle中資料轉存到excel中OracleExcel
- asp.net中利用NPOI匯出資料到excel中ASP.NETExcel
- wps的excel中的單元格限定輸入的內容Excel
- 在excel中某些單元格內批量增加相同的內容Excel
- Excel如何篩選出自己想要的資料 excel怎麼篩選出需要的內容Excel
- 在sqlplus全部輸出clob欄位的內容SQL
- 在ASP.NET中,向資料庫批次插入資料 (轉)ASP.NET資料庫
- 將dataGridView內容匯出到Excel檔案ViewExcel
- 資料與內容中臺
- PowerShell輸出內容到檔案
- 廣招內容輸出英雄帖
- 將資料從 Visual Basic 傳輸到 ExcelExcel
- EXCEL中如何橫向輸入資料?Excel
- matlab輸出資料為excel檔案MatlabExcel
- Python實現對比兩個Excel資料內容並標出不同PythonExcel
- 轉載:利用SQL*Loader將 Excel 資料匯出到資料庫中SQLExcel資料庫
- java實現將資料庫資料轉化成excel表格顯示出來Java資料庫Excel
- 【greenplum】greenplum叢集資料庫初始化輸出內容樣例資料庫
- Spring Boot Filter中擷取響應輸出內容Spring BootFilter
- 如何將Word文件轉成Excel表格?Excel
- 如何讓excel單元格內只能輸入指定內容?Excel