I'm trying to replace the SharePoint 2013 attachment paperclip icons with the actual NAME of the attached document.

When I export a SharePoint (2013) list to an Excel spreadsheet, instead of listing the name of the document (which is a hyperlink to the document), it will only show "Attachments" in the column instead of the document name.

I just want a spreadsheet that has a column with the name of the attachment.

Any suggestions?

Attached is a snap of the SP data prior to exporting:

enter image description here

2 Answers 2


Download JQuery Api and upload js file to Site Assets library.

Save the below code as JS file and upload it to Site Assets library.

(function () {

// Create object that have the context information about the field that we want to change it output render  

var attachmentsFiledContext = {};

attachmentsFiledContext.Templates = {};

attachmentsFiledContext.Templates.Fields = {
    "Attachments": { "View": AttachmentsFiledTemplate }



// This function provides the rendering logic for list view 
function AttachmentsFiledTemplate(ctx) {
var itemId = ctx.CurrentItem.ID;
var listName = ctx.ListTitle;       
return getAttachments(listName, itemId);

//get attachments field properties
function getAttachments(listName,itemId) {

var url = _spPageContextInfo.webAbsoluteUrl;
var requestUri = url + "/_api/web/lists/getbytitle('" + listName + "')/items(" + itemId + ")/AttachmentFiles";
var str = "";
// execute AJAX request
    url: requestUri,
    type: "GET",
    headers: { "ACCEPT": "application/json;odata=verbose" },
    async: false,
    success: function (data) {
        for (var i = 0; i < data.d.results.length; i++) {
            str += "<a href='" + data.d.results[i].ServerRelativeUrl + "'>" + data.d.results[i].FileName + "</a>";
            if (i != data.d.results.length - 1) {
                str += "<br/>";
    error: function (err) {
return str;

Edit the Miscellaneous section of list web part, Add the following URL into the JS Link textbox.


enter image description here

Test result:

enter image description here

I have post a detailed answer on Microsoft Q&A: Export a SharePoint List with Name of Attachments, you can take a reference to it.


You can run the below PowerShell script as an admin:

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
#Get the SPWeb
$web = Get-SPWeb -identity “http://sp/sites/echo/”
#Get the SPList
$list = $web.Lists[“TargetList”]
$ListItemCollection = @()

 $list.Items | foreach {
    $attachmentCollection = $_.Attachments
    $folder = $web.GetFolder($attachmentCollection.UrlPrefix);
    foreach ($file in $folder.Files)
        #Write-Host $file.Name
        $AttachmentName = $file.Name
        Write-Host $AttachmentName     

 $ExportItem = New-Object PSObject
 $ExportItem | Add-Member -MemberType NoteProperty -name “Title” -value $_[“Title”]
 $ExportItem | Add-Member -MemberType NoteProperty -name “Choice” -value $_[“Choice”]
 $ExportItem | Add-Member -MemberType NoteProperty -name “Date” -value $_[“Date”]
 $ExportItem | Add-Member -MemberType NoteProperty -name “Account” -value $_[“Account”]
 $ExportItem | Add-Member -MemberType NoteProperty -name “Attachment” -value $_[“Attachments”]
 $ExportItem | Add-Member -MemberType NoteProperty -name “AttachmentName” -value $AttachmentName
 $ListItemCollection += $ExportItem

Write-Host “Copying data from list to Excel”
$ListItemCollection | Export-CSV “C:\temp\TestMyList.csv”                   
#Dispose the web Object

enter image description here

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.