PC Review


Reply
Thread Tools Rate Thread

Convert DataSet To Excel

 
 
=?Utf-8?B?a3NjZGF2ZWZs?=
Guest
Posts: n/a
 
      14th Feb 2005
I am running the following code to retrieve a DataSet:

public DataView CreateGroupSource()
{
string groupConnect = Session["connect"].ToString();
string groupSelect = "Select grpname from Maxusergroups where usrname = "
+ "'" + userText.Text + "'";
oda = new OleDbDataAdapter(groupSelect, groupConnect);
DataSet ds = new DataSet();
oda.Fill(ds, "group");
DataView group = ds.Tables["group"].DefaultView;
return group;
}

When I click on a button on a web form I want to convert the information
toan excel spreadsheet.

How do I accomplish this task?

Thanks,

Dave
 
Reply With Quote
 
 
 
 
Nicholas Paldino [.NET/C# MVP]
Guest
Posts: n/a
 
      14th Feb 2005
Dave,

You would create a dataadapter, and then you would set the
InsertCommand, DeleteCommand and UpdateCommand to the commands that will
perform those operations. Then, feed the dataset to the Update method on
the DataAdapter, and it should work.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (E-Mail Removed)

"kscdavefl" <(E-Mail Removed)> wrote in message
news:B4093810-6C87-4AD8-B94C-(E-Mail Removed)...
>I am running the following code to retrieve a DataSet:
>
> public DataView CreateGroupSource()
> {
> string groupConnect = Session["connect"].ToString();
> string groupSelect = "Select grpname from Maxusergroups where usrname = "
> + "'" + userText.Text + "'";
> oda = new OleDbDataAdapter(groupSelect, groupConnect);
> DataSet ds = new DataSet();
> oda.Fill(ds, "group");
> DataView group = ds.Tables["group"].DefaultView;
> return group;
> }
>
> When I click on a button on a web form I want to convert the information
> toan excel spreadsheet.
>
> How do I accomplish this task?
>
> Thanks,
>
> Dave



 
Reply With Quote
 
Chad Z. Hower aka Kudzu
Guest
Posts: n/a
 
      14th Feb 2005
=?Utf-8?B?a3NjZGF2ZWZs?= <(E-Mail Removed)> wrote in
news:B4093810-6C87-4AD8-B94C-(E-Mail Removed):
> When I click on a button on a web form I want to convert the information
> toan excel spreadsheet.


The easiest way is to export as a CSV, and then load that with Excel.


--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Empower ASP.NET with IntraWeb
http://www.atozed.com/IntraWeb/
 
Reply With Quote
 
Fredrik Wahlgren
Guest
Posts: n/a
 
      14th Feb 2005

"Chad Z. Hower aka Kudzu" <(E-Mail Removed)> wrote in message
news:Xns95FD8CC4C2254cpub@127.0.0.1...
> =?Utf-8?B?a3NjZGF2ZWZs?= <(E-Mail Removed)> wrote in
> news:B4093810-6C87-4AD8-B94C-(E-Mail Removed):
> > When I click on a button on a web form I want to convert the information
> > toan excel spreadsheet.

>
> The easiest way is to export as a CSV, and then load that with Excel.
>

Excel can read xml files.

/Fredrik


 
Reply With Quote
 
Chad Z. Hower aka Kudzu
Guest
Posts: n/a
 
      14th Feb 2005
"Fredrik Wahlgren" <(E-Mail Removed)> wrote in
news:(E-Mail Removed):
>> The easiest way is to export as a CSV, and then load that with Excel.
>>

> Excel can read xml files.


Even easier - if it can read the same format that the dataset produces.


--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Make your ASP.NET applications run faster
http://www.atozed.com/IntraWeb/
 
Reply With Quote
 
Nicholas Paldino [.NET/C# MVP]
Guest
Posts: n/a
 
      14th Feb 2005
Chad,

Since Excel can read XML, and the XML produced by the DataSet is valid,
it can read them. However, you have to handle all the mappings yourself.

One catch though, you have to be using Excel XP, or 2003 and up (I'm not
sure which version support was added).

If that is not a problem for you, then I would use that.


--
- Nicholas Paldino [.NET/C# MVP]
- (E-Mail Removed)

"Chad Z. Hower aka Kudzu" <(E-Mail Removed)> wrote in message
news:Xns95FD952C543A8cpub@127.0.0.1...
> "Fredrik Wahlgren" <(E-Mail Removed)> wrote in
> news:(E-Mail Removed):
>>> The easiest way is to export as a CSV, and then load that with Excel.
>>>

>> Excel can read xml files.

>
> Even easier - if it can read the same format that the dataset produces.
>
>
> --
> Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
> "Programming is an art form that fights back"
>
> Make your ASP.NET applications run faster
> http://www.atozed.com/IntraWeb/



 
Reply With Quote
 
Fredrik Wahlgren
Guest
Posts: n/a
 
      14th Feb 2005

"Nicholas Paldino [.NET/C# MVP]" <(E-Mail Removed)> wrote in
message news:%(E-Mail Removed)...
> Chad,
>
> Since Excel can read XML, and the XML produced by the DataSet is

valid,
> it can read them. However, you have to handle all the mappings yourself.
>
> One catch though, you have to be using Excel XP, or 2003 and up (I'm

not
> sure which version support was added).
>
> If that is not a problem for you, then I would use that.
>
>


Another option is to use automation from within your C# application. Start a
new instance of Excel, make it visible, loop thru your values and pass them
one by one. You should be able to find several examples of this on the
Internet.

/Fredrik



 
Reply With Quote
 
Chad Z. Hower aka Kudzu
Guest
Posts: n/a
 
      14th Feb 2005
"Nicholas Paldino [.NET/C# MVP]" <(E-Mail Removed)> wrote
in news:#(E-Mail Removed):
> Since Excel can read XML, and the XML produced by the DataSet is
> it can read them. However, you have to handle all the mappings
> yourself.


Thats what I thought. Unless he wants to go through ODBC or Automation, the
simplest solution might be best. A CSV.


--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Get your ASP.NET in gear with IntraWeb!
http://www.atozed.com/IntraWeb/
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
convert Excel to dataset karups Microsoft VB .NET 2 8th Aug 2006 07:06 AM
convert Excel to dataset karups Microsoft VB .NET 2 8th Aug 2006 07:04 AM
convert Excel to dataset karups Microsoft VB .NET 0 4th Aug 2006 02:06 PM
How convert Excel data into DataSet/DataTable? Ronald S. Cook Microsoft C# .NET 2 14th Feb 2006 09:30 PM
Convert DataSet to Excel Workbook. =?Utf-8?B?T3dlbiBKLg==?= Microsoft ADO .NET 0 10th Feb 2005 03:03 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:43 AM.