Purpose Generate an Excel file |
Solution We use an Excel template file that is stored on the server. We transport the current data for the Excel file in invisible S10 fields. The actual generation is then carried out from the template file and the current data with JavaScript. Either we use specialized libraries like "ExelJS" or "SheetJS", or for simple cases we directly replace the placeholders of the Excel template file with the current values. Here we describe a case of direct replacement of the placeholder variables. For example, the template file "exceltemplate.xlsx" in the SAP MIME repository looks like this: ![]() The placeholders "&[qmnum]", "&[aufnr]",... are arbitrary. In the HTML page, the values are included in an invisible area. They are automatically provided by the S10 framework: HTML We implement a JavaScript function that replaces the placeholders in a string with the actual values, for example: JavaScript
Here we have replaced the "&" character with the XML value "&" because we will be changing the placeholders in the XML format.
The JavaScript routine is not very long but a bit demanding, because some of the called functions work asynchronously: JavaScriptThe user then receives the following Excel file, for example:
|
Components |