473,480 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Exporting Data from DataSet to text file or xls file

308 Contributor
Hi all,

Is there any way by which I can export the data from the dataset table to the text file or xls file ?

Currently I implemented this by itterating through each row of the table and writting the data to file.I want to avoid iteration.It occured to me bcoz skipping iteration will improve the performance.

Please Help..

Thanks!
Sep 25 '09 #1
13 4494
ssnaik84
149 New Member
Do you want to save .xls file on disk or just to create-n-send through browser on-the-fly?
in second case, you just need to set page header...

Expand|Select|Wrap|Line Numbers
  1. HttpContext.Current.Response.ContentType = "text/csv";
  2. HttpContext.Current.Response.AddHeader("Pragma", "public");
Sep 25 '09 #2
madankarmukta
308 Contributor
@ssnaik84
Hi ,

Thanks for your reply.

But I want to export/copy data from dataset table to the file.The File I want to save it on local disk.

Please provide input.

Thanks!
Sep 25 '09 #3
Plater
7,872 Recognized Expert Expert
Have you looked at the .WriteXML() function?
Sep 25 '09 #4
madankarmukta
308 Contributor
@Plater
Hi,

Thanks for the reply.

per my understanding .. writeXml function is used to get the xml equivalent of the table's data which is not my goal. Suppose the dataset table contains the data as -

================
Column1 Column2
================
Value11 Value22
--------------------------------
Value12 Value21
--------------------------------
I want it should get write to the text file as it is and not it's xml format.

If I m wrong pls. correct me.

Thanks again!
Sep 27 '09 #5
Plater
7,872 Recognized Expert Expert
Well an XML file would be able to be read by Excel.
But for your request, you would need to format the data in a text string yourself. Looping through the data.
You could check to see if someone has already created a function for doing that?
Sep 28 '09 #6
madankarmukta
308 Contributor
@Plater
Hi,

Thanks for the reply.

As I stated earlier I implemented the same way as you described here.But to avoid the "looping through data" I want to have some direct way by which the data can directly exported to text file.

Though the code was working smoothly previously, it may lead to degrade the peformance;because my table will now hold the records at the count of a lacs or two.

Please provide inputs if you have any.

Thanks again!
Sep 29 '09 #7
tabla
8 New Member
Hi,
Have u tried it with UTL package.check the same it is very fast.

Tabla
Sep 29 '09 #8
madankarmukta
308 Contributor
@tabla
Could you pls. elaborate more on what you want to say ..?

Thanks!
Sep 29 '09 #9
tabla
8 New Member
Hi,
There is one package UTL_FILE in oracle which read/write/append the data into existing or New .txt or .xls or .csv file.

First have all the data which u want to write in file into cursor.
Then open a file in UTL directory (take help of dba to know the path).
Using UTL_FLIE.PUT_LINE procedure you can write a data in to FILE.
After reading all records from cursor close the open file.

Tabla
Sep 29 '09 #10
Frinavale
9,735 Recognized Expert Moderator Expert
In case you're not using an Oracle Database....

It is probably a good idea if you research XML Serialization. The MSDN Library is a great place to start your research. For example it has an Introduction to XML Serialization article that states that you can use a XmlSerializer to serailize DataSet objects as XML.


Happy Coding
-Frinny
Sep 29 '09 #11
madankarmukta
308 Contributor
@Frinavale
Hi,

Thanks for your reply.

Per my understading Xmlserialization won't be useful. I don't want to transfer/post the object to and fro network/machines.I just want to get the data from the table to the text file as it is.Please provide input if you have any.

Thanks!
Sep 30 '09 #12
madankarmukta
308 Contributor
Hi All,

Any inputs..?

Please reply!
Oct 7 '09 #13
Plater
7,872 Recognized Expert Expert
@madankarmukta
create/open file. Write contents. flush stream and close.
Not a complicated task?
Oct 7 '09 #14

Sign in to post your reply or Sign up for a free account.

Similar topics

3
7969
by: Chris | last post by:
Could someone please provide me an effective means of exporting data from a data set (or data grid) to Excel?
2
1908
by: Mike P | last post by:
How do you go about exporting data in excel to a C# dataset? Any help would be really appreciated. Cheers, Mike
2
1052
by: brian | last post by:
I am using vb.net and sql2000. What is the best way using vb.net to export data to text file. I can retrieve it through a dataset or reader. There are a lot of columns. I perfer not to use the...
1
2448
by: Luis Esteban Valencia | last post by:
Hello Everyone, Iam an intermediate ASP.Net programmer and iam facing a challenging task. I have a table in MS-SQL server database called 'Members'. The table has following fields... ...
2
2386
by: bienwell | last post by:
Hi, I have a question about exporting data from datagrid control into Excel file in ASP.NET. On my Web page, I have a linkbutton "Export data". This link will call a Sub Function to perform...
4
2041
by: BizWorld | last post by:
I am getting this error in exporting a crystal report (having two subreports) using C# code. i got the following exception at Export statement. Exception Details:...
3
2036
by: David P. Donahue | last post by:
I'm re-writing an application in C# that was originally written in Delphi 7. The heart of the application is a DataSet displayed in a DataGrid. One of the main functions of the previous...
0
1494
by: Mike Collins | last post by:
I am trying to export data from multiple tables in SQL Server to an XML file so I can then import it to another database. It seems to be working fine for exporting, but I am having trouble...
6
8171
by: sara | last post by:
I have what I think is a little strange...I have to get data from our payroll system into a specific format (fixed record length) as a .txt or .prn file only to upload to our 401k custodian. I...
0
7034
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,...
1
6732
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
6886
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5324
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,...
1
4768
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4472
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2990
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
2976
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
174
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.