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. Image for the cookie policy date

Export from a datset

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 ..........
'............


1 Reply

YG Yavanaarasi G Syncfusion Team 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


Loader.
Live Chat Icon For mobile
Up arrow icon