Forum Discussion
CardinalNight
Jun 03, 2024Brass Contributor
Using an SPFx extension to hide the Export to Excel button
As the title suggests I want to create an extension that hides it for classic mode and potentially for modern. I will then implement this extension into a PS script that applies it to a site template.
I've made a fairly deep google search and found:
How to Disable Export to Excel Button in SharePoint Online? - SharePoint Diary
The Ultimate Guide to SharePoint Site Templates and Site Scripts (laurakokkarinen.com)
sp-dev-site-scripts/samples at master · pnp/sp-dev-site-scripts · GitHub
I've tried:
@import '~@microsoft/sp-office-ui-fabric-core/dist/sass/SPFabricCore.scss';
:global {
a[id*='ExportToSpreadsheet'] {
display:none;
}
button[name="Export to Excel"] {
display: none;
}
}
but neither work.
I'm importing the the above style like this:
import { Log } from '@microsoft/sp-core-library';
import {
BaseApplicationCustomizer,
} from '@microsoft/sp-application-base';
import * as strings from 'SiteScriptExtensionApplicationCustomizerStrings';
import './SiteScriptExtension.module.scss';
import { override } from '@microsoft/decorators';
const LOG_SOURCE: string = 'SiteScriptExtensionApplicationCustomizer';
export interface ISiteScriptExtensionApplicationCustomizerProperties {
// This is an example; replace with your own property
}
export default class SiteScriptExtensionApplicationCustomizer
extends BaseApplicationCustomizer<ISiteScriptExtensionApplicationCustomizerProperties> {
@override
public onInit(): Promise<void> {
Log.info(LOG_SOURCE, `Initialized ${strings.Title}`);
return Promise.resolve();
}
}
No RepliesBe the first to reply