Hello, how can I insert a single image on the top of a XSL document?
I tried this code below:

<xsl:stylesheet version="1.0"
xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:msxsl="urn:schemas-microsoft-com:xslt"
 xmlns:user="urn:my-scripts"
 xmlns:o="urn:schemas-microsoft-com:office:office"
 xmlns:x="urn:schemas-microsoft-com:office:excel"
 xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" >
      <xsl:template match="/">
        <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">

        <!-- Styles added....      -->
        <Styles>
              <Style ss:ID="Default" ss:Name="Normal">
                    <Alignment ss:Horizontal="Left" ss:Vertical="Bottom"/>
                    <Borders/>
                    <Font ss:FontName="Times New Roman" x:Family="Roman" ss:Size="8"/>
                    <Interior/>
                    <NumberFormat/>
                    <Protection/>
              </Style>
              <Style ss:ID="sWrapText">
                    <Alignment ss:Horizontal="Center" ss:Vertical="Bottom" ss:WrapText="1"/>
                    <Font ss:FontName="Times New Roman" x:Family="Roman" ss:Size="8"/>
              </Style>
              <Style ss:ID="s21">
                    <Font ss:FontName="Times New Roman" x:Family="Roman" ss:Size="8"/>
                    <Alignment ss:Horizontal="Center" ss:Vertical="Bottom"/>
              </Style>
              <Style ss:ID="s22">
                    <Borders>
                          <Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1"/>
                          <Border ss:Position="Left" ss:LineStyle="None" ss:Weight="0"/>
                          <Border ss:Position="Right" ss:LineStyle="None" ss:Weight="0"/>
                          <Border ss:Position="Top" ss:LineStyle="None" ss:Weight="0"/>
                    </Borders>
                    <Font ss:FontName="Times New Roman" x:Family="Roman" ss:Size="10" ss:Color="#000000" ss:Bold="1"/>
                <Alignment ss:Horizontal="Center" ss:Vertical="Bottom"/>
                    <Interior ss:Color="#3fbecc" ss:Pattern="Solid"/>
              </Style>
              <Style ss:ID="s23">
                    <Alignment ss:Horizontal="Center" ss:Vertical="Bottom"/>
                    <Font ss:FontName="Times New Roman" x:Family="Roman" ss:Size="8"/>
              </Style>
        </Styles>
              <xsl:apply-templates/>
        </Workbook>
  </xsl:template>
  <xsl:template match="/*">
        <Worksheet>
              <xsl:attribute name="ss:Name">
                    <xsl:value-of select="local-name(/*/*)"/>
              </xsl:attribute>

              <Table  x:ExpandedColumnCount="10" x:ExpandedRowCount="10" x:FullColumns="1" x:FullRows="1">
                <picture>
                  <xsl:attribute name="source">
                    <xsl:value-of select="frog.JPG" />
                  </xsl:attribute>
                </picture>
                <xsl:for-each select="*[position() = 1]/*">
                  <Column ss:StyleID="s21" ss:Width="150"/>
                </xsl:for-each>
                   <Row ss:AutoFitHeight="0" ss:Height="50.0625">

                          <!--      Set the Header Hieght's-->
                          <xsl:if test="position() = 1">
                                <xsl:attribute name="ss:Height">50</xsl:attribute>
                          </xsl:if>

                          <!-- Set styles for the headers -->
                          <xsl:for-each select="*[position() = 1]/*">

                                            <Cell ss:StyleID="s22" >
                                                  <!-- CHANGE HERE, added style attribute. -->
                                                  <Data ss:Type="String">
                                                        <xsl:value-of select="local-name()"/>
                                                  </Data>
                                            </Cell>

                                </xsl:for-each>

                    </Row>
                    <xsl:apply-templates/>
              </Table>
        </Worksheet>
  </xsl:template>

  <xsl:template match="/*/*/*">
        <Cell>
              <xsl:if test="string-length(.) &gt; 254">
                    <xsl:attribute name="ss:StyleID">sWrapText</xsl:attribute>
              </xsl:if>

              <Data ss:Type="String">
                    <xsl:value-of select="."/>
              </Data>

        </Cell>
  </xsl:template>
  <xsl:template match="/*/*">
        <Row>
              <xsl:if test="string-length(*) &gt; 254">
                    <xsl:attribute name="ss:Height">
                          <xsl:for-each select="*[string-length(.) &gt; 254]">
                                <xsl:sort select="string-length(.)" order="descending"/>
                                <xsl:if test="position()=1">
                                      <xsl:value-of select="11.25 * (string-length(.) div 50 + 1)"/>
                                </xsl:if>
                          </xsl:for-each>
                    </xsl:attribute>
              </xsl:if>
              <xsl:apply-templates/>
        </Row>
  </xsl:template>
</xsl:stylesheet>

It looks like that was from some sheet. That is, you didn't type all that but saved it from Excel.

To see what an inserted image looks like, use this sheet and in Excel insert what you want. Now compare the xsl files to see what Excel did. You can then code that up in C#.

Hello, I tried to do this idea, but when I convert to xml to see the code it takes off the image i put in excel as a header or as a part of the table =/

The topic is about XSL and if you have a new issue such as XSL to XML conversion then you would start a discussion about that.

I don't want to convert anything, I just want to insert an image in this code.
I tried
" </xsl:attribute>"
and it doesnt work, so I want to know what kind of code i should write to make the image work.

when I convert to xml

Back to Excel and save as XLS (or Excel's own XLS) and examine that there. If you convert it the image may indeed be lost but XML and XML conversion not in your top post or topic title.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.