Create Export Layouts dynamically for SAP Design Studio and Lumira Designer

biExport allows you to use so called "Export Templates" to create the perfect export from SAP Lumira Designer and Design Studio to PowerPoint, Word, PDF and Excel:

  • “Master templates” provide a generic approach to export different sets of components. They can be used for multiple applications and reduce the maintenance effort for the export. On the other hand, it may be difficult to implement detailed requirements for a specific scenario.
  • “Specific templates” allow for creating individual layouts specifically for an application or scenario. If you want to support different scenarios in one application, you can even dynamically switch between Export Templates. However, the downside of Specific Templates might be the number of Export Templates that have to be maintained and to be kept up to date.

This is where “Dynamic Template Definitions” become very handy. They allow you to dynamically create Export Templates! Dynamic Template Definitions are available for PDF, Word and PowerPoint exports.

In this article I will show you two examples of how to create an Export Template on the fly.

Dynamic Templates for PowerPoint exports – simple example

Let’s say you have created a sophisticated Export Template for an export to PowerPoint. You are using it to create a monthly management presentation, which shows data from different SAP Design Studio applications and different views. (To learn how to implement this scenario check the following blog post: www.designstudio-export.com/blog/how-to-export-a-complete-lumira-designer-design-studio-dashboard-for-multiple-filter-selections-140).

Now, business requests different details for the PowerPoint presentations. Every second month, some additional detail slides shall be generated.

Of course, you could create two Export Templates and switch between those two with the help of a short script. The downside of this approach is that you will have to maintain the component names in two presentations in the future.

With the Dynamic Template Definition on the other hand, you can simply combine multiple presentations into one Export Template. In our scenario, we would create three part-presentations:

  1. PART_1.pptx: Title page and general slides 1 to 10
  2. PART_2.pptx: Detail slides 11 to 15
  3. PART_3.pptx: General Slides 16 to 25

These part-presentations can then be combined flexibly:

  1. General presenation: PART_1.pptx + PART_2.pptx
  2. Detailed presentation: PART_1.pptx + PART_2.pptx + PART_3.pptx

Here is how easily you can code this:

// create empty arrays
var lholder1 = OPENBIEXPORT_1.createNameValuePair("", "");
var lplaceholder1 = [lholder1];
var lholder2 = OPENBIEXPORT_1.createPlaceholderRedefinition("", "");
var lplaceholder2 = [lholder2];
var lempty = OPENBIEXPORT_1.createDocumentPagebreak();
var lcontent = [lempty];

// create PART_1
var lsection1 = OPENBIEXPORT_1.createDocumentSection("PART_1.pptx", false, lplaceholder1, lplaceholder2, lcontent);
var lsections = [lsection1];

// PART 2 only for every second month
if (XMONTH == 2) {
var lsection2 = OPENBIEXPORT_1.createDocumentSection("PART_2.pptx", false, lplaceholder1, lplaceholder2, lcontent);
lsections.push(lsection2);
}

// create PART_3
var lsection3 = OPENBIEXPORT_1.createDocumentSection("PART_3.pptx", false, lplaceholder1, lplaceholder2, lcontent);
lsections.push(lsection3);

// set document parameter
var ldocument = OPENBIEXPORT_1.createDocumentDefinition("", lsections);
OPENBIEXPORT_1.setPptTemplateDefinition(ldocument);

Dynamic Templates for PowerPoint exports – advanced example

Our first example still was rather static: The part-presentations already included the correct placeholders for the Design Studio components to be exported.

Now let’s say you want content of the slides to change dynamically. Let’s say you want to create one slide with two charts. The user shall be able to choose which charts are displayed.

It’s clear that creating individual part presentations for each combination of two charts is not really an option. This is where the Name-Value Pairs and Placeholder Redefinitions become very handy. In the example above we left them empty:

// create empty arrays
var lholder1 = OPENBIEXPORT_1.createNameValuePair("", "");
var lplaceholder1 = [lholder1];
var lholder2 = OPENBIEXPORT_1.createPlaceholderRedefinition("", "");

In this advanced example we use a checkbox group that allows the user to select the components to be exported:

http://www.biexcellence.com:80/mimes/designstudio_export/LumiraDesigner/LumiraDesigner_32.PNG

In the Items array, we created individual entries for all components that we want the user to be able to export. As a value we enter the technical name of the component, you can choose the text freely:

http://www.biexcellence.com:80/mimes/designstudio_export/LumiraDesigner/LumiraDesigner_31.PNG

We have also create a PowerPoint Presentation with generic placeholders “HOLDER_1” to “HOLDER_4”:

http://www.biexcellence.com:80/mimes/designstudio_export/LumiraDesigner/LumiraDesigner_33.PNG

In our script, we read out the selected values and replace HOLDER_1 to HOLDER_4 with the selected components:

// collect visible components, determine section template

CHECKBOXGROUP_1.getSelectedValues().forEach(function(element, index) {
  var lplaceholder = "HOLDER_" + ( index + 1);
  var lholder = OPENBIEXPORT_1.createPlaceholderRedefinition(lplaceholder, element.component);
  lplaceholder2.push(lholder);

});
var lsection2 = OPENBIEXPORT_1.createDocumentSection("4HOLDERS.pptx", false, lplaceholder1, lplaceholder2, lcontent);
lsections.push(lsection2);

As lplaceholder1 in above code we could also pass Name-Value Pairs to Replace Placeholders with texts. This way you can replace generic placeholders with texts that you generate depending on the context of the application.

Dynamic Templates for Word / PDFexports

For exports to Word and PDF Word, we offer the same functions as for the PowerPoint export: To generate a Dynamic Template Definition for Word you can combine different part-documents and replace placeholders dynamically:

var lsection = OPENBIEXPORT_1.createDocumentSectionFromTemplate("CONTENT.docx", false, lplaceholder_values, lplaceholder_redefinitions);

For Word and PDF exports, we even offer the possibility to generate a whole document programmatically:

var lsection = OPENBIEXPORT_1.createDocumentSectionFromContent("", false, lcontent);

Content can contain simple texts, headers, page breaks, placeholders, paragraphs, tables, images, links and even TOCs! Here is a short example for this:

var lpage2 = OPENBIEXPORT_1.createDocumentText("Some text", "Title");
var lcontent = [lpage2];

lpage2 = OPENBIEXPORT_1.createDocumentHeader("Chapter 1", 1);
lcontent.push(lpage2);

lpage2 = OPENBIEXPORT_1.createDocumentText("Some more text", "");
lcontent.push(lpage2);
var lsection = OPENBIEXPORT_1.createDocumentSectionFromContent("", false, lcontent);
var lsections = [lsection];

var ldocument = OPENBIEXPORT_1.createDocumentDefinition("admin/DynamicDefinition/TITLE.docx", lsections);
OPENBIEXPORT_1.setDocTemplateDefinition(ldocument);

More information and examples can be found in section 5.10 of the biExport documentation.

Thilo Knötzele
Author: Thilo Knötzele
Creation date: 31.01.2018
Category: Briefing Books
back to overview