|
Partial Class Example1
Inherits System.Web.UI.Page
Dim objExport As ExportToExcel.ExcelExport
Protected Sub cmdExport_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdExport.Click
Dim strSql As String
Dim strCon As String
Dim strExcelFile As String
Dim dsOrders As DataSet
Try
strSql = "select ord.orderid,ord.EmployeeID, ordDet.ProductID, ordDet.UnitPrice, ordDet.Quantity, "
strSql = strSql & " ordDet.Discount from orders ord inner join ""order details"" ordDet "
strSql = strSql & "on ord.orderid = ordDet.orderid where customerID = 'ALFKI' order by ord.orderid"
strCon = System.Configuration.ConfigurationManager.AppSettings("ConStr")
dsOrders = SqlHelper.ExecuteDataset(strCon, CommandType.Text, strSql)
strExcelFile = objExport.TransformDataTableToExcel(dsOrders.Tables(0), True)
objExport.SendExcelToClient(strExcelFile)
Catch ex As Threading.ThreadAbortException
'Do nothing
Catch ex As Exception
Response.Write(ex.ToString)
End Try
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
objExport = New ExportToExcel.ExcelExport
objExport.TempFolder = "\Excel\Temp\"
objExport.TemplateFolder = "\Excel\Template\"
objExport.XSLStyleSheetFolder = "\Excel\XSLStyleSheet\"
objExport.CleanUpTemporaryFiles()
End Sub
End Class
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.