EducationSoftwareStrategy.com
StrategyCommunity

Knowledge Base

Product

Community

Knowledge Base

TopicsBrowse ArticlesDeveloper Zone

Product

Download SoftwareProduct DocumentationSecurity Hub

Education

Tutorial VideosSolution GalleryEducation courses

Community

GuidelinesGrandmastersEvents
x_social-icon_white.svglinkedin_social-icon_white.svg
Strategy logoCommunity

© Strategy Inc. All Rights Reserved.

LegalTerms of UsePrivacy Policy
  1. Home
  2. Topics

KB440511: How to use a HTML image as a button that exports a grid on a document to Excel in MicroStrategy version 10.4 and later


Sana Hidayat

Director, Cloud Support Operations • MicroStrategy


How to use a HTML image as a button that exports a grid on a document to Excel in MicroStrategy version 10.4

In Strategy Web, it is possible to use an image as a button to export a grid on a document to Excel in Strategy version 10.4 and later. This document provides the steps to accomplish the same. 
The goal is to create an image link that is used to export the grid, like shown below:

ka04W000001IrYzQAK_0EM44000000A6zi.png

Document in Edit Mode

ka04W000001IrYzQAK_0EM44000000A6zn.png

1. Create a Report Services Document in Strategy Tutorial
2. Make two grids with different attributes and metrics in each 
3. Insert an HTML container and insert the script below. Make sure the Project name matches the given project and gridKey matches (highlighted in bold in the script below). The code below is used for the first grid and button. Main things to watch are the gridKey values and the name of the element id which in the below code is exportLink.
 


<a target="_blank" id="exportLink" href=""><img height="50" width="50" src="https://static.wikia.nocookie.net/logopedia/images/7/7f/Microsoft_Office_Excel_%282018%E2%80%93present%29.svg/revision/latest?cb=20190927105356" /></a>
 
<script>
        try {
            var baseUrl = "./Main.aspx?&evt=3132&src=mstrWeb.3132&executionMode=4&gridKey=K44&Main.aspx=-.Strategy+Tutorial.34955_&rwExportMode=4&rwb=";
            var beanState = mstrmojo.App.docModel.bs;
            baseUrl = baseUrl + beanState;
            document.getElementById("exportLink").href = baseUrl;
        } catch (err) {
            document.getElementById("exportLink").href = "";
        }
</script>

4. Insert another HTML container and paste the script below. Make sure the Project name matches the given project and gridKey matches. The code below is used for the second grid and second button. The gridKey value is different here and the name of the element id which is exportLink2.
 

<a target="_blank" id="exportLink2" href=""><img height="50" width="50" src="https://static.wikia.nocookie.net/logopedia/images/7/7f/Microsoft_Office_Excel_%282018%E2%80%93present%29.svg/revision/latest?cb=20190927105356" /></a>

 
<script>
        try {
            var baseUrl2 = "./Main.aspx?&evt=3132&src=mstrWeb.3132&executionMode=4&gridKey=K45&Main.aspx=-.Strategy+Tutorial.34955_&rwExportMode=4&rwb=";
            var beanState2 = mstrmojo.App.docModel.bs;
            baseUrl2 = baseUrl2 + beanState2;
            document.getElementById("exportLink2").href = baseUrl2;
        } catch (err) {
            document.getElementById("exportLink2").href = "";
        }
</script>

5. Run in Presentation mode and Click the Buttons to test that the grids get exported successfully. 
Article Reference Number: KB440511
  KB440511


Comment

0 comments

Details

Knowledge Article

Published:

March 31, 2018

Last Updated:

December 24, 2018