I am using this xslt code to generate excel file from the xml data as input for this code. when a mail triggered from SAP CPI i am receiving the excel file but that excel file not coming in proper format all the columns are coming in some default sizes not able to see the content of the cell fully when i opened the file not able to auto adjust the column widths & Row heights based one the content of the cell. Please help me to set the column widths & row heights adjusts automatically as per the content in the cell(entire content must be visible with out double clicking at the row or columns separator lines in excel sheet after downloading the file). please help in this regard.
Thank you.
<?mso-application progid="Excel.Sheet"?>
<xsl:stylesheet version="1.0" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns0="urn:test.com" xmlns:html="http://www.w3.org/TR/REC-html40">
<xsl:template match="/">
<Workbook>
<Styles>
<Style ss:ID="Default" ss:Name="Normal">
<Alignment ss:Vertical="Bottom"/>
<Borders/>
<Font/>
<Interior/>
<NumberFormat/>
<Protection/>
</Style>
<Style ss:ID="s21">
<Font ss:Size="22" ss:Bold="1"/>
</Style>
<Style ss:ID="s22">
<Font ss:Size="14" ss:Bold="1"/>
</Style>
<Style ss:ID="s23">
<Font ss:Size="12" ss:Bold="1"/>
<Borders>
<Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1"/>
</Borders>
</Style>
<Style ss:ID="s24">
<Font ss:Size="10" ss:Bold="1"/>
</Style>
<Style ss:ID="s25">
<Borders>
<Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1"/>
</Borders>
</Style>
</Styles>
<Worksheet ss:Name="Sheet1">
<Table>
<xsl:call-template name="Excel"/>
</Table>
</Worksheet>
</Workbook>
</xsl:template>
<xsl:template name="Excel">
<Row>
<Cell ss:StyleID="s23">
<Data ss:Type="String">IntegrationFlowName</Data>
</Cell>
<Cell ss:StyleID="s23">
<Data ss:Type="String">IFlowStartTime</Data>
</Cell>
<Cell ss:StyleID="s23">
<Data ss:Type="String">MessageGUID</Data>
</Cell>
<Cell ss:StyleID="s23">
<Data ss:Type="String">ErrorMessage</Data>
</Cell>
</Row>
<xsl:for-each select="//MessageProcessingLogs">
<Row>
<Cell ss:StyleID="s25">
<Data ss:Type="String">
<xsl:value-of select="IntegrationFlowName" />
</Data>
</Cell>
<Cell ss:StyleID="s25">
<Data ss:Type="String">
<xsl:value-of select="StartTime" />
</Data>
</Cell>
<Cell ss:StyleID="s25">
<Data ss:Type="String">
<xsl:value-of select="MessageGuid" />
</Data>
</Cell>
<Cell ss:StyleID="s25">
<Data ss:Type="String">
<xsl:value-of select="ErrorMessage" />
</Data>
</Cell>
</Row>
</xsl:for-each>
</xsl:template>
<xsl:template match="MessageProcessingLogs">
</xsl:template>
</xsl:stylesheet>
CodePudding user response:
Here is how I do it :
<ss:Worksheet ss:Name="Sheet name">
<ss:Table>
<!-- Col 1 --> <ss:Column ss:Width="50"/>
<!-- Col 2 --> <ss:Column ss:Width="50"/>
<!-- Col 3 --> <ss:Column ss:Width="100"/>
<ss:Row ss:StyleID="SomeStyle">
<ss:Cell><ss:Data ss:Type="String">Col1 Contents</ss:Data></ss:Cell>
<ss:Cell><ss:Data ss:Type="String">Col2 Contents</ss:Data></ss:Cell>
<ss:Cell><ss:Data ss:Type="String">Col3 Contents</ss:Data></ss:Cell>
</ss:Row>
</ss:Table>
</ss:Worksheet>