1/ Add needed fields into export. You can add also unwanted and unsorted fields, does not affect in this case.
3/ Set up FILTERS: in this sample we will only orders with invoice (1), and sorted by invoice number (2).
3/ Set up OPTIONS: we will need raw data for XLST transform (1), and in this example we will need output CSV format file (2).
4/ Fill XLST transformation structure.
Here is basic structure (without data) for grouping Orders by Order ID:
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text" omit-xml-declaration="yes" indent="no"/><!-- IMPORTANT - WE NEED CSV OUTPUT --> <xsl:variable name="newline"><xsl:text>
</xsl:text></xsl:variable><!-- CRLF NEED IN CSV OUTPUT --> <xsl:variable name="quo"><xsl:text>"</xsl:text></xsl:variable><!-- QUOTES NEED IN CSV OUTPUT --> <xsl:key use="order_id" match="/nvn_export_orders/order" name="groups"/> <xsl:template match="/"> <xsl:apply-templates select="/nvn_export_orders" /> </xsl:template> <xsl:template match="/nvn_export_orders"> <!--COLUMNS TITLES FIRST ROW--> <xsl:for-each select="order[generate-id(.)=generate-id(key('groups',order_id))]"> <!--COMMON VALUES HERE--> <xsl:for-each select="key('groups',order_id)"> <!--ROWS ITEMS HERE--> </xsl:for-each> </xsl:for-each> </xsl:template> </xsl:stylesheet>
Now we insert data fields into this structure:
Copy and paste this xlsx stylesheet into module “XML transformation – XSLT stylesheet” and save setting.
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text" omit-xml-declaration="yes" indent="no"/><!-- IMPORTANT - WE NEED CSV OUTPUT --> <xsl:variable name="newline"><xsl:text>
</xsl:text></xsl:variable><!-- CRLF NEED IN CSV OUTPUT --> <xsl:variable name="quo"><xsl:text>"</xsl:text></xsl:variable><!-- QUOTES NEED IN CSV OUTPUT --> <xsl:key use="order_id" match="/nvn_export_orders/order" name="groups"/> <xsl:template match="/"> <xsl:apply-templates select="/nvn_export_orders" /> </xsl:template> <xsl:template match="/nvn_export_orders"> <!--COLUMNS TITLES FIRST ROW--> <xsl:value-of select="concat( $quo,'Invoice',$quo,';',$quo,'Date',$quo,';',$quo,'Paid excl VAT',$quo,';',$quo,'Paid incl VAT',$quo,';',$quo,'Customer name',$quo,';',$quo,'Product',$quo,';',$quo,'Quantity',$quo ,$newline)"/> <xsl:for-each select="order[generate-id(.)=generate-id(key('groups',order_id))]"> <!--COMMON VALUES HERE--> <xsl:value-of select="concat( invoice_number,';' ,$quo,invoice_date,$quo,';' ,$quo,total_price_tax_excl,$quo,';' ,$quo,total_price_tax_incl,$quo,';' ,$quo,invoice_firstname,' ',invoice_lastname,$quo,';' ,$quo,product_name,$quo,';' ,$quo,product_quantity,$quo,';' ,$newline)"/> <xsl:for-each select="key('groups',order_id)"> <!--ROWS ITEMS HERE--> <xsl:if test="position() != 1"> <xsl:value-of select="concat( ';;;;;' ,$quo,product_name,$quo,';' ,$quo,product_quantity,$quo,';' ,$newline)"/> </xsl:if> </xsl:for-each> </xsl:for-each> </xsl:template> </xsl:stylesheet>
TIP: For better edit is recommended use external editor with syntax highlighting and save backup of xsl stylesheet
Copy and paste xlsx stylesheet into module “XML transformation – XSLT stylesheet” and save setting.
Export and save csv file.
Sample output opened in Calk
For more samples visit this page: http://www.praotec.com/nvn-export-orders-page-of-xslt-samples/
I need to export all invoices from a certain period of time for accounting purposes – can this be done with that module ?
Hello,
yes, it is possible. But not in pdf format, only csv, excel xls/xlsx, html, XML.
If your accounting program support any special input format, send me sample.