Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is Excel required on the server?
Message
From
01/05/2006 17:02:56
 
 
To
01/05/2006 15:08:27
Keith Payne
Technical Marketing Solutions
Florida, United States
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
01117194
Message ID:
01118198
Views:
13
I have reached a major breakthrought today with that research. Basically, I can obtain a natif Excel spreadsheet from a dataset without any need of using a 3rd party tool, nor this Jet Engine, nor any fancy XML string that have to be manipulated. Based on some samples I found here and there, I put them all together in something that is working:
Imports System.IO
Imports System.Xml
Imports System.Xml.Xsl

Namespace Framework

    Public Class Export

        Public oApp As Framework.App

        ' Export a dataset into an Excel spreadsheet
        ' expO1 DataSet
        ' expC1 Full path of the file to save
        ' expC2 Full path of the transformation stylesheet
        Public Function ExportToExcel(ByVal toDataSet As DataSet, ByVal tcFile As String, _
         ByVal tcTransformationStyleSheet As String) As Boolean

            ' Read the dataset in a XmlDataDocument
            Dim loXmlDataDoc As XmlDataDocument = New XmlDataDocument(toDataSet)

            Dim loXslCompiledTransform As Xsl.XslCompiledTransform = New Xsl.XslCompiledTransform

            ' Get the Excel stylesheet into memory
            Dim loMemorySteam As New FileStream(tcTransformationStyleSheet, FileMode.Open, FileAccess.Read)

            Dim loXmlTextReader As XmlTextReader = New XmlTextReader(loMemorySteam)
            loXslCompiledTransform.Load(loXmlTextReader, Nothing, Nothing)
            Dim loStringWriter As New StringWriter()
            loXslCompiledTransform.Transform(loXmlDataDoc, Nothing, loStringWriter)

            ' Try to save the file
            If Not oApp.CreateFile(loStringWriter.ToString(), tcFile) Then
                Return False
            End If

            Return True
        End Function

    End Class

End Namespace
A big thanks to all who provided help on this topic.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform