|
Imports System.xml
Partial Class Example2
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
Dim XMLDoc As XmlDataDocument
Dim b As XmlNode
Dim a As XmlNode
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)
XMLDoc = New XmlDataDocument(dsOrders)
a = XMLDoc.CreateElement("CustomerDetails")
a.InnerXml = "<CustomerId>ALFKI</CustomerId><CustomerNm>Alfreds Futterkiste</CustomerNm><ContactNm>Maria Anders</ContactNm><City>Berlin</City>"
XMLDoc.DataSet.EnforceConstraints = False
b = XMLDoc.DocumentElement.FirstChild
XMLDoc.DocumentElement.InsertBefore(a, b)
strExcelFile = objExport.TransformXMLDocumentToExcel(XMLDoc, "Example2.xsl")
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.