Professional Documents
Culture Documents
Applies to:
Dashboard Design (Xcelsius Enterprise 5.3.2.0) (may also work with other versions). For more information, visit the Dashboard Design homepage.
Summary
This paper lists the steps for generating an XML file from an Excel worksheet and connecting it to an Xcelsius dashboard. This gives users suppleness to quickly work with source data and modify it per their business requirements without interacting with the dashboard file. Code for converting Excel data to XML data compatible with Xcelsius is also provided. Author: Ashish Tewari
Author Bio
Ashish Tewari is currently working with Deloitte. He is a Business Intelligence Solution Consultant with 6 years of experience in SAP BW space.
Table of Contents
Introduction ......................................................................................................................................................... 3 Requirement ....................................................................................................................................................... 3 How XML Connection Works .............................................................................................................................. 3 Generating XML File ........................................................................................................................................... 4 Step-by-step Process ......................................................................................................................................... 6 Step 1: Create the Excel File .......................................................................................................................... 6 Step 2: Generate the XML File ....................................................................................................................... 6 Step 3: Validate the XML File ......................................................................................................................... 9 Step 4: Create the XML Connection in Xcelsius ........................................................................................... 10 Step 5: Map XML data to Components ......................................................................................................... 16 Step 6: Preview the Dashboard .................................................................................................................... 16 Consideration .................................................................................................................................................... 17 Appendix VB Code for Macro ........................................................................................................................ 17 Related Content ................................................................................................................................................ 20 Disclaimer and Liability Notice .......................................................................................................................... 21
Introduction
This paper lists the steps for generating an XML file from an Excel worksheet and connecting it to an Xcelsius dashboard. This gives users suppleness to quickly work with source data and modify it per their business requirements without interacting with the dashboard file. Code for converting Excel data to XML data compatible with Xcelsius is also provided.
Requirement
Dashboard is an intuitive tool for visualizing data in the form for eye catching flashy components. This is also complemented with the possibility of connecting it with live data. This may require dashboard to connect with any combination of diverse source system like SAP, RDBMS, Portal, Excel or XML. In this paper Ill discuss about the connectivity with XML data. XML data can come from online forms or other databases. Here I will talk about converting an MS Excel file into XML file for data capture. Many times users want to have control to update dashboard data. In this case we can give them an MS Excel file and they can change data in it as per their business requirement and generate XML file, which will be connected to Xcelsius dashboard. This will reduce cycle time to update dashboard data. Consider this requirement: users want to publish a dashboard page with manual feed of KPIs and a section of their BusinessObjects report hyperlink. To give them flexibility of changing underlying source file without changing dashboard XLF we can implement this solution. It will give users an Excel file, they can change or update data in that file on a specific section and generate XML file from there. This XML file will be linked in Xcelsius dashboard as source. This way XLF will be untouched and source data is also updated as per users direction.
When you hit Preview XML button, it opens a temporary file in Internet Explorer that shows the structure of required XML file. Notice file name and declarations. There has to be a VB program to generate this format from Excel file. See attached code in Appendix. All you need to do is to copy this code in Excel VB macro program and tweak it for XML file destination.
Step-by-step Process
Step 1: Create the Excel File Create a layout for source Excel file and embed a button for Make XML. There will be Visual Basic (VB) code behind this button to read data from layout and put it in XML format compatible for Xcelsius. Go to the developer toolbar in Excel and insert a button from 'Form Controls'. Insert (copy and paste) the code in module for that Excel file by going to Visual Basic button on developer toolbar. Test and save Excel file as .XLTM format to save it with macro.
Step 2: Generate the XML File When the user clicks the Make XML button, a popup message appears with procedure details. Once the user clicks Yes, it will ask about file name, group name, header row and data cell range. File name should be same as Range name in Xcelsius connection details for XML. Group name will be Row. Titles destination of the table should be assigned in Header row. Finally data set, which will be covered in XML should be specified in Data cell range prompt.
Note: Remember to change the destination for this XML file. Attached code saves it to the user desktop. Change this line accordingly "C:\Users\<userid>\Desktop\"..
Step 3: Validate the XML File Once the XML file is saved, open it from its destination where it was saved (in this case from desktop) by VB program. When you open the XML file, it will open in browser and will look like attached screenshot. Check if this is the format expected and all declarations are opened and closed in proper order for Data, Variable, Row and Column.
When you collapse all rows, you can see that the structure of this XML file is same as what Xcelsius understands. Now this file is ready for connection with Xcelsius.
Step 4: Create the XML Connection in Xcelsius Connect this XML file to Xcelsius using Data Manager.
Go to XML Data and specify the connection name (for example, XML Connection as below).
Select text/xml for MIME type if the file is residing on the machine. In case of an online version of this file, choose the other MIME type.
Notice that there are of checkboxes for Enable Send and Enable Load. Enable Send pushes data from Xcelsius to then external location Enable Load reads the data from the file or website.
Click the + icon and rename range with same name as XML files name.
Specify the range on the underlying Excel where this XML data will be populated during dashboard execution.
On the Usage tab, check the option of Refresh Before Components Are Loaded . This way, data will be populated in Xcelsius components on dashboard launch. A formula can also be placed here for a trigger.
Step 5: Map XML data to Components Once XML data range is mapped in Xcelsius, perform the regular dashboard work. Map components with this XML data. Then define drilldowns and visibility of items. Step 6: Preview the Dashboard Based on above steps, dashboard components will be linked with XML data. Click Preview and validate the functioning.
Consideration
This concept of generating XML file from Excel and connecting it with Xcelsius can be used at many places. It is left to the imagination of developer who builds dashboards and creativity of users who pass on such requirements to us.
If YesNo = vbNo Then Debug.Print "User aborted with 'No'" Exit Sub End If XMLFileName = FillSpaces(InputBox("1. Enter the name of the XML file:", "MakeXML CiM", "xl_xml_data")) If Right(XMLFileName, 4) <> ".xml" Then XMLFileName = XMLFileName & ".xml" End If XMLRecSetName = FillSpaces(InputBox("2. Enter an identifying name of a record:", "MakeXML CiM", "row")) RangeOne = InputBox("3. Enter the range of cells containing the field names (or column titles):", "MakeXML CiM", "A3:E3") If MyRng(RangeOne, 1) <> MyRng(RangeOne, 2) Then MsgBox "Error: names must be on a single row" & MyLF & "Procedure STOPPED", vbOKOnly + vbCritical, "MakeXML CiM" Exit Sub End If MyRow = MyRng(RangeOne, 1) For MyCol = MyRng(RangeOne, 3) To MyRng(RangeOne, 4) If Len(Cells(MyRow, MyCol).Value) = 0 Then MsgBox "Error: names range contains blank cell" & MyLF & "Procedure STOPPED", vbOKOnly + vbCritical, "MakeXML CiM" Exit Sub
End If FldName(MyCol - MyRng(RangeOne, 3)) = FillSpaces(Cells(MyRow, MyCol).Value) Next MyCol RangeTwo = InputBox("4. Enter the range of cells containing the data table:", "MakeXML CiM", "A4:E8") If MyRng(RangeOne, 4) - MyRng(RangeOne, 3) <> MyRng(RangeTwo, 4) - MyRng(RangeTwo, 3) Then MsgBox "Error: number of field names <> data columns" & MyLF & "Procedure STOPPED", vbOKOnly + vbCritical, "MakeXML CiM" Exit Sub End If RTC1 = MyRng(RangeTwo, 3) If InStr(1, XMLFileName, ":\") = 0 Then XMLFileName = DefFolder & XMLFileName End If Open XMLFileName For Output As #1 'Print #1, "<?xml version=" & Chr(34) & "1.0" & Chr(34) & " encoding=" & Chr(34) & "ISO8859-1" & Chr(34) & "?>" Print #1, "<data>" Print #1, "<variable name=" & """xl_xml_data"">" For MyRow = MyRng(RangeTwo, 1) To MyRng(RangeTwo, 2) Print #1, "<" & XMLRecSetName & ">" For MyCol = RTC1 To MyRng(RangeTwo, 4) ' the next line uses the FormChk function to format dates and numbers Print #1, "<" & FldName(MyCol - RTC1) & ">" & RemoveAmpersands(FormChk(MyRow, MyCol)) & "</" & FldName(MyCol - RTC1) & ">" ' the next line does not apply any formatting ' Print #1, "<" & FldName(MyCol - RTC1) & ">" & RemoveAmpersands(Cells(MyRow, MyCol).Value) & "</" & FldName(MyCol - RTC1) & ">" Next MyCol Print #1, "</" & XMLRecSetName & ">" Next MyRow Print #1, "</variable>" Print #1, "</data>" Close #1 MsgBox XMLFileName & " created." & MyLF & "Process finished", vbOKOnly + vbInformation, "MakeXML CiM" Debug.Print XMLFileName & " saved" End Sub Function MyRng(MyRangeAsText As String, MyItem As Integer) As Integer ' analyse a range, where MyItem represents 1=TR, 2=BR, 3=LHC, 4=RHC Dim UserRange As Range Set UserRange = Range(MyRangeAsText) Select Case MyItem Case 1 MyRng = UserRange.Row Case 2 MyRng = UserRange.Row + UserRange.Rows.Count - 1 Case 3 MyRng = UserRange.Column
Case 4 MyRng = UserRange.Columns(UserRange.Columns.Count).Column End Select Exit Function End Function Function FillSpaces(AnyStr As String) As String ' remove any spaces and replace with underscore character Dim MyPos As Integer MyPos = InStr(1, AnyStr, " ") Do While MyPos > 0 Mid(AnyStr, MyPos, 1) = "_" MyPos = InStr(1, AnyStr, " ") Loop FillSpaces = LCase(AnyStr) End Function Function FormChk(RowNum As Integer, ColNum As Integer) As String ' formats numeric and date cell values to comma 000's and DD MMM YY FormChk = Cells(RowNum, ColNum).Value If IsNumeric(Cells(RowNum, ColNum).Value) Then FormChk = Format(Cells(RowNum, ColNum).Value, "#,##0 ;(#,##0)") End If If IsDate(Cells(RowNum, ColNum).Value) Then FormChk = Format(Cells(RowNum, ColNum).Value, "dd mmm yy") End If End Function Function RemoveAmpersands(AnyStr As String) As String Dim MyPos As Integer ' replace Ampersands (&) with plus symbols (+) MyPos = InStr(1, AnyStr, "&") Do While MyPos > 0 Mid(AnyStr, MyPos, 1) = "+" MyPos = InStr(1, AnyStr, "&") Loop RemoveAmpersands = AnyStr End Function
Related Content
Dashboard Design Connecting Xcelsius Dashboards to External Data Sources using XML Data Button Configure Xcelsius output XML schema for Xport Wizard For more information, visit the Dashboard Design homepage.