How to export the results of Macro Usage to a .csv
Asked by Louise Simonds:

I need to generate a list of all pages on which a certain macro is used (LucidChart). I can do this in the Administration UI with Macro Usage, but I've got hundreds of pages using the macro, and the UI isn't that easy to work with for a large number of pages.

How can I export the results of this into a form that is easier to work with - ideally a .csv that I can turn into a spreadsheet that I can sort, etc.?

Thanks very much

Louise


Answers:
author: Dominic Lagger
body: Hi [@Louise Simonds](/t5/user/viewprofilepage/user-id/677100)

Do you mean this "macro usage"?

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/107545iAC6EA80C0CCA91C6/image-dimensions/788x209?v=v2 "image.png")

If yes, here you only see how many times a macro was used.

Or do you want a list of all pages which uses a special macro?   
Perhaps you can share an example of the head row in the .csv (what you would like to have)

Regards, Dominic

comments: author: Louise Simonds
body: Sorry - thought I replied, but now I don't see what I wrote.....

Thanks very much for your response.

Yes - I mean the "macro usage" in your screenshot. Specifically for LucidChart macro, but something general-purpose where I could specify the name of the macro would be ideal.

Columns I need in the .csv are:

space_name, space_key, page_id, page_title, page_url

where page_url can be used in a browser.

Extra credit for including last modified_by, last_modified_date

I need this to identify pages using the LucidChart macro, because we are migrating our Confluence content to a new instance (Cloud to Server, after an acquisition) and LucidChart does not support that migration path. The prospect of manually fixing all those links is daunting enough, and is nearly impossible unless we know which pages need fixing.

Thanks

Louise


author: Louise Simonds
body: And yes - you are correct that the page in your screenshot lists only the number of times the macro is used, but if you click on that, you get a list of the pages. Unfortunately, I cannot find a way to export those results, and the UI is not friendly - especially when I have nearly 400 pages with the LucidChart macro!

L


author: Dominic Lagger
body: Hi [@Louise Simonds](/t5/user/viewprofilepage/user-id/677100)

There are two possible solutions:

1. REST API and parse the JSON
2. Own User Macro

**REST API**

In the REST documentation you can see, that you can search with a CQL: [Content Search](https://docs.atlassian.com/ConfluenceServer/rest/7.6.0/#api/content-search)

Which means, you can search with:

```
<<URL>>/rest/api/content/search?cql=macro+%3D+%22LucidChart%22&limit=1000
```

This gives you 500 (max is 500) pages. You can create a second call with the "start" parameter:

```
<<URL>>/rest/api/content/search?cql=macro+%3D+%22LucidChart%22&limit=1000&start=500
```

This gives you the results from 500.

From there you can generate a CSV with a converter like <https://json-csv.com/>

**User Macro**

You could possibly write an user macro. But I want to see if the first option is okay for you, before we look to deep in the user macro option.

Regards, Dominic


Tags: cloud