473,395 Members | 2,436 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

To create xsl with multiple worksheet

Hi all,
I 've created an xsl file to create an excel Workbook with multiple worksheets, thro' xslt. My code works fine for sheet1. Sheet2 was created but has no data. So please help me to fill data in sheet2 also. My code is here
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="utf-8"?>
  2.  
  3. <xsl:stylesheet version="1.0"
  4.    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  5.  
  6.     <xsl:template match="/">
  7.         <html xmlns:o="urn:schemas-microsoft-com:office:office"
  8.        xmlns:x="urn:schemas-microsoft-com:office:excel"
  9.               xmlns:s="urn:schemas-microsoft-com:office:spreadsheet"
  10.           xmlns="http://www.w3.org/TR/REC-html40">
  11.             <head>
  12.                 <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
  13.                 <style>
  14.                     .xlText{mso-number-format:"@";text-align:left;font-family:新細明體;font-size:12px;}
  15.                     .xlHeader{font-family:新細明體;font-size:12px;background:#CCFFCC;}
  16.                     .xlEach{font-family:新細明體;font-size:12px;}
  17.                     .xlTitle{font-size:20px;font-family:新細明體;font-weight:bold;background:#FFFF99;height:30px;}
  18.                     .xlDate{mso-number-format:"yyyy/mm/dd_ ";}
  19.                 </style>
  20.                 <xml>
  21.                     <x:ExcelWorkbook>
  22.                         <x:ExcelWorksheets>
  23.                             <x:ExcelWorksheet>
  24.                                 <x:Name>summary</x:Name>
  25.                                 <x:WorksheetOptions>
  26.                                     <x:ProtectContents>False</x:ProtectContents>
  27.                                     <x:ProtectObjects>False</x:ProtectObjects>
  28.                                     <x:ProtectScenarios>False</x:ProtectScenarios>
  29.                                 </x:WorksheetOptions>
  30.                             </x:ExcelWorksheet>
  31.                             <x:ExcelWorksheet >
  32.                                 <x:Name>GateMoves</x:Name>
  33.                                 <Table x:name="GateMoves"  x:FullColumns="1" x:FullRows="1">
  34.                                     <tr>
  35.                                         <td align="Center" class="xlHeader">Month</td>
  36.                                         <td align="Center" class="xlHeader">Activity</td>
  37.                                         <td align="Center" class="xlHeader">count</td>
  38.                                         <xsl:for-each select="NewDataSet/Table">
  39.                                             <tr>
  40.                                                 <td class="xlEach">
  41.                                                     <xsl:value-of select="Month" />
  42.                                                 </td>
  43.                                                 <td class="xlEach">
  44.                                                     <xsl:value-of select="Activity" />
  45.                                                 </td>
  46.                                                 <td class="xlEach">
  47.                                                     <xsl:value-of select="count" />
  48.                                                 </td>
  49.  
  50.                                             </tr>
  51.                                         </xsl:for-each>
  52.                                     </tr>
  53.                                 </Table>
  54.                                 <x:WorksheetOptions>
  55.                                     <x:ProtectContents>False</x:ProtectContents>
  56.                                     <x:ProtectObjects>False</x:ProtectObjects>
  57.                                     <x:ProtectScenarios>False</x:ProtectScenarios>
  58.                                 </x:WorksheetOptions>
  59.                             </x:ExcelWorksheet>
  60.                         </x:ExcelWorksheets>
  61.                     </x:ExcelWorkbook>
  62.                 </xml>
  63.             </head>
  64.  
  65.             <body >
  66.                 <table border="1" cellpadding="0" cellspacing="0" width="100%" x:worksheet="GateMoves">
  67.                     <tr>
  68.                         <td align="Center" class="xlHeader">Month</td>
  69.                             <td align="Center" class="xlHeader">Activity</td>
  70.                             <td align="Center" class="xlHeader">count</td>
  71.                             <xsl:for-each select="NewDataSet/Table">
  72.                                 <tr>
  73.                                     <td class="xlEach">
  74.                                         <xsl:value-of select="Month" />
  75.                                     </td>
  76.                                     <td class="xlEach">
  77.                                         <xsl:value-of select="Activity" />
  78.                                     </td>
  79.                                     <td class="xlEach">
  80.                                         <xsl:value-of select="count" />
  81.                                     </td>
  82.  
  83.                                 </tr>
  84.                             </xsl:for-each>
  85.                         </tr>
  86.                         </table>        
  87.                         </body >                    
  88.         </html>
  89.     </xsl:template>
  90.  
  91. </xsl:stylesheet>

With Thanks,

Sudha
Dec 23 '08 #1
1 10664
jkmyoung
2,057 Expert 2GB
Which version of excel are you using? I'm confused as to why you have a mix of html and word xml.

Would normally advise populating a table in a second worksheet node.
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0"?>
  2. <?mso-application progid="Excel.Sheet"?>
  3. <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40">
  4.     <Worksheet ss:Name="Sheet1">
  5.         <Table ss:ExpandedColumnCount="1" ss:ExpandedRowCount="1" x:FullColumns="1" x:FullRows="1">
  6.             <Row>
  7.                 <Cell>
  8.                     <Data ss:Type="String">Sheet1Data</Data>
  9.                 </Cell>
  10.             </Row>
  11.         </Table>
  12.     </Worksheet>
  13.     <Worksheet ss:Name="Sheet2">
  14.         <Table ss:ExpandedColumnCount="1" ss:ExpandedRowCount="1" x:FullColumns="1" x:FullRows="1">
  15.             <Row>
  16.                 <Cell>
  17.                     <Data ss:Type="String">Sheet2Data</Data>
  18.                 </Cell>
  19.             </Row>
  20.         </Table>
  21.     </Worksheet>
  22. </Workbook>
  23.  
Dec 23 '08 #2

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

Similar topics

1
by: Brian Johnson | last post by:
I am trying to create multiple (named) worksheets in excel using .Net PIA's. I have successfully created an excel document and set cell values, but have been unable to manipulate which worksheet...
4
by: Krishna Tulasi via .NET 247 | last post by:
Hi, I am having trouble with creation of XML programmatically using .NET. Specifically Im trying to create an element which looks like below and insert into an existing xml doc: <Worksheet...
8
by: Horst Walter | last post by:
I create an Excel worksheet in C# (should be similar in VB) Connection String: "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filename + ";" + "Extended Properties=Excel 8.0;"; Create...
0
by: Dayron | last post by:
Hi, I'm retreving a large bunch of records from database and I wish to disply the records in the excel workbook. unfortunately the worksheet just can support until 65,535 records in a single...
3
by: James Wong | last post by:
Dear all, I have an old VB6 application which can create and access Excel object. The basic definition statements are as follows: Dim appExcel As Object Dim wkb1 As Excel.Workbook Dim wks1...
1
by: yalebulldog05 | last post by:
Watsup everyone, I'm having 2 problems, both dealing with similar themes of having code work for all possible series/worksheets, so i'm wondering if there's a macro that deals with this: 1) I'd...
3
by: sejal17 | last post by:
hello Can any one tell me how to read multiple worksheets from a single excel file.I have stored that excel in xml file.so i want to read that xml that has multiple worksheet.And i want to store...
3
by: sejal17 | last post by:
hello Can any one tell me how to read multiple worksheets from a single excel file.I have stored that excel in xml file.so i want to read that xml that has multiple worksheet.And i want to store...
1
by: TG | last post by:
Hi! I have an application in which I have some checkboxes and depending which ones are checked those columns will show in the datagridview from sql server or no. After that I have 2 buttons:...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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...
0
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
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
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,...

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.