Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
daandamhuis
Advocate I
Advocate I

Sharepoint Online: Embed Report in Classic Page

Hi All,

 

I have a question. I succesfully included the report in an Modern Page in our Sharepoint Online enviroment. But the frontpage of our sharepoint site is site the Classic Page, which we cannot upgrade to a Modern Page at this point in time. Is it still possible to show a report on the Classic Page? I want to get rid op Datazen, but the only way to do that is by embedding the Report on the frontpage of sharepoint.

 

With kind regards,

Daan Damhuis

4 REPLIES 4
v-caliao-msft
Employee
Employee

@daandamhuis,

 

With Power BI's new report web part for SharePoint Online, you can easily embed interactive Power BI reports in SharePoint Online pages. The requirements in order for Embed in SharePoint Online reports to work is that the Power BI web part for SharePoint Online requires Modern Pages. So I am afraid you requirement cannot be achieved currently. Thank you for your understanding.

 

Reference
https://docs.microsoft.com/en-us/power-bi/service-embed-report-spo

 

Regards,

Charlie Liao

 

I undertsnad that the web part doesnt work. BUT what are the other options for embedding in classic pages? Do we need Powerr BI embedded? 

 

Anonymous
Not applicable

Hi, i had the same problem. If "publish to web" is not an option or you want to secure embed on a SharePoint classic page but still have single sign-on, you could add it to a modern page and then iframe the modern page on a classic page. This is what i did below. It will require the modern spfx script editor webpart.

  • Deploy modern script editor webpart: link
  • Create a modern page and embed the report using SharePoint embed (modern Power BI webpart)
  • Add the modern script editor webpart at the top of the page, and then include the following script. This script will ensure that if you access the modern page with ?onlyshowpbi=1 in the querystring, all other page content will be hidden and the powerbi report will be shown fullscreen.

 

<script type="text/javascript">
	if(window.location.href.indexOf('onlyshowpbi=') > -1 && window.location.href.indexOf('onlyshowpbi=0') < 0) {
		console.log('Hide all content and show only the PBI embedded iframe fullscreen');
		var css = 'body > div, body > span { display: none !important; }',
			head = document.head || document.getElementsByTagName('head')[0],
			style = document.createElement('style');
		head.appendChild(style);
		style.type = 'text/css';
		style.id = 'pbi_css'
		style.appendChild(document.createTextNode(css));
		window.frameReadyToDisplay = true;
				
		var checker = function(){
			var pbiframe = document.querySelectorAll('iframe[src*=powerbi]')[0];
			if(typeof(pbiframe) !== 'undefined') {
				var pbiframe = document.querySelectorAll('iframe[src*=powerbi]')[0];
				pbiframe.style.border = '0px';
				pbiframe.style.width = '100%';
				pbiframe.style.height = '100%';
				pbiframe.style.margin = '0px';
				pbiframe.style.padding = '0px';
				document.querySelector('body').appendChild(pbiframe);
			}
			else {
				setTimeout(checker, 1);
			}
		}
		setTimeout(checker, 1);
	}
</script>

 

 

 

  • On the classic page, iframe the modern page containing the powerBI report as below with the script block:

 

<!-- Embedded PowerBI report - embedded on a modern SPO page and shown in an iframe so that it can be displayed on a classic page but still single sign-on (modern webpart capability only) -->
<div id="pbiContainer">
	<iframe id="pbi" src="https://<tenant>.sharepoint.com/teams/test/SitePages/pbitest.aspx?onlyshowpbi=1" style="display: none; width: 100%; height: 100%;"></iframe>
	<script type="text/javascript">
		// Check the frame to see if it is ready to be displayed. The frame has some script to hide everything except the PBI report webpart but the script doesn't run until
		// the script editor is rendered which may be a second after content is shown... which would produce a flicker. So the frame indicates when it is ready to be shown after CSS has been
		// applied
		var pbiframechecker = function () {
			if (document.getElementById("pbi").contentWindow.frameReadyToDisplay) {
				document.getElementById("pbi").style.display = '';
			}
			else {
				setTimeout(pbiframechecker, 25);
			}
		};
		setTimeout(pbiframechecker, 25);
	</script>
</div>

 

 

The reason the SharePoint embed link only works in a modern powerbi webpart is because there is a window.PostMessage conversation between the modern sharepoint page and the powerbi page. The modern SPO page sends an access token matching what the powerBI site is expecting, though i'm not sure how the modern powerBI webpart comes up with the token. The ideal and faster solution would be to implement this flow on a classic site. If anyone has spent the time please share.

Hi,

You cannot embed Power Bi report onto a classic SharePoint Online page, that is as simple as that.

 

But what you could do is enable Site Pages feature for the site and then add a site page (which is modern page) and add Power Bi Report web part and add the embed URL.

 

Regards,

Hari Govind

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors