You are on page 1of 9

Adding Maps to a Report

There is a known problem that can result in maps inserted into reports not appearing in the report viewer and appearing in the Excel workbook as icons with the name and path of the linked file underneath. This is a result of an interaction with a setting in Microsoft Office Picture Manager. For instructions for changing this setting so that the maps appear correctly, see Changing the Microsoft Office Picture Manager Settings.

Adding a Maps element to the app pack XML


Let's start by amending the example app pack XML created like this (the changes are outlined in red):

Apart from changing the name of the app pack itself and the report, we have added the following: A ShowAllTabs field (which is set to True) to the Report element. This indicates that when users run the report we want them to see a tab for all of the worksheets in the workbook that are not hidden. A Maps element with its ImageDirectory field set to Analyzer://Reports/images. The maps are inserted into the report as bitmaps and this is where they will be stored.

A single Map element, which has two child Layer elements. Each of these specifies a single attribute to be displayed on the map and for the ServRxQualSub attribute we have set the ZoomTo field to True, indicating that we want the map to zoom to this layer. This effectively results in a "best fit" operation on the drive test route within the map window.

Save the app pack XML file as MyKPIReport Map App Pack.xml in the Reports folder within the user data area. For example: C:\Documents and Settings\All Users\Application Data\Actix\Analyzer\Reports Copy the Excel workbook, rename it to MyKPIMapReport.xls and place it in the same folder we used in that topic: C:\Documents and Settings\All Users\Application Data\Actix\Analyzer\Reports\MyKPIReport

Running the report to generate the bitmaps


Before we can insert the map into the workbook we need to run the report to generate the bitmap images, but first we need to restart Analyzer, because we have added a new XML file. Restart Analyzer and load a suitable log file. Now choose Display new Map from the View menu. The size of the map bitmap that will be exported when we run the report will reflect the size of the map window. So if necessary, resize the window to the size that you want the map to be in the report. (Note that if you display an attribute on the map, it will also be included in the image that will be created.) Now select the app pack from the Analysis menu and run the report. Notice that the report now has multiple tabs. This is because we set the ShowAllTabs field to True on the Report element in the app pack XML.

However, because we now have a Maps node in our app pack XML file, running the report should have generated the bitmaps for our map. Using Windows Explorer, browse to the folder specified in the ImageDirectory field on the Maps element. This should reveal two bitmap files, one representing the map and the other the legend.

Inserting the bitmaps into the Excel workbook


We now need to insert into our workbook the bitmaps that we generated in the previous step. Open the report workbook (MyKPIMapReport.xls) by choosing the Open Workbook / Report command on the Workbooks menu. Switch to a blank worksheet (for example, Sheet2). Select a cell near the top left corner (for example, cell B4). From the Insert menu, choose Object to open the Object dialog box. Select the Create from File tab.

Use the Browse button to browse to the following folder:

C:\Documents and Settings\All Users\Application Data\Actix\Analyzer\Reports\Images Select the RxQual_Drops_map.bmp file and then click Insert.

Back on the Create from File tab, select Link to file and deselect Display as icon. Click OK.

If the map appears as an icon with the name and path of the linked file underneath, see Changing the Microsoft Office Picture Manager Settings. If necessary, resize the image to suit your requirements. Select the image, right-click and choose Format Object from the shortcut menu. This opens the Format Object dialog. This has a number of options, which you can use to add borders and specify various other types of formatting. Most of these are fairly straight forward and in this example, we will simply set the size options, because it is important to understand how these work and interact with the app pack mechanism. But first you need to understand the following: New map and legend bitmaps are generated for each Map node in the XML every time the report is run (provided it is run through the app pack mechanism). The new bitmaps overwrite those that were written the last time the report was run. The size of the map bitmaps will reflect the size of the map window at the time that the report is run. If the map window is closed when the user runs the report, it will be reopened using the stored size settings.

This means that if you are creating a report for use by multiple users, you need to be aware that the size of the bitmap images are likely to vary according to each user's individual setup and screen resolution.

Select the Size tab.

Select or deselect the Relative to original picture size option according to your requirements. Select the option if you want the map to be stretched and shrunk to fit the size of the current image. You should normally do this if you are placing several maps on the same worksheet. Deselect the option if you want the size of the map to vary according to the size of the image that is generated each time the report is run. This means that the map will vary in size. This option will generally provide a better quality and is useful when you have a single map on a page.

It is generally advisable to select the Lock aspect ratio option, because this reduces the amount of distortion when the image is resized. When you have finished setting the formatting options, click OK. Use similar steps to insert and format the map legend bitmap. Hide the gridlines and add a heading.

And that's it! You can use the same technique to add additional maps, either to the same worksheet or other ones.

Hiding the system worksheets


Because we are using the Show All Tabs option, we will now tidy up the tabs so that users won't see the "system" and blank worksheets. First let's rename Sheet2 to Map. Do this by right-clicking the tab text and choosing Rename from the shortcut menu. Now let's delete the unused Sheet3. Do this by clicking it and then choosing Edit | Delete Sheet from the menu. Now let's hide the CrossTab Formatted Data worksheet. Do this by clicking it and then choose Format | Sheet | Hide.

Testing the changes


To test our changes, restart Analyzer and then load a suitable log file. Now select the app pack from the Analysis menu and run the report..

Notes: If the map window is open when the report is run, the app pack mechanism will add the layers defined in the XML to the layers that are already displayed in the map window and export them all to the bitmap image. This can result in overlapping data and can make the information hard to read. If necessary, users should be instructed to remove unwanted layers from the map or to close the map window before running the report. Users can click Show Excel Report to view the Excel workbook and save it. If they then run the report again on different data, the map bitmaps will be updated to reflect the new data. If they subsequently reopen the workbook that was saved earlier, Excel will display the following message. It is important that the user chooses the Don't Update option, because otherwise the maps will be updated with the data from the latest running of the report.

If you want to display an array attribute on the map, you need to add an Index field to the Layer node in the XML, like this:

<Map Name="EcNo"> <Layer Attribute="Uu_ActiveSet_EcNo" Index="0" ZoomTo="true"/> </Map>

You might also like