Hide / Disable Export to Spreadsheet

I got a question from a colleague where the customer has added an out of the box survey in SharePoint and granted the required users permissions to respond. The scenario has been recreated on my environment and the issue is that visitors/members can read other responses even when specified that they are not allowed to view them using the Export to Spreadsheet action. This occurs in all SharePoint environments and I’ve created the scenario in SharePoint Online (Office 365). I would like to suggest using the Office 365 Forms app to build a survey when using Office 365!

I responded to a survey with my “External” account with edit permissions:

image

I changed the edit permissions to read and navigated to the “Overview” page.

image

I still have actions available and also Export to Spreadsheet

image

I was able to see all answers from all users.

Solution

There is no option to really disable this functionality but we are able to hide the Actions tab.

You can hide the Actions tab using CSS or JQuery. I suggest to do the below actions on all .aspx pages used by the form although Overview.aspx is the one hosting the “Export to Spreadsheet” :

  • Overview.aspx
  • AllItems.aspx
  • Summary.aspx

CSS

SNAGHTMLde51c4c

Edit page

image

Add a Script Editor web part

image

Edit snippit and add the below CSS code. This will select all ID’s that contains _ListActionsMenu_t and hides it.

<style>
*[id*=’_ListActionsMenu_t’]{ display:none; }
</style>

image

Insert and stop editing the page

image

The Actions menu is now hidden.

JQuery

I suggest using CSS and JQuery combined in case the browser does not support the wildcard selection from CSS.
Add the below code in the same script editor webpart where you can add this also as a .js file to the site assets and reference those .js files.

<script src=”//code.jquery.com/jquery-3.1.1.min.js”></script>
<script>
$(document).ready(function(){
$(“table.ms-menutoolbar tr td.ms-toolbar”).has(“span[id*=’ListActionsMenu_t’]”).hide();
$(“table.ms-menutoolbar tr td.ms-separator:first”).hide();
});
</script>

image

Insert and stop editing the page

image

List SharePoint Services on Server using PowerShell

Manage Services on Server shows which SharePoint service is running on a particular server. You can only select 1 server and you won’t get a quick overview of all the services per server. I have created the below script to create a .html file which shows each server and their active or inactive service.

The following script can be copied into notepad and saved as a .ps1 file. Just execute the script to create a .HTML file. When you run the script, it will ask for an export location. This folder does not have to exist on your harddrive. This has been created and tested for SharePoint 2013 and haven’t tested this yet for SharePoint 2010.

#Import SharePoint PowerShell Modules
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Request the location to store the HTML file
$ExportLocation = Read-Host "Enter the location to store the HTML file. (eg. C:\temp). This directory will be created if it doesn't exist"

Function ListServicesOnServer($path)
{
#Check if directory exists or create the directory
if((Test-Path $path) -eq $false)
{
mkdir $path
write-host "Folder created" -foregroundcolor yellow
}
else
{
write-host "Folder already exists" -foregroundcolor yellow
}

#create an unique name
$date = get-date
$today = $date.ToString("ddMMyyyy_HHmm")
$HTMLpath = "$($path)\ServicesOnServer_$($today).html"

#Create HTML File for the information
New-Item -ItemType file $HTMLpath -force | out-null
add-content -value "<html><body><h1>Services on Server</h1><br />" -path $HTMLpath

#Try / Catch statement to get the information
try
{
#Get the SharePoint servers in the farm
$servers = Get-SPServer | where {$_.Role -ne "Invalid"}

#Create an HTML Table and headers
add-content -value "<table border='1' style='font-family: Calibri, sans-serif'>
<tr>
<th style='background-color:blue; color:white'>Service</th>" -path $HTMLpath
$servers | %{Add-Content $HTMLpath "<th style='background-color:blue; color:white'>$($_.Address)</th>"}
add-content -value "</tr><tr>" -path $HTMLpath

#list all services using 1 server
$services = get-spserviceinstance -server $servers[0]

foreach($service in $services)
{
$serviceTypeName = $service.TypeName | sort-object
Add-Content $HTMLpath "<td>$($service.TypeName)</td>"
$servicesOnServers = get-spserviceinstance | where-object {$_.TypeName -eq $serviceTypeName} | %{Add-Content $HTMLpath "<td>$($_.status)</td>"}
Add-Content $HTMLpath "<tr></tr>"
}

add-content -value "</table></body></html>" -path $HTMLpath
write-host "Script Done" -foregroundcolor green
}
catch
{
write-host "$($_.Exception.Message)" -foregroundcolor red
}
}

ListServicesOnServer($ExportLocation)

Manual

You should already have created a .ps1 file and saved this to a predefined location:

ListServicesOnServer1

Run PowerShell as administrator and run the following command:

& “C:\Temp\ListServicesOnServer.ps1”

ListServicesOnServer2

Press enter and fill in a location:

ListServicesOnServer3

Press enter:

ListServicesOnServer4

The output should look like below:

ListServicesOnServer5