473,466 Members | 1,412 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Convert DataSet To Excel

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
Nov 16 '05 #1
7 11772
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]
- mv*@spam.guard.caspershouse.com

"kscdavefl" <ks*******@discussions.microsoft.com> wrote in message
news:B4**********************************@microsof t.com...
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

Nov 16 '05 #2
=?Utf-8?B?a3NjZGF2ZWZs?= <ks*******@discussions.microsoft.com> wrote in
news:B4**********************************@microsof t.com:
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/
Nov 16 '05 #3

"Chad Z. Hower aka Kudzu" <cp**@hower.org> wrote in message
news:Xn******************@127.0.0.1...
=?Utf-8?B?a3NjZGF2ZWZs?= <ks*******@discussions.microsoft.com> wrote in
news:B4**********************************@microsof t.com:
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
Nov 16 '05 #4
"Fredrik Wahlgren" <fr****************@mailbox.swipnet.se> wrote in
news:Om*************@TK2MSFTNGP12.phx.gbl:
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/
Nov 16 '05 #5
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]
- mv*@spam.guard.caspershouse.com

"Chad Z. Hower aka Kudzu" <cp**@hower.org> wrote in message
news:Xn******************@127.0.0.1...
"Fredrik Wahlgren" <fr****************@mailbox.swipnet.se> wrote in
news:Om*************@TK2MSFTNGP12.phx.gbl:
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/

Nov 16 '05 #6

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2****************@TK2MSFTNGP10.phx.gbl...
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

Nov 16 '05 #7
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in news:#j**************@TK2MSFTNGP10.phx.gbl:
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/
Nov 16 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Paul | last post by:
Hi all Arggghhh........... The problem.....I want the user to be able to create an excel document and name particular cells in the document where they want the data to be placed and then save...
29
by: Mark B | last post by:
We have an Access app (quite big) at www.orbisoft.com/download. We have had requests by potential users to have it converted to an SQL version for them since there corporate policy excludes them...
9
by: Marathoner | last post by:
I am trying to convert a dataset to an ADODB.Recordset. I create the sxl file and open it in VB.NET by using: Dim rs as ADODB.Recordset rs.Open("C:\files\xslfile.xsl") I want to do this same...
4
by: Hans [DiaGraphIT] | last post by:
Hi! I want to export a dataset to an excel file. I found following code on the net... ( http://www.codeproject.com/csharp/Export.asp ) Excel.ApplicationClass excel = new ApplicationClass();...
1
by: TaeHo Yoo | last post by:
How to convert a dataset to excel spreadsheet in windows based application?? Thanks a lot in advance. *** Sent via Devdex http://www.devdex.com *** Don't just participate in...
1
by: SL | last post by:
Hi - I'm fairly new to manipulating xml and I have an excel workbook and on one of the sheets is apparently a listobject... using it's xmlmap.export function I get an xml file that looks like this...
2
by: Ronald S. Cook | last post by:
Hi, I need to open an Excel file from within my ASP.NET app and read data. I'm guessing the most like format in ASP.NET would be a DataTable. Regardles,, how do I get the data into my ASP.NET...
2
by: karups | last post by:
Hi when i convert Excel file to dataset using the following code, i find that, some col. such as Col1 ------ 404 403 NOT 222
3
by: binny | last post by:
i use jet engine ,and oledb database but with this i get four errors which r compile time errores,plz help me to solve these errors i wrote this programe bt it is not working . using System.Web;...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.