Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8832623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:34:35+00:00 2026-06-14T08:34:35+00:00

I need to change existing xml in order to make an excel table from

  • 0

I need to change existing xml in order to make an excel table from it.

My xml that needs to be changed:

<rows>
  <row>
    <cell image="blank.gif">Row1</cell>
    <cell>1</cell>
    <cell>2</cell>
    <cell>3</cell>
    <cell>4</cell>
    <cell>5</cell>
    <cell>6</cell>
    <cell>7</cell>
    <row>
      <cell image="blank.gif">Row1_1</cell>
      <cell>8</cell>
      <cell>9</cell>
      <cell>10</cell>
      <cell>11</cell>
      <cell>12</cell>
      <cell>13</cell>
      <cell>14</cell>
    </row>
    <row>
      <cell image="blank.gif">Row1_2</cell>
      <cell>15</cell>
      <cell>16</cell>
      <cell>17</cell>
      <cell>18</cell>
      <cell>19</cell>
      <cell>20</cell>
      <cell>21</cell>
    </row>
  </row>
  <row>
    <cell image="blank.gif">Row2</cell>
    <cell>22</cell>
    <cell>23</cell>
    <cell>24</cell>
    <cell>25</cell>
    <cell>26</cell>
    <cell>27</cell>
    <cell>28</cell>
  </row>
</rows>

My current XSLT:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
  <xsl:output method="xml" indent="yes"/>



  <xsl:template match="rows">
    <xsl:element name="sheetData">
      <xsl:apply-templates select="row"></xsl:apply-templates>
    </xsl:element>
  </xsl:template>



  <xsl:template match="row">
    <xsl:variable name="rowID">
      <xsl:number value="position()" format="1"/>
    </xsl:variable>
    <xsl:element name="row">
      <xsl:attribute name="r">
        <xsl:value-of select="$rowID"/>
      </xsl:attribute>



      <xsl:for-each select="*">
        <xsl:element name="c">
          <xsl:variable name="colID">
            <xsl:number value="position()" format="A"/>
          </xsl:variable>
          <xsl:attribute name="r">
            <xsl:value-of  select="concat(string($colID),string($rowID))"/>
          </xsl:attribute>
          <xsl:attribute name="t">
            <xsl:text>inlineStr</xsl:text>
          </xsl:attribute>
          <xsl:element name="is">
            <xsl:element name="t">
              <xsl:value-of select="."/>
            </xsl:element>
          </xsl:element>
        </xsl:element>
      </xsl:for-each>

    </xsl:element>
  </xsl:template>

</xsl:stylesheet>

My output from the transformations:

<sheetData>
 <row r="1">
  <c r="A1" t="inlineStr">
      <is>
      <t>Row1</t> 
      </is>
  </c>
  <c r="B1" t="inlineStr">
      <is>
      <t>1</t> 
      </is>
  </c>
  <c r="C1" t="inlineStr">
      <is>
      <t>2</t> 
      </is>
  </c>
  <c r="D1" t="inlineStr">
      <is>
      <t>3</t> 
      </is>
  </c>
  <c r="E1" t="inlineStr">
      <is>
      <t>4</t> 
      </is>
  </c>
  <c r="F1" t="inlineStr">
      <is>
      <t>5</t> 
      </is>
  </c>
  <c r="G1" t="inlineStr">
      <is>
      <t>6</t> 
      </is>
  </c>
  <c r="H1" t="inlineStr">
      <is>
      <t>7</t> 
      </is>
  </c>
  <c r="I1" t="inlineStr">
      <is>
      <t>Row1_1891011121314</t> 
      </is>
  </c>
  <c r="J1" t="inlineStr">
      <is>
      <t>Row1_215161718192021</t> 
      </is>
  </c>
  </row>
  <row r="2">
  <c r="A2" t="inlineStr">
      <is>
      <t>Row2</t> 
      </is>
  </c>
  <c r="B2" t="inlineStr">
      <is>
      <t>22</t> 
      </is>
  </c>
  <c r="C2" t="inlineStr">
      <is>
      <t>23</t> 
      </is>
  </c>
  <c r="D2" t="inlineStr">
      <is>
      <t>24</t> 
      </is>
  </c>
  <c r="E2" t="inlineStr">
      <is>
      <t>25</t> 
      </is>
  </c>
  <c r="F2" t="inlineStr">
      <is>
      <t>26</t> 
      </is>
  </c>
  <c r="G2" t="inlineStr">
      <is>
      <t>27</t> 
      </is>
  </c>
  <c r="H2" t="inlineStr">
      <is>
      <t>28</t> 
      </is>
  </c>
 </row>
</sheetData>

And a screenshot from the generated excel document:
Screenshot

So my problem is the nested rows i need to show them exactly like Row1 and Row2

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T08:34:37+00:00Added an answer on June 14, 2026 at 8:34 am

    I think what you are saying is that you want a separate row in the output for each row in the input XML, even though the row elements are nested.

    To start with then, you need to replace this line

    <xsl:for-each select="*">
    

    With this…

    <xsl:for-each select="cell">
    

    This will ensure only the cell elements are output in the current row, and the nested row elements won’t be processed.

    Then, after you have created the row element with just the cell elements, you can look for the nested row elements to output these

    <row>
       <!-- Process Cells -->
    </row>
    <xsl:apply-templates select="row"/>
    

    Do note there is no real need to use xsl:element to output static named elements, just write out the element directly. Your code can also be tidied up by making use of Attribute Value Templates to create attributes, rather than using xsl:attribute

    Try the following XSLT:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
       <xsl:output method="xml" indent="yes"/>
    
       <xsl:template match="rows">
          <sheetData>
             <xsl:apply-templates select="row"/>
          </sheetData>
       </xsl:template>
    
       <xsl:template match="row">
          <xsl:variable name="rowID">
             <xsl:number level="any" format="1"/>
          </xsl:variable>
          <row r="{$rowID}">
             <xsl:for-each select="cell">
                <xsl:variable name="colID">
                   <xsl:number value="position()" format="A"/>
                </xsl:variable>
                <c t="inlineStr" r="{string($colID)}{string($rowID)}">
                   <is>
                      <t>
                         <xsl:value-of select="."/>
                      </t>
                   </is>
                </c>
             </xsl:for-each>
          </row>
          <xsl:apply-templates select="row"/>
       </xsl:template>
    </xsl:stylesheet>
    

    When applied to your XML, the following is output

    <sheetData>
       <row r="1">
          <c t="inlineStr" r="A1">
             <is>
                <t>Row1</t>
             </is>
          </c>
          <c t="inlineStr" r="B1">
             <is>
                <t>1</t>
             </is>
          </c>
          <c t="inlineStr" r="C1">
             <is>
                <t>2</t>
             </is>
          </c>
          <c t="inlineStr" r="D1">
             <is>
                <t>3</t>
             </is>
          </c>
          <c t="inlineStr" r="E1">
             <is>
                <t>4</t>
             </is>
          </c>
          <c t="inlineStr" r="F1">
             <is>
                <t>5</t>
             </is>
          </c>
          <c t="inlineStr" r="G1">
             <is>
                <t>6</t>
             </is>
          </c>
          <c t="inlineStr" r="H1">
             <is>
                <t>7</t>
             </is>
          </c>
       </row>
       <row r="2">
          <c t="inlineStr" r="A2">
             <is>
                <t>Row1_1</t>
             </is>
          </c>
          <c t="inlineStr" r="B2">
             <is>
                <t>8</t>
             </is>
          </c>
          <c t="inlineStr" r="C2">
             <is>
                <t>9</t>
             </is>
          </c>
          <c t="inlineStr" r="D2">
             <is>
                <t>10</t>
             </is>
          </c>
          <c t="inlineStr" r="E2">
             <is>
                <t>11</t>
             </is>
          </c>
          <c t="inlineStr" r="F2">
             <is>
                <t>12</t>
             </is>
          </c>
          <c t="inlineStr" r="G2">
             <is>
                <t>13</t>
             </is>
          </c>
          <c t="inlineStr" r="H2">
             <is>
                <t>14</t>
             </is>
          </c>
       </row>
       <row r="3">
          <c t="inlineStr" r="A3">
             <is>
                <t>Row1_2</t>
             </is>
          </c>
          <c t="inlineStr" r="B3">
             <is>
                <t>15</t>
             </is>
          </c>
          <c t="inlineStr" r="C3">
             <is>
                <t>16</t>
             </is>
          </c>
          <c t="inlineStr" r="D3">
             <is>
                <t>17</t>
             </is>
          </c>
          <c t="inlineStr" r="E3">
             <is>
                <t>18</t>
             </is>
          </c>
          <c t="inlineStr" r="F3">
             <is>
                <t>19</t>
             </is>
          </c>
          <c t="inlineStr" r="G3">
             <is>
                <t>20</t>
             </is>
          </c>
          <c t="inlineStr" r="H3">
             <is>
                <t>21</t>
             </is>
          </c>
       </row>
       <row r="4">
          <c t="inlineStr" r="A4">
             <is>
                <t>Row2</t>
             </is>
          </c>
          <c t="inlineStr" r="B4">
             <is>
                <t>22</t>
             </is>
          </c>
          <c t="inlineStr" r="C4">
             <is>
                <t>23</t>
             </is>
          </c>
          <c t="inlineStr" r="D4">
             <is>
                <t>24</t>
             </is>
          </c>
          <c t="inlineStr" r="E4">
             <is>
                <t>25</t>
             </is>
          </c>
          <c t="inlineStr" r="F4">
             <is>
                <t>26</t>
             </is>
          </c>
          <c t="inlineStr" r="G4">
             <is>
                <t>27</t>
             </is>
          </c>
          <c t="inlineStr" r="H4">
             <is>
                <t>28</t>
             </is>
          </c>
       </row>
    </sheetData>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need change background of all text that have two spaces from the start
I need to change table name from lowercase to uppercase but using this statement
I use Pjax with tutorial from http://railscasts.com/episodes/294-playing-with-pjax?view=comments I don't need change url and this
I have XML that I need to parse but have no control over the
Trying to convert an existing Android build system using Ant with 'ant_rules_r3.xml' integration from
I have to make a schema for an XML format that's already being used.
I need to take an existing xml file, and modify just a few attributes
I need change first image in Galleria fullscreen theme ( link ) after Galleria.run().
i need change color of SystemTray.ProgressIndicator color, how i can do it? I tried
I have database, and in one the tables I need change the values of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.