473,513 Members | 2,708 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Export DataTable to XML using XSL file

Hi

I'd like to get a populated datatable, create an in memory xml document
(file shouldn't be more than a couple of meg), load an XSLT file, do a
transform and stream it to a browser. What am I Missing please?

MemoryStream strm = new MemoryStream();

XmlWriter writer = XmlWriter.Create(strm);

DataTable dataTbl = new myBLL().GetAll();

dataTbl.WriteXml(writer);

// Load the style sheet.

XslCompiledTransform xslt = new XslCompiledTransform();

xslt.Load(Server.MapPath("~/docs/Accounts.xsl"));

// Execute the transform and output the results to a file.

xslt.Transform(?, file to sent to response stream);

Thanks

Andrew
Jun 19 '07 #1
3 10974
J055 schreef:
Hi

I'd like to get a populated datatable, create an in memory xml document
(file shouldn't be more than a couple of meg), load an XSLT file, do a
transform and stream it to a browser. What am I Missing please?

MemoryStream strm = new MemoryStream();

XmlWriter writer = XmlWriter.Create(strm);

DataTable dataTbl = new myBLL().GetAll();

dataTbl.WriteXml(writer);

// Load the style sheet.

XslCompiledTransform xslt = new XslCompiledTransform();

xslt.Load(Server.MapPath("~/docs/Accounts.xsl"));

// Execute the transform and output the results to a file.

xslt.Transform(?, file to sent to response stream);
Since you're talking about streaming to webbrowser i'll presume you have
access to an HttpContext... Output the right content-type header
(probably text/xml) and create an XmlWriter from the
Response.Outputstream... Then pass in that writer instance in the
Transform method...
--
Tim Van Wassenhove - Read my mind <url:http://www.timvw.be/>
Jun 19 '07 #2
J055 wrote:
I'd like to get a populated datatable, create an in memory xml document
(file shouldn't be more than a couple of meg), load an XSLT file, do a
transform and stream it to a browser. What am I Missing please?

MemoryStream strm = new MemoryStream();

XmlWriter writer = XmlWriter.Create(strm);

DataTable dataTbl = new myBLL().GetAll();

dataTbl.WriteXml(writer);

// Load the style sheet.

XslCompiledTransform xslt = new XslCompiledTransform();

xslt.Load(Server.MapPath("~/docs/Accounts.xsl"));

// Execute the transform and output the results to a file.

xslt.Transform(?, file to sent to response stream);


MemoryStream strm = new MemoryStream();
DataTable dataTbl = new myBLL().GetAll();

dataTbl.WriteXml(strm);

strm.Position = 0;

// Load the style sheet.

XslCompiledTransform xslt = new XslCompiledTransform();

xslt.Load(Server.MapPath("~/docs/Accounts.xsl"));

// Execute the transform and output the results to a file.

Response.ContentType = "application/xml";

using (XmlReader xmlReader = XmlReader.Create(strm))
{
xslt.Transform(xmlReader, (XsltArgumentList)null, Response.OutputStream);
}
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jun 19 '07 #3
Hello Andrew,
Thanks for Martin and Tim's suggestion.

I also agree with them.
xslt.Transform(xmlReader, (XsltArgumentList)null, Response.OutputStream)
could output the stream transformed from XSLT to web browser.

Do you meet any further issue on this?
Please feel free to update here. Thus, we could follow up.:)

Have a great day,
Sincerely,
Wen Yuan
Microsoft Online Community Support
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 21 '07 #4

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

Similar topics

8
2830
by: DC Gringo | last post by:
I have a simple button that should open another window and export a datagrid to an Excel file. I'm getting: "Name 'window' is not declared." What do I need to declare or import? <INPUT...
3
8016
by: nologin | last post by:
Is it possible to export data exposed by DataView to Excel file for example ? Seba
2
2325
by: David Richards | last post by:
Hi, I was wondering if anyone could help me. I have DataSet that contains the following data tables Customers, Calls, Quotes, QuoteDetails, Competitors, Contacts, Notes, and I have setup...
3
11671
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...
1
2764
by: cehether | last post by:
Hello everyone. I am trying to export the contents of a DataGrid to MS Excel using VB.NET 2003. I read of a couple different ways of doing that here (though I couldn't tell which version of...
4
9589
by: =?Utf-8?B?anAybXNmdA==?= | last post by:
I've got a DataSet that I save as XML using the DataSet DataTable's WriteXml method. If I say XmlWriteMode.IgnoreSchema, it shows up great in Excel, but I can not reopen the file in my...
19
11207
by: cj2 | last post by:
#1 Is there a quick way to export a datatable to an excel file? Or delimited file? #2 Where is the appropriate Microsoft monitored group to ask about writing reports in SQL Reporting services...
0
1725
by: chago | last post by:
Hi all, I am trying to adapt a program, by transforming the output part of it, so it can export to ODBC(SAS), as previously it exported to plain text. Thus I create an SqlDataAdapter "da" by...
2
6390
hemantbasva
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...
1
7098
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
5683
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
5085
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
4745
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
3232
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
3221
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1592
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 ...
1
798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
455
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.