473,503 Members | 12,136 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Multiple Workseets in Excel using XSLT transforms form XML(ASP.Net)

1 New Member
How does one introduce multiple worksheets in a excel using Xslt Transforms
my code... Please suggest

Expand|Select|Wrap|Line Numbers
  1. <xsl:stylesheet
  2.     version="1.0"
  3.     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  4.     xmlns:o="urn:schemas-microsoft-com:office:office"
  5.     xmlns:x="urn:schemas-microsoft-com:office:excel">
  6.   <xsl:output method="html" encoding="UTF-8"/>
  7.   <xsl:template match="/">
  8.     <html>
  9.       <head>
  10.         <title></title>
  11.         <xml>
  12.           <x:ExcelWorkbook>
  13.             <x:ExcelWorksheets>
  14.               <x:ExcelWorksheet>
  15.                 <x:Name>Sheet 1</x:Name>
  16.                 <x:Table>
  17.                 <xsl:apply-templates select="DeptData"></xsl:apply-templates>
  18.                 </x:Table>
  19.                 <x:WorksheetOptions>
  20.                   <x:DefaultRowHeight>210</x:DefaultRowHeight>
  21.                   <x:Print>
  22.                     <x:FitHeight>0</x:FitHeight>
  23.                     <x:ValidPrinterInfo/>
  24.                     <x:Scale>100</x:Scale>
  25.                     <x:HorizontalResolution>600</x:HorizontalResolution>
  26.                     <x:VerticalResolution>600</x:VerticalResolution>
  27.                   </x:Print>
  28.                   <x:Selected/>
  29.                   <x:DoNotDisplayGridlines>False</x:DoNotDisplayGridlines>
  30.                   <x:ProtectContents>False</x:ProtectContents>
  31.                   <x:ProtectObjects>False</x:ProtectObjects>
  32.                   <x:ProtectScenarios>False</x:ProtectScenarios>
  33.                 </x:WorksheetOptions>
  34.                 <x:PageBreaks>
  35.                 </x:PageBreaks>
  36.               </x:ExcelWorksheet>
  37.               <x:ExcelWorksheet>
  38.                 <x:Name>Sheet 2</x:Name>
  39.                 <x:Table>
  40.                   <xsl:apply-templates select="EmpData"></xsl:apply-templates>
  41.                 </x:Table>
  42.                 <x:WorksheetOptions>
  43.                   <x:DefaultRowHeight>210</x:DefaultRowHeight>
  44.                   <x:Print>
  45.                     <x:FitHeight>0</x:FitHeight>
  46.                     <x:ValidPrinterInfo/>
  47.                     <x:Scale>100</x:Scale>
  48.                     <x:HorizontalResolution>600</x:HorizontalResolution>
  49.                     <x:VerticalResolution>600</x:VerticalResolution>
  50.                   </x:Print>
  51.                   <x:Selected/>
  52.                   <x:DoNotDisplayGridlines>False</x:DoNotDisplayGridlines>
  53.                   <x:ProtectContents>False</x:ProtectContents>
  54.                   <x:ProtectObjects>False</x:ProtectObjects>
  55.                   <x:ProtectScenarios>False</x:ProtectScenarios>
  56.                 </x:WorksheetOptions>
  57.                 <x:PageBreaks>
  58.                 </x:PageBreaks>
  59.               </x:ExcelWorksheet>    
  60.             <x:ProtectStructure>False</x:ProtectStructure>
  61.             <x:ProtectWindows>False</x:ProtectWindows>
  62.               </x:ExcelWorksheets>
  63.           </x:ExcelWorkbook>
  64.         </xml>
  65.       </head>
  66.       <body>
  67.         <table>
  68.           <tr>
  69.             <td >Group</td>
  70.             <td >Code</td>
  71.           </tr>
  72.           <xsl:for-each select="//ResultItemDeptSearch">
  73.             <tr>
  74.               <td >
  75.                 <xsl:value-of select="Group" />
  76.               </td>
  77.               <td >
  78.                 <xsl:value-of select="Dept" />
  79.               </td>
  80.             </tr>
  81.           </xsl:for-each>
  82.         </table>
  83.       </body>
  84.       <body>
  85.         <table>
  86.           <tr>
  87.             <td >Business Group</td>
  88.             <td >Department Code</td>
  89.           </tr>
  90.           <xsl:for-each select="//ResultItemDeptSearch">
  91.             <tr>
  92.               <td >
  93.                 <xsl:value-of select="BusinessGroup" />
  94.               </td>
  95.               <td >
  96.                 <xsl:value-of select="DeptCode" />
  97.               </td>
  98.             </tr>
  99.           </xsl:for-each>
  100.         </table>
  101.       </body>
  102.     </html>
  103.   </xsl:template>
  104.   </xsl:stylesheet>
  105.  
this is putting all the data in sheet 1
sheet 2 is blank
Aug 21 '07 #1
4 7106
jkmyoung
2,057 Recognized Expert Top Contributor
Would need to see your xml source, but I'm guessing that the
EmpData nodes are not at the same level as the DeptData nodes.

I'm assuming you have not listed your templates for EmpData and DeptData?

Are employees under the Dept nodes?

You might be able to fix by simply changing EmpData to //EmpData
Aug 21 '07 #2
souravXML
1 New Member
What i have to do ,if i want some other contents in sheet2 i.e not a blank sheet
Thanks
Mar 20 '08 #3
jkmyoung
2,057 Recognized Expert Top Contributor
To answer your original question,

Create another <x:ExcelWorksheet> node, and put your data in there.

Did you want one Worksheet per EmpNode?


My original response was off, sorry.
Mar 24 '08 #4
ritzkandy
1 New Member
What i have to do ,if i want some other contents in sheet2 i.e not a blank sheet
Thanks
SouravXML, just wanted to know if you were able to achieve contents in multiple excel worksheets. I have a similar requirement and wanted to know..

Thanks!
Sep 11 '08 #5

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

Similar topics

9
1777
by: LarryR | last post by:
The following XSLT works fine using MSXML 4.0 (e.g I receive a result in about 20 seconds), but effectively hangs in both .NET 1.0 sp2 with the XML hot fix and NET 1.1. My source XML file is...
3
2549
by: D. Shane Fowlkes | last post by:
Sorry for the length of this post. I have created a rather complex form which has a header/line item (parent and child records) structure. It's for an intranet. A screenshot can be seen here: ...
3
1443
by: darin dimitrov | last post by:
Hello, I have the following Html form: <form name="submitForProcess" action="http://localhost/xml/process.aspx" method="post" enctype="multipart/form-data"> <input type="text"...
4
3178
by: Josh Behl | last post by:
When I try to programmatically open an existing Excel document using a custom windows form, it works perfectly. I instanciate a new instance of the Excel.ApplicationClass and then set the Visible...
11
5615
by: Not Me | last post by:
Hi, I'm trying to export from a gridview control, to an excel file using code intended for a datagrid control (it's all over the web, can post if requested) I get the error. Control...
0
951
by: Wesley | last post by:
Hi, I'm creating a report in Excel using asp.net, but I can't release the Excel instance from memory. Excel.exe stays in the Windows Task Manager. Below is an example of the code I'm using: ...
2
4210
by: Sasquatch | last post by:
I'm having trouble creating a simple login page using the asp:login control. I followed some instructions in a WROX book, "Beginning ASP.NET 2.0," and the instructions are very straight forward,...
5
2293
by: Rajesh | last post by:
Hi, Please help me to do an EXCEL report generation using ASP.NET. I am building an website. This should work in all machine. I need do load the data from SQL tables to excel sheet and user can...
1
1530
by: micawber | last post by:
I would like to search and find records from Excel using ASP. Here is what I have so far, Can anyone help me? Thanks. <% Option Explicit Dim strConnection, conn, rs, strSQL, freephone
4
15392
by: =?Utf-8?B?Sm9zaW4gSm9obg==?= | last post by:
I could create MS Excel sheet using ASP.NET 2.0 with C# but it is not being created in some systems, following error occurs when the program compiles : Microsoft Office Excel cannot open or...
0
7212
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
7296
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
7364
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
7017
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
7470
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...
1
5026
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
4696
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
3186
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...
1
751
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.