xslt template for creating excel file with multiple worksheets

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi,<br/> I need help on this one.<br/> Am not too sure also about the forum link. Dear Moderator, if this question is not intended for this forum, can you please divert the question to appropriate forum post.<br/> <br/> My requirement is to have one Excel (*.xls) file with 5 tabs (or 5 worksheets). Each of this worksheets with be populated with 5 DataTables within a DataSet.<br/> Like, Worksheet named "Job" will be populated with dsOracleReport.Tables["Job"] value. Worksheet named "Billing" will be populated with dsOracleReport.Tables["Billing"] value and so on.<br/> <br/> I have converted the DataSet into an XML file as given by code:<br/> <br/>
<pre>XmlDocument objXmlDocument = new XmlDocument();
objXmlDocument.LoadXml(dsOracleReport.GetXml());
string strXMLFilePath = filePath + @"" + "ExceptionReport.xml";
objXmlDocument.Save(strXMLFilePath);[/code]
<br/> Now, I want to transform this XML file into an Excel file using XSLT transformation with the following code.<br/> <br/>
<pre lang="x-c# XPathDocument objXPathDocument = new XPathDocument(strXMLFilePath);
XslTransform objXslTransform = new XslTransform();
string strXSLTPath = strInstallPath + "ExceptionReport_Template.xslt";
objXslTransform.Load(strXSLTPath);
string strExcelReportFilename = string.Format(filePath + @"" + "ExceptionReport_{0}.xls", DateTime.Now.ToString("yyyyMMddHHmmss"));
XmlWriter objXmlWriter = new XmlTextWriter(strExcelReportFilename, null);
objXslTransform.Transform(objXPathDocument, null, objXmlWriter);
objXmlWriter.Close();[/code]
Can you people let me know what should be the template for "ExceptionReport_Template.xslt" file to accommodate the 5 DataTables with the DatSet into 5 separate worksheets named "Job", "Billing"  etc etc. <br/> <br/> <span style="text-decoration:underline I need some template or sample for the above purpose XSLT file. <br/><hr class="sig Best Regards,
Arka Mitra.

View the full article
 
Back
Top