On Mon, 14 Jun 2004 11:45:42 +0200, "Tomek" <tniewoli@bcdpl us.pl>
wrote:
[color=blue]
>Hi,
>How could I export data from table or query to excel file in VB.NET?
>Thanks in advance,
>Tomek
>[/color]
"Michael Gray" <fleetg@newsguy .spam.com> wrote in message
news:di1rc0h6cr ubb3b0lpbv1qb1e t9k4a8ps8@4ax.c om...[color=blue]
> On Mon, 14 Jun 2004 11:45:42 +0200, "Tomek" <tniewoli@bcdpl us.pl>
> wrote:
>[color=green]
> >Hi,
> >How could I export data from table or query to excel file in VB.NET?
> >Thanks in advance,
> >Tomek
> >[/color]
>
> What version of Excel?
> What version of VB.NET?[/color]
I had need to do this so often that I wrote a function for it. It is below.
Bear in mind that this takes some time, but it's currently better that using
..xml, which is much faster but it has a couple of flaws - the biggest of
which is that a label with number characters only will appear inside excel
as, say, '833' when it should be '00833'. If you can figure that out, let
me know.
The function below allows for either .csv or .xls (.xls works best but is
slow), and you can also use column names as headers, if you wish.
HTH,
Bernie Yaeger
Public Function sqltabletocsvor xls(ByVal dt As DataTable, ByRef strpath As
String, ByVal dtype As String, ByVal includeheader As Boolean) As Integer
"Tomek" <tniewoli@bcdpl us.pl> wrote in message
news:O5sz%23QfU EHA.644@tk2msft ngp13.phx.gbl.. .[color=blue]
> Hi,
> How could I export data from table or query to excel file in VB.NET?
> Thanks in advance,
> Tomek
>
>[/color]
Comment