We help IT Professionals succeed at work.
Get Started

VB.NET 2003 Dataset to Excel Export

563 Views
Last Modified: 2007-12-19
I have a Dataset and a Dataview, displayed in the following manner (dgData is a Datagrid):

            Dim DataAU As New formChild
            Dim ViewAU As New DataView
            ViewAU.Table = dt
            ViewAU.RowFilter = "Type = 'AU'"
            ViewAU.Sort = "count DESC"
            DataAU.dgData.DataSource = ViewAU
            Dim ts As New DataGridTableStyle
            ts.MappingName = ViewAU.Table.TableName
            DataAU.dgData.TableStyles.Add(ts)
            DataAU.dgData.TableStyles(0).GridColumnStyles(0).Width = 583
            DataAU.dgData.TableStyles(0).GridColumnStyles(1).Width = 35
            DataAU.dgData.TableStyles(0).GridColumnStyles(2).Width = 0
            DataAU.dgData.TableStyles(0).GridColumnStyles(0).HeaderText = "Author"
            DataAU.dgData.TableStyles(0).GridColumnStyles(1).HeaderText = "#"

            Dim DataSO As New formChild
            Dim ViewSO As New DataView
            ViewSO.Table = dt
            ViewSO.RowFilter = "Type = 'SO'"
            ViewSO.Sort = "count DESC"
            DataSO.dgData.DataSource = ViewSO
            Dim ts As New DataGridTableStyle
            ts.MappingName = ViewSO.Table.TableName
            DataSO.dgData.TableStyles.Add(ts)
            DataSO.dgData.TableStyles(0).GridColumnStyles(0).Width = 583
            DataSO.dgData.TableStyles(0).GridColumnStyles(1).Width = 35
            DataSO.dgData.TableStyles(0).GridColumnStyles(2).Width = 0
            DataSO.dgData.TableStyles(0).GridColumnStyles(0).HeaderText = "Parent Publication"
            DataSO.dgData.TableStyles(0).GridColumnStyles(1).HeaderText = "#"

I would like these two datasets to be saved to an Excel document, one in each of the first two worksheets.   A prompt needs to appear to ask a location to save the file.  I'd like to preserve column width formatting, with HeaderText appearing as the worksheet names.  This is a simplified version: there are really 7 different worksheets, but I can modify an example containing just 2.  What code would produce this outcome?
Comment
Watch Question
Database Consultant
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 1 Answer and 9 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE