We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Export datatable to Excel

Thread ID:





106021 Dec 4,2012 09:12 PM UTC Dec 18,2012 12:52 PM UTC ASP.NET Web Forms (Classic) 4
Tags: XlsIO
David Cleland
Asked On December 4, 2012 09:12 PM UTC

I am using XLsIO v9.4.0.62 and cannot update due to legacy issues.  I have a remote hosted server to which I am publishing a compiled dll which includes an excel document with several macros as a resource.  I need to figure out how to A) Open this excel document and write to it and then  B) export it to the client.  Currently I am opening the resource and trying to save it to the server C:\ drive but I do not think I have write permissions to it and for security reasons won't be given that access. Can I open an existing excel document straight from the dll without first saving it to the server?  I have included my code below.

' get the data
                Dim dt As DataTable = ds.Tables(0)
                Dim gamaRpt As Array
                gamaRpt = Global.My.Resources.ResourceManager.GetObject("BetaGamaRptver6_1")
                Global.My.Computer.FileSystem.WriteAllBytes _
                ("C:\GamaRpt", gamaRpt, False)
                wkb = _excelEngine.Excel.Workbooks.Open("C:\GamaRpt")
                'wkb = _excelEngine.Excel.Workbooks.Create(1)
                wkb.StandardFont = "Times New Roman"
                Dim xtab As DataTable
                wks = wkb.Worksheets.Item("Report")
                xtab = GenerateTable(dt)
                'wks.ImportDataTable(xtab, True, 1, 1)
                GenerateSheet(wks, xtab, dt)

                ' save the workbook to a stream
                Dim memStream As New System.IO.MemoryStream

                'Allow enterprise reports to be downloaded to client machine
                Response.ContentType = "application/vnd.ms-excel"
                Response.AddHeader("Content-Disposition", "attachment; filename=" & "Report.xlsx")

Manikandan M [Syncfusion]
Replied On December 13, 2012 01:20 PM UTC

Hi David,


Thank you for using Syncfusion products.


We are working on sample creation for directly accessing the file instead of storing it to drive and open it in XlsIO. We will get back to you with sample in one business day.


Thank you very much for your patience.




Manikandan M [Syncfusion]
Replied On December 14, 2012 12:03 PM UTC

Hi David,

Thanks for your patience.

We have created the simplified the sample to directly accessing the workbook instead of the loading it to drive and have attached the same in the below link. please make use of this and let us know if this helps you.

Sample link:LoadWorkbook.zip

Sample scenario:

1. Changed the array bytes of resource to Memory stream.
2. Opened the workbook using memory stream.

Code snippet:
        Dim gamaRpt As Array
        gamaRpt = GetLocalResourceObject("Incident")

        Dim workbookStream As MemoryStream
        workbookStream = New MemoryStream(gamaRpt)

        Dim excelEngine As New ExcelEngine()
        Dim application As IApplication = excelEngine.Excel

        Dim workbook As IWorkbook = application.Workbooks.Open(workbookStream)

Please let us know if you need any clarifications.


David Cleland
Replied On December 14, 2012 09:48 PM UTC

Thank you for the response.  I am testing now and will let you know what happens.

Mahajothi R [Syncfusion]
Replied On December 18, 2012 12:52 PM UTC

Hi David,


Thank you for the update. Please let us know if you require any further clarifications.





This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon