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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Export from a datset

Thread ID:

Created:

Updated:

Platform:

Replies:

75621 Aug 2,2008 08:31 AM UTC Aug 7,2008 12:32 PM UTC ASP.NET Web Forms (Classic) 1
loading
Tags: XlsIO
Kjell Ek
Asked On August 2, 2008 08:31 AM UTC

I am using Syncfusion.XlsIO v6.3

How to export data from MS SQL using a DataSet like the code below.

Any that have a simple exsamle in asp.net vb?
I want to have all data from my dataset to a .xls file when the user klick on the btnMedlem button.........


------------------------------------------

Protected Sub btnMedlem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnMedlem.Click

Try

MyCommand = New SqlClient.SqlCommand("SELECT * FROM MyTable Where Distriktsnr = @id And Foreningsnr = @Foreningsnr Order By Foreningsnr ASC, Enamn ASC", MyConnection)

MyCommand.Parameters.Add(New SqlParameter("@id", SqlDbType.Int, 4))
MyCommand.Parameters("@id").Value = ddDistrikt.SelectedItem.Value

MyCommand.Parameters.Add(New SqlParameter("@Foreningsnr", SqlDbType.smallint, 2))
MyCommand.Parameters("@Foreningsnr").Value = ddForening.SelectedItem.Value

MyDataAdapter = New SqlClient.SqlDataAdapter(MyCommand)

DS = New DataSet()
MyDataAdapter.Fill(DS)

Dim excelEngine As ExcelEngine = New ExcelEngine()
Dim workbook ..........
'............


Yavanaarasi G [Syncfusion]
Replied On August 7, 2008 12:32 PM UTC

Hi Kjell,

I regret to let you know that it is not possible to export the excel data directly from the dataset using our XlsIO and we can only export as Data table by using ExportDataTable method. Please refer the below code snippet:


[VB]
'Read data from spreadsheet and export to datagrid
Dim customersTable As DataTable = sheet.ExportDataTable(sheet.UsedRange,ExcelExportDataTableOptions.ColumnNames)
Me.dataGrid1.DataSource = customersTable

'Import the data from grid to excel sheet
sheet1.ImportDataTable(CType(Me.dataGrid1.DataSource, DataTable),True,3,1,-1,-1)


Please refer our shipped browser sample that demonstrates how to export and import the data:

\\Syncfusion\EssentialStudio\6.3.0.30\Windows\XlsIO.Windows\Samples\2.0\Data Binding\ImportExportDataTable\VB

Please try this and let me know if this helps.

Regards,
G.Yavana


CONFIRMATION

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.

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

;