You are on page 1of 10

* ehfnd_exp_xlsx_add_cellxfs -> Add placeholder for CellXfs

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:sap="http://www.sap.com/sapxsl"
xmlns:mn="http://schemas.openxmlformats.org/spreadsheetml/2006/main"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
version="1.0">

<xsl:param name="CELLXFS_COUNT"/>

<xsl:strip-space elements="*"/>

<xsl:template match="mn:cellXfs">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:attribute name="count">
<xsl:value-of select="$CELLXFS_COUNT"/>
</xsl:attribute>
<xsl:text>
XFS_PLACEHOLDER
</xsl:text>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>

<xsl:template match="*">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>

</xsl:stylesheet>

* EHFND_EXP_XLSX_CREATE_SHEET -> Creates a new sheet with data

<?sap.transform simple?>
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates"
xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">

<tt:root name="param"/>

<tt:template>
<worksheet
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">

<dimension>
<tt:attribute name="ref" value-ref="param.dim"/>
</dimension>

<sheetFormatPr defaultRowHeight="15">
</sheetFormatPr>

<tt:s-cond check="not-initial(param.cols_tab)">
<cols>
<tt:loop name="col" ref="param.cols_tab">
<col>
<tt:s-cond check="not-initial($col.customwidth)">
<tt:attribute name="customWidth" value-ref="$col.customwidth"/>
</tt:s-cond>
<tt:s-cond check="not-initial($col.style)">
<tt:attribute name="style" value-ref="$col.style"/>
</tt:s-cond>
<tt:s-cond check="not-initial($col.width)">
<tt:attribute name="width" value-ref="$col.width"/>
</tt:s-cond>
<tt:s-cond check="not-initial($col.max)">
<tt:attribute name="max" value-ref="$col.max"/>
</tt:s-cond>
<tt:s-cond check="not-initial($col.min)">
<tt:attribute name="min" value-ref="$col.min"/>
</tt:s-cond>
<tt:s-cond check="not-initial($col.hidden)">
<tt:attribute name="hidden" value-ref="$col.hidden"/>
</tt:s-cond>
<tt:s-cond check="not-initial($col.bestfit)">
<tt:attribute name="bestFit" value-ref="$col.bestfit"/>
</tt:s-cond>
</col>
</tt:loop>
</cols>
</tt:s-cond>

<sheetData>
<!-- data -->
<tt:loop name="row" ref="param.rows_tab">
<row>
<tt:attribute name="r" value-ref="$row.position"/>
<!-- Set the span attribute if available -->
<tt:s-cond check="not-initial($row.spans)">
<tt:attribute name="spans" value-ref="$row.spans"/>
</tt:s-cond>
<tt:loop name="cell" ref="$row.cells_tab">
<c>
<tt:attribute name="r" value-ref="$cell.position"/>
<!-- Set the style attribute if available -->
<tt:s-cond check="not-initial($cell.style)">
<tt:attribute name="s" value-ref="$cell.style"/>
</tt:s-cond>
<!-- Set the type attribute if available -->
<tt:s-cond check="not-initial($cell.sharedstring)">
<tt:attribute name="t" value-ref="$cell.sharedstring"/>
</tt:s-cond>
<!-- For shared Strings, set the index as value -->
<tt:s-cond check="$cell.sharedstring = C('s')">
<v>
<tt:value ref="$cell.index"/>
</v>
</tt:s-cond>
<!-- Otherwise we put out the value as value -->
<tt:s-cond check="($cell.sharedstring != C('s')) and (not-
initial($cell.value))">
<v>
<tt:value ref="$cell.value"/>
</v>
</tt:s-cond>

</c>
</tt:loop>
</row>
</tt:loop>
</sheetData>

<pageMargins bottom="1" footer="0.5" header="0.5" left="0.75" right="0.75"


top="1"/>
<headerFooter alignWithMargins="0"/>
<tt:s-cond check="not-initial(param.table_rid)">
<tableParts count="1">
<tablePart>
<tt:attribute name="r:id" value-ref="param.table_rid"/>
</tablePart>
</tableParts>
</tt:s-cond>
</worksheet>
</tt:template>

</tt:transform>

* ehfnd_exp_xlsx_create_styles -> Creates a new styles part

<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates"
xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"

xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">

<tt:root name="param"/>

<tt:template>

<styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">

<numFmts count="2">
<numFmt numFmtId="164" formatCode="[$-F400]hh:mm:ss\ AM/PM"/>
<numFmt numFmtId="165" formatCode="dd/mm/yy\ hh:mm:ss;@"/>
</numFmts>

<fonts count="1">
<font>
<sz val="11"/>
<name val="Calibri"/>
</font>
</fonts>
<fills count="2">
<fill>
<patternFill patternType="none"/>
</fill>
<fill>
<patternFill patternType="gray125"/>
</fill>

</fills>
<borders count="1">
<border>
<left/>
<right/>
<top/>
<bottom/>
<diagonal/>
</border>
</borders>
<cellStyleXfs count="1">
<xf numFmtId="0" fontId="0" fillId="0" borderId="0"/>
</cellStyleXfs>
<cellXfs count = "4">
<xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0" />
<xf numFmtId="14" fontId="0" fillId="0" borderId="0" xfId="0"
applyNumberFormat="1" />
<xf numFmtId="164" fontId="0" fillId="0" borderId="0" xfId="0"
applyNumberFormat="1" />
<xf numFmtId="165" fontId="0" fillId="0" borderId="0" xfId="0"
applyNumberFormat="1" />
</cellXfs>
<cellStyles count="1">
<cellStyle name="Normal" xfId="0" builtinId="0"/>
</cellStyles>
<dxfs count="0"/>
<tableStyles count="0" defaultTableStyle="TableStyleMedium9"
defaultPivotStyle="PivotStyleLight16"/>
</styleSheet>

</tt:template>

</tt:transform>

* ehfnd_exp_xlsx_create_workbook -> Creates a new workbook part

<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates"
xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"

xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">

<tt:root name="param"/>

<tt:template>
<workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
<bookViews>
<workbookView xWindow="0" yWindow="0" windowWidth="21855"
windowHeight="14940"/>
</bookViews>

<sheets>
<sheet>
<tt:attribute name="name" value-ref="param.name"/>
<tt:attribute name="sheetId" value-ref="param.sheetid"/>
<tt:attribute name="r:id" value-ref="param.relid"/>
</sheet>
</sheets>
</workbook>
</tt:template>
</tt:transform>

* ehfnd_exp_xlsx_get_cellxfs -> Get cellxfs of style sheet

<xsl:transform version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:sap="http://www.sap.com/sapxsl"
xmlns:mn="http://schemas.openxmlformats.org/spreadsheetml/2006/main"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
>

<xsl:strip-space elements="*"/>

<xsl:template match="/">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<CELLXFS>
<xsl:apply-templates select="mn:styleSheet/mn:cellXfs/mn:xf"/>
</CELLXFS>
</asx:values>
</asx:abap>
</xsl:template>

<xsl:template match="mn:styleSheet/mn:cellXfs/mn:xf">
<CELLXFS>
<NUMFMTID><xsl:value-of select="@numFmtId"/></NUMFMTID>
<FONTID><xsl:value-of select="@fontId"/></FONTID>
<FILLID><xsl:value-of select="@fillId"/></FILLID>
<BORDERID><xsl:value-of select="@borderId"/></BORDERID>
<XFID><xsl:value-of select="@xfId"/></XFID>
<APPLYFONT><xsl:value-of select="@applyFont"/></APPLYFONT>
<APPLYFILL><xsl:value-of select="@applyFill"/></APPLYFILL>
<APPLYBORDER><xsl:value-of select="@applyBorder"/></APPLYBORDER>
<APPLYNUMBERFORMAT><xsl:value-of
select="@applyNumberFormat"/></APPLYNUMBERFORMAT>
</CELLXFS>
</xsl:template>

</xsl:transform>

* ehfnd_exp_xlsx_get_sheet_names -> Extracts the sheet names from an XLSX workbook

<xsl:transform version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:sap="http://www.sap.com/sapxsl"
xmlns:mn="http://schemas.openxmlformats.org/spreadsheetml/2006/main"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
>

<xsl:strip-space elements="*"/>

<xsl:template match="/">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<WORKBOOK_DATA>
<xsl:apply-templates select="mn:workbook/mn:bookViews/mn:workbookView"/>
<SHEET_IDS_HTAB>
<xsl:apply-templates select="mn:workbook/mn:sheets/mn:sheet"/>
</SHEET_IDS_HTAB>
</WORKBOOK_DATA>
</asx:values>
</asx:abap>
</xsl:template>

<xsl:template match="mn:workbook/mn:bookViews/mn:workbookView">
<ACTIVE_SHEET><xsl:value-of select="@activeTab"/></ACTIVE_SHEET>
</xsl:template>

<xsl:template match="mn:workbook/mn:sheets/mn:sheet">
<EHFNDS_EXP_SHEET>
<NAME><xsl:value-of select="@name"/></NAME>
<SHEET_ID><xsl:value-of select="@sheetId"/></SHEET_ID>
<RID><xsl:value-of select="@r:id"/></RID>
</EHFNDS_EXP_SHEET>
</xsl:template>

</xsl:transform>

* ehfnd_exp_xlsx_insert_sheet -> Inserts a new sheet into a workbook part

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:mn="http://schemas.openxmlformats.org/spreadsheetml/2006/main"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
>

<xsl:param name="ACTIVE_SHEET" />


<xsl:param name="SHEET_NAME" />
<xsl:param name="SHEET_ID" />
<xsl:param name="SHEET_RID" />

<xsl:strip-space elements="*"/>

<xsl:template match="mn:workbookView">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:attribute name="activeTab"><xsl:value-of
select="$ACTIVE_SHEET"/></xsl:attribute>
</xsl:copy>
</xsl:template>

<xsl:template match="mn:sheets">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:element name="mn:sheet" >
<xsl:attribute name="name"><xsl:value-of
select="$SHEET_NAME"/></xsl:attribute>
<xsl:attribute name="sheetId"><xsl:value-of
select="$SHEET_ID"/></xsl:attribute>
<xsl:attribute name="r:id"><xsl:value-of
select="$SHEET_RID"/></xsl:attribute>
</xsl:element>
<xsl:apply-templates />
</xsl:copy>
</xsl:template>

<xsl:template match="*">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates />
</xsl:copy>
</xsl:template>

</xsl:stylesheet>

* ehfnd_exp_xlsx_read_sheet -> Get cellxfs of style sheet

<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:sap="http://www.sap.com/sapxsl"
xmlns:mn="http://schemas.openxmlformats.org/spreadsheetml/2006/main"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
version="1.0">

<xsl:strip-space elements="*"/>

<xsl:template match="/">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<COLS>
<xsl:apply-templates select="mn:worksheet/mn:cols/mn:col"/>
</COLS>
<ROWS>
<xsl:apply-templates select="mn:worksheet/mn:sheetData/mn:row"/>
</ROWS>
</asx:values>
</asx:abap>
</xsl:template>

<xsl:template match="mn:worksheet/mn:cols/mn:col">
<COL>
<CUSTOMWIDTH>
<xsl:value-of select="@customWidth"/>
</CUSTOMWIDTH>
<STYLE>
<xsl:value-of select="@style"/>
</STYLE>
<WIDTH>
<xsl:value-of select="@width"/>
</WIDTH>
<MAX>
<xsl:value-of select="@max"/>
</MAX>
<MIN>
<xsl:value-of select="@min"/>
</MIN>
<HIDDEN>
<xsl:value-of select="@hidden"/>
</HIDDEN>
<BESTFIT>
<xsl:value-of select="@bestFit"/>
</BESTFIT>
</COL>
</xsl:template>

<xsl:template match="mn:worksheet/mn:sheetData/mn:row">
<ROW>
<POSITION>
<xsl:value-of select="@r"/>
</POSITION>
<CELLS_TAB>
<xsl:apply-templates select="mn:c"/>
</CELLS_TAB>
</ROW>
</xsl:template>

<xsl:template match="mn:c">
<CELL>
<POSITION>
<xsl:value-of select="@r"/>
</POSITION>
<SHAREDSTRING>
<xsl:value-of select="@t"/>
</SHAREDSTRING>
<STYLE>
<xsl:value-of select="@s"/>
</STYLE>
<VALUE>
<xsl:apply-templates select="mn:v"/>
</VALUE>
</CELL>
</xsl:template>

<xsl:template match="mn:v">
<xsl:value-of select="."/>
</xsl:template>

</xsl:transform>

* ehfnd_exp_xlsx_set_cellxfs -> Transfrom cellxfs to XML (xstring)

<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">

<tt:root name="param"/>

<tt:template>

<cellXfs>
<tt:loop name="xf" ref="param.t_cellxfs">
<xf>
<tt:attribute name="numFmtId" value-ref="$xf.numfmtid"/>
<tt:attribute name="fontId" value-ref="$xf.fontid"/>
<tt:attribute name="fillId" value-ref="$xf.fillid"/>
<tt:attribute name="borderId" value-ref="$xf.borderid"/>
<tt:attribute name="xfId" value-ref="$xf.xfid"/>
<tt:s-cond check="$xf.fontId != 0">
<tt:attribute name="applyFont">1</tt:attribute>
</tt:s-cond>
<tt:s-cond check="$xf.fillId != 0">
<tt:attribute name="applyFill">1</tt:attribute>
</tt:s-cond>
<tt:s-cond check="$xf.borderId != 0">
<tt:attribute name="applyBorder">1</tt:attribute>
</tt:s-cond>
<tt:s-cond check="$xf.numFmtId != 0">
<tt:attribute name="applyNumberFormat">1</tt:attribute>
</tt:s-cond>
</xf>
</tt:loop>
</cellXfs>

</tt:template>

</tt:transform>

* ehfnd_exp_xlsx_create_strings -> Creates a new shared strings part

<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates"
xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"

xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">

<tt:root name="param"/>

<tt:template>
<sst xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
<tt:attribute name="count" value-ref="param.string_count"/>
<tt:attribute name="uniqueCount" value-ref="param.string_ucount"/>
<tt:loop ref="param.string_tab" name="ss">
<si>
<tt:s-cond check="initial($ss.r)">
<t>
<tt:value ref="$ss.string"/>
</t>
</tt:s-cond>
<tt:s-cond check="not-initial($ss.r)">
<tt:loop ref="$ss.r" name="r">
<r>
<t>
<tt:value ref="$r.string"/>
</t>
</r>
</tt:loop>
</tt:s-cond>
</si>
</tt:loop>
</sst>
</tt:template>

</tt:transform>

* ehfnd_exp_xlsx_get_strings -> Extracts the strings from a shared strings part

<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:sap="http://www.sap.com/sapxsl"
xmlns:mn="http://schemas.openxmlformats.org/spreadsheetml/2006/main"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
version="1.0">

<xsl:strip-space elements="*"/>

<xsl:template match="/">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<STRINGS>
<xsl:apply-templates select="mn:sst/mn:si"/>
</STRINGS>
</asx:values>
</asx:abap>
</xsl:template>

<xsl:template match="mn:sst/mn:si">
<STRUCT>
<xsl:apply-templates select="mn:t"/>
<R>
<xsl:apply-templates select="mn:r/mn:t"/>
</R>
</STRUCT>
</xsl:template>

<xsl:template match="mn:t">
<STRING>
<xsl:value-of select="."/>
</STRING>
</xsl:template>

<xsl:template match="mn:r/mn:t">
<STRUCT>
<STRING>
<xsl:value-of select="."/>
</STRING>
</STRUCT>
</xsl:template>

</xsl:transform>

You might also like