I've got a DataSet that I save as XML using the DataSet DataTable's WriteXml
method.
If I say XmlWriteMode.Ig noreSchema, it shows up great in Excel, but I can
not reopen the file in my application because there is no schema for it.
On the other hand, I can choose XmlWriteMode.Wr iteSchema, and the data in
Excel looks more like some kind of code instead of the data: id=NewDataSet,
name=NewDataSet , ns1:IsDataSet=T RUE, etc. If I open this file in Notepad, my
data is there, bunched between a lot of this difficult to read other info.
Is there some common ground that I am missing?
I write the XML file using this:
using (XmlTextWriter xw = new XmlTextWriter(m _filename, Encoding.UTF8)) {
foreach (DataTable table in ds.Tables) {
table.WriteXml( xw, XmlWriteMode.Wr iteSchema);
//table.WriteXml( xw, XmlWriteMode.Ig noreSchema);
}
}
I read it back using this:
DataSet ds = new DataSet();
ds.ReadXml(open FileDlg1.FileNa me, XmlReadMode.Rea dSchema);
foreach (DataTable table in ds.Tables) {
dgv.DataSource = table.DefaultVi ew;
}
There is typically only one (1) table in the view, but my use of foreach
prevents errors while reminding me of the possibilities! :) 4 9615
jp2msft wrote:
I've got a DataSet that I save as XML using the DataSet DataTable's WriteXml
method.
If I say XmlWriteMode.Ig noreSchema, it shows up great in Excel, but I can
not reopen the file in my application because there is no schema for it.
On the other hand, I can choose XmlWriteMode.Wr iteSchema, and the data in
Excel looks more like some kind of code instead of the data: id=NewDataSet,
name=NewDataSet , ns1:IsDataSet=T RUE, etc. If I open this file in Notepad, my
data is there, bunched between a lot of this difficult to read other info.
Is there some common ground that I am missing?
I write the XML file using this:
using (XmlTextWriter xw = new XmlTextWriter(m _filename, Encoding.UTF8)) {
foreach (DataTable table in ds.Tables) {
table.WriteXml( xw, XmlWriteMode.Wr iteSchema);
//table.WriteXml( xw, XmlWriteMode.Ig noreSchema);
}
}
I read it back using this:
DataSet ds = new DataSet();
ds.ReadXml(open FileDlg1.FileNa me, XmlReadMode.Rea dSchema);
foreach (DataTable table in ds.Tables) {
dgv.DataSource = table.DefaultVi ew;
}
There is typically only one (1) table in the view, but my use of foreach
prevents errors while reminding me of the possibilities! :)
I am not sure why you iterate over the tables to write out the DataSet.
DataSet has its own WriteXml method and also a WriteXmlSchema method.
And if you use
ds.WriteXml("fi le.xml");
then you should be able to read that in with
ds.ReadXml("fil e.xml");
too.
If the schema does make problems with Excel then you could write it out
as a separate document with
ds.WriteXmlSche ma("schema.xsd" );
ds.WriteXml("fi le.xml");
and read it back in with e.g.
ds.ReadXmlSchem a("schema.xsd") ;
ds.ReadXml("fil e.xml");
--
Martin Honnen --- MVP XML http://JavaScript.FAQTs.com/
On Aug 25, 12:52*pm, jp2msft <jp2m...@discus sions.microsoft .com>
wrote:
I've got a DataSet that I save as XML using the DataSet DataTable's WriteXml
method.
If I say XmlWriteMode.Ig noreSchema, it shows up great in Excel, but I can
not reopen the file in my application because there is no schema for it.
On the other hand, I can choose XmlWriteMode.Wr iteSchema, and the data in
Excel looks more like some kind of code instead of the data: id=NewDataSet,
name=NewDataSet , ns1:IsDataSet=T RUE, etc. If I open this file in Notepad, my
data is there, bunched between a lot of this difficult to read other info..
Is there some common ground that I am missing?
I write the XML file using this:
using (XmlTextWriter xw = new XmlTextWriter(m _filename, Encoding.UTF8)) {
* foreach (DataTable table in ds.Tables) {
* * table.WriteXml( xw, XmlWriteMode.Wr iteSchema);
* * //table.WriteXml( xw, XmlWriteMode.Ig noreSchema);
* }
}
I read it back using this:
DataSet ds = new DataSet();
ds.ReadXml(open FileDlg1.FileNa me, XmlReadMode.Rea dSchema);
foreach (DataTable table in ds.Tables) {
* dgv.DataSource = table.DefaultVi ew;
}
There is typically only one (1) table in the view, but my use of foreach
prevents errors while reminding me of the possibilities! :)
Hi,
Have you tried to export it to CSV instead?
CSV is readable by Excel (most of the cases Excel is teh default
program for .CSV files)
Here is a food for thought post:
http://sholliday.space s.live.com/blog/cns!A68482B9628 A842A!148.entry
The xml generated by the WriteXml method...can be transformed to anything
you like.
.......
"jp2msft" <jp*****@discus sions.microsoft .comwrote in message
news:CC******** *************** ***********@mic rosoft.com...
I've got a DataSet that I save as XML using the DataSet DataTable's
WriteXml
method.
If I say XmlWriteMode.Ig noreSchema, it shows up great in Excel, but I can
not reopen the file in my application because there is no schema for it.
On the other hand, I can choose XmlWriteMode.Wr iteSchema, and the data in
Excel looks more like some kind of code instead of the data:
id=NewDataSet,
name=NewDataSet , ns1:IsDataSet=T RUE, etc. If I open this file in Notepad,
my
data is there, bunched between a lot of this difficult to read other info.
Is there some common ground that I am missing?
I write the XML file using this:
using (XmlTextWriter xw = new XmlTextWriter(m _filename, Encoding.UTF8)) {
foreach (DataTable table in ds.Tables) {
table.WriteXml( xw, XmlWriteMode.Wr iteSchema);
//table.WriteXml( xw, XmlWriteMode.Ig noreSchema);
}
}
I read it back using this:
DataSet ds = new DataSet();
ds.ReadXml(open FileDlg1.FileNa me, XmlReadMode.Rea dSchema);
foreach (DataTable table in ds.Tables) {
dgv.DataSource = table.DefaultVi ew;
}
There is typically only one (1) table in the view, but my use of foreach
prevents errors while reminding me of the possibilities! :)
A CSV option is included in the SaveAs Dialog Box for the Clients to select
from.
I'm just trying to figure out a little of this XML stuff. :)
"Ignacio Machin ( .NET/ C# MVP )" wrote:
On Aug 25, 12:52 pm, jp2msft <jp2m...@discus sions.microsoft .com>
wrote:
I've got a DataSet that I save as XML using the DataSet DataTable's WriteXml
method.
If I say XmlWriteMode.Ig noreSchema, it shows up great in Excel, but I can
not reopen the file in my application because there is no schema for it.
On the other hand, I can choose XmlWriteMode.Wr iteSchema, and the data in
Excel looks more like some kind of code instead of the data: id=NewDataSet,
name=NewDataSet , ns1:IsDataSet=T RUE, etc. If I open this file in Notepad, my
data is there, bunched between a lot of this difficult to read other info..
Is there some common ground that I am missing?
I write the XML file using this:
using (XmlTextWriter xw = new XmlTextWriter(m _filename, Encoding.UTF8)) {
foreach (DataTable table in ds.Tables) {
table.WriteXml( xw, XmlWriteMode.Wr iteSchema);
//table.WriteXml( xw, XmlWriteMode.Ig noreSchema);
}
}
I read it back using this:
DataSet ds = new DataSet();
ds.ReadXml(open FileDlg1.FileNa me, XmlReadMode.Rea dSchema);
foreach (DataTable table in ds.Tables) {
dgv.DataSource = table.DefaultVi ew;
}
There is typically only one (1) table in the view, but my use of foreach
prevents errors while reminding me of the possibilities! :)
Hi,
Have you tried to export it to CSV instead?
CSV is readable by Excel (most of the cases Excel is teh default
program for .CSV files) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Maria L. |
last post by:
Hi,
I need to export the content of a DataGrid (in Windows application in C#), into
an Excel spreadsheet.
Anyone knows how to do this? Any code snippets would help!
thanks a lot,
Maria
|
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();
excel.Application.Workbooks.Add(true);
DataTable table = DATASETNAME.Tables;
|
by: Kevin Blakeley |
last post by:
I know this was just posted but I did not want this message to get lost in
the other thread as it's slightly different.
Yes I want to export my dataset to excel for my clients, but I don't want it
to show in the browser. Everything I have tried makes it so that IE will
load excel within the browser session and view the file in there. What I
want is for the user to be prompted with the save dialog to save the excel
file disk. How do I...
|
by: ad |
last post by:
I used the code below to export a table in a dataset to Excel.
It can export only on table at a time.
Can export more than on table in a dataset to Excel
public static void Convert(System.Data.DataSet ds, int TableIndex,
System.Web.HttpResponse response)
{
if (TableIndex > ds.Tables.Count - 1)
{
|
by: John Z. |
last post by:
I have read numerous articles and postings on various approaches to
exporting
a DataSet to excel while avoiding the use of automation. I found the
most performant approach to be assigning a string array of data to a
range in excel (similar to a copyfromrecordset). However, with this
approach, the datatype is lost and all numeric columns in excel appear
as string.
In order to overcome this, I tried calling TextToColumns on each...
| |
by: Scott M. Lyon |
last post by:
I'm trying to figure out a way to export data (actually the result of a
Stored Procedure call from SQL Server) into a specified Excel spreadsheet
format.
Currently, I have the data read into a DataSet that consists of one
DataTable.
That DataTable has a specific name (for arguments purposes, let's say it's
called "DataGrid"), that I need to use as the tab name in the exported Excel
|
by: Sachin Salgarkar |
last post by:
I have a DataSet that I need to export to Excel.
The dataset has multiple tables. I need a way to export the complete dataset
to a single Excel Workbook with sheets for each table in the dataset.
Is that possible ?
I have seen solutions that export a single table to an Excel file.
Opening the XML ( DataSet.getXML() ) in Excel is a little complicated for
our users. Besides , the XML mappings are on the same sheet.
|
by: DennisBetten |
last post by:
First of all, I need to give some credit to Mahesh Chand for providing me with an excellent basis to export data to excel.
What does this code do:
As the title says, this code is capable of extracting all tables and it's data from any given database! I was searching the net for a program like this, but I didn't come accross any (free) versions. So I decided to write it myself.
To get this code to work, you need to add a reference to...
|
by: hemantbasva |
last post by:
Note We need to have a template on server for generating report in multiple sheet
as we do not had msoffice on server
moreover this require a batch job to delete excel file created by the method....
it creates 6 sheets
# region Namespaces
using System;
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |