Convert Excel to PDF in SharePoint

In this guide you’ll get step-by-step instructions on how to convert a Microsoft Excel document into a PDF at the click of a button using the SharePoint UI (user interface). We also cover how you can convert a folder of Excel documents or an entire document library to PDF in SharePoint. This guide can be used in SharePoint Online or On-premises deployments.

Converting a Single Excel File in SharePoint

To convert a single MS Excel file to PDF, perform the following steps:

  1. Navigate to the Document Library and folder where the MS Excel file is located.

  2. Select the file that you want to convert.

  3. Open the context menu and select Convert to PDF.

convert to pdf

  1. Conversion Settings Page is displayed. You can review the settings and click Convert.

    conversion settings page

  2. Conversion results Page is displayed. You can review the results in this page to check if the conversion has been successful and without any errors.

results page

  1. Click Destination Library to navigate to the converted PDF file’s directory.

    Note: When using the Document Converter with MS SharePoint 2010 (or later), you can also convert the file by selecting it and choosing Convert to PDF in the Ribbon.

Downloading a Single PDF File

If Muhimbi.PDFConverter.ConvertAndDownload.Site Feature is enabled in a site collection, then the Download as PDF option is also added to both the SharePoint Ribbon and the file Context Menu.

Download as PDF works very similar to the Convert to PDF option, except that it opens/downloads the PDF file on a local machine rather than saving it to MS SharePoint.

Converting an Entire Folder Containing MS Excel Files

You can convert an entire folder containing MS Excel files to PDF by performing the following steps:

  1. Navigate to the Document Library that contains the folder to convert. The contents of the folder we have used in this example has been given in the below screenshot.

    document library

  2. Open the context menu and select Convert to PDF.

    convert to pdf menu

  3. Conversion Settings Page is displayed. You can review the settings and click Convert.

    conversion settings

  4. Conversion results Page is displayed. You can review the results in this page to check if the conversion of the MS Excel files have been successful and without any errors.

result page

  1. Click Destination Library to navigate to the directory containing the converted PDF file(s).

    Note: When using the Document Converter with MS SharePoint 2010 (or later), you can convert the file by selecting it and selecting Convert to PDF in the Ribbon. The Download as PDF feature does not work for folders.

Converting an Entire Document Library Containing MS Excel Files

This section is only valid for MS SharePoint 2007.

Although it is possible to convert an entire document library (MS SharePoint 2007) in one go, it may take a long time to complete, or even time out, if the library contains many MS Excel files. You will automatically receive a warning if many files are in the library.

You can convert an entire Document Library containing MS Excel files to PDF by performing the following steps:

  1. Navigate to the root folder of the document library to convert.

  2. Select Convert to PDF from the Actions menu.

    Note: This option is only available in MS SharePoint 2007.

    convert to pdf

  3. Specify if you want to convert subfolders as well.

  4. Review all the other settings and click Convert button to start the conversion process.

  5. Verify the MS Excel files have been converted without errors.

  6. Click Destination Library to navigate to the directory containing the converted PDF files.

    Note: If you are using MS SharePoint 2010 or above, select all files and use the Convert to PDF option in the Ribbon instead, as this option is only available in MS SharePoint 2007.

Saving the Converted File(s) to a Different Location

By default, PDF files are saved to the same folder in which the source files are located. However, as discussed above, it is possible to specify a different folder, document library, site, or even a different site collection to save the converted PDF files.

To specify a different folder, open the PDF Conversion screen and select the destination folder. When the site is hosted on a SharePoint server rather than the free Foundation server, a user-friendly Browse button is available, allowing folders or sites to be selected within the current site collection.

browse destination folder
Browse for a destination folder (Commercial versions of SharePoint only)

If the Browse button is not available or the destination folder is located in a different site collection, then you will need to enter the destination path manually. The format is as follows:

  1. A folder in the current site collection: Document Library Name/Folder path.
    E.g. – Shared Documents/PDF Files

  2. A folder in the different site collection: Absolute path to Site Collection/Document Library Name/Folder path.
    E.g. – /sites/Press Office/Shared Documents/PDF Files

Note: An absolute path always starts with ‘/’, without ‘http://’ and the domain name.

If the files are always written to the same directory, then you can select Remember this path to automatically default to the custom path last used.

Note: These settings are remembered per user and stored at the Site collection level.

Unchecking Remember this path checkbox will automatically forget the settings for future conversions.

Note: Document Sets can be used as a source as well as a destination for PDF Conversion. They work exactly the same as folders.

Working with Conversion Results Screen

The Conversion Results screen contains functionality to simplify managing a large number of converted documents.

The following features are available:

  1. Filter by column: Click the column’s header to filter on and select the value to filter for. For example, select ‘Error’ in the ‘Status’ column to generate an overview of all files that caused an error during the conversion process.

  2. Sort by column: Click the header of a column to sort its contents either in ascending or descending order. For example, click the ‘Source Path’ column to group all documents by folder.

    sort by column

  3. Jump to the destination folder: Click Destination Library button to navigate to the folder to which the PDF files were written. This is particularly useful when a different destination folder has been specified during the conversion process.

  4. Page through results: A pager is automatically displayed when you convert more than 100 files.

In this guide you’ll learn how to convert Microsoft Excel files to PDF using SharePoint Designer Workflows.

Muhimbi’s Document Converter for SharePoint comes with a number of Workflow Actions, including one that you can use to convert Excel documents to PDF as part of a workflow using MS SharePoint Designer. To help you get started use the example below to create a simple workflow in MS SharePoint Designer, which converts your Excel file to PDF format as soon as it has been approved.

This guide can be used in SharePoint Online and the legacy MS SharePoint 2007 / 2010 workflow engine is fully supported, as is the optional Workflow Manager that comes with MS SharePoint 2013 and later versions. For more details, refer to this post.

Before you start, make sure the Document Converter for SharePoint has been installed, and you have access to a site collection with the appropriate rights to create workflows.

To convert documents via a workflow using MS SharePoint Designer, you will need to configure the Document Library and then also configure the workflow as per the details given below:

Create and Configure the Document Library

You can create and configure the Document Library containing MS Excel files by performing the following steps:

  1. Create a Document Library named Proposal Documents. You can use any name of your choice.

  2. Once created, navigate to the library’s Settings
    Document Library SettingsVersioning Settings screen and enable Requires content approval for submitted items.

  3. In the Document Library, create two folders (You can use any name of your choice): Confidential Proposals and
    Approved PDF Files.

Create and Configure MS SharePoint Designer Workflow

You can create and configure the MS SharePoint Designer Workflow by performing the following steps:

  1. Start MS SharePoint Designer and open the site collection that contains the Proposal Documents Document Library.

  2. Click Add Item and select List Workflow. Specify the following settings:

    • Name for the workflow: Convert Approved Excel to PDF Format.

    • Select the Document Library associated with the Workflow: Proposal Documents list.

    • When creating a SharePoint Designer Workflow in SharePoint 2013 or later, select the appropriate Platform Type.

  3. Click Create button to proceed.

  4. We are now ready to create the workflow. From the ‘Conditions’ menu, select the ‘If any value equals value’ condition.

  5. Click the first value followed by the display data binding (fx) button.

  6. Select ‘Current Item’ as the Source and select ‘Approval Status’ in the field.
    Click OK button to continue.

  7. Click the second value and select ‘Approved’ from the list.

To avoid the same workflow being executed on the converted PDF file after the conversion has taken place, we need to specifically exclude PDF files as follows:

  1. Add another ‘If any value equals value’ condition.

  2. Click the first value followed by the display data binding (fx) button.

  3. Select ‘Current Item’ as the Source and select ‘File Type’ in the Field. Click OK button to continue.

  4. Select ‘equals’ and change it to ‘not equals’.

  5. Click the second ‘value’ and enter ‘PDF’. (Do not prefix the extension with
    a period ‘.’).

With the Conditions in place, we can now add the Actions, which is where the magic happens.

  1. From the Actions menu, select Convert to PDF. It may be hidden behind the All Actions option.

  2. The following action is inserted:
    Convert ‘this document to ‘this url’ using ‘the same file name’ and ‘include / exclude meta data’. Store the converted item details in List ID: ‘Variable: List ID’, Item ID: ‘Variable: List Item ID’.
    Let’s examine what the various options within the action mean:

    • this document: Specify which MS Excel file to convert. Select the option
      and make sure Current Item is selected.

    • this url: Specify the location the converted file will be written to. The following options are available:

      1. Leave it empty: When no value is specified, then the converted PDF is written to the same folder as the source file.

      2. Site Relative URL: By specifying a URL relative to the current site, e.g. subsite/shared documents/PDF Files, any folder location in the current site collection can be targeted. This is the option we want to use so enter ‘Important Documents/Approved PDF Files’.

      3. Web Application relative URL: Using a URL that is relative to the entire web application, e.g. /sites/Press Office/Public Documents/To Distribute, any folder location in any site collection can be targeted.

    • the same file name: The name of the converted PDF file can be specified here. In our case we will leave it empty to make sure we use the same name as the original document.

    • include / exclude meta data: In case of sensitive documents, we may want to strip any custom SharePoint columns information from the file. Assuming that our document library contains a column Yearly sales forecast, we want to select ‘Exclude’.

    • Variable: List ID: A new workflow variable named List ID is automatically created. After the file has been converted, this variable will contain the ID of the list the converted file was saved to. This can later be fed into another action in order to manipulate this file further.

    • Variable: List Item ID: A new workflow variable named ‘List Item ID’ is automatically created. After the file has been converted, this variable will contain the ID of the item the converted file was saved to. This can later be fed into another action to manipulate this file further.

  3. Insert a new action named ‘Log to History List’ and enter ‘File converted’.

  4. Insert a new action named ‘Update List Item’ and select ‘this list’. We are now going to automatically mark the converted PDF file as approved.

    • From the ‘List’ dropdown select ‘Confidential Proposals’.

    • Click the ‘Add’ button and set the field to ‘Approval Status’ and the value to ‘Approved’. Click OK.
      Note: Starting with MS SharePoint 2010 it is no longer possible to set the value of the ‘Approved’ field.

    • In the ‘Find the List Item’ area set the field to ‘ID’.

    • Click fx button next to ‘Value’, and specify ‘Workflow Variables and Parameters’ as the Source and set the field to ‘Variable: List Item ID’. Click OK button.

    • Click OK again to return to the MS SharePoint Designer Workflow. It should look like the image below.

      update list item

  5. Click Publish button to deploy and activate the workflow.

Testing the Workflow

You can test the workflow created by performing the following steps:

  1. Create or upload an MS Excel file to the ‘Confidential Proposals’ folder.

  2. From the context menu, select Approve / Reject and approve the file.

This will automatically start the workflow, and after a few seconds, the Workflow status should change to Completed, as shown in the screenshot below.

approve or reject file

Once the workflow has been completed, you will find the PDF version of the document in the ‘Approved PDF Files’ folder.

approved files

If an error occurs during the execution of the workflow, you can perform the following to troubleshoot the same:

  1. Check the messages on the workflow status screen.

  2. Check for errors in the Windows Event log.

  3. Check for errors in the SharePoint trace log.

Information

We recently released the Muhimbi Document Converter Xtension for Nintex Automation Cloud. You can download it here or learn more about available Muhimbi deployments for Nintex on our product page.

In this guide you’ll learn how to convert Microsoft Excel documents to PDF using Nintex Workflows.

In the first part of the guide we use the Muhimbi Document Converter for SharePoint On-Premises to convert Excel documents to PDF using a Nintex workflow. The Muhimbi Document Converter for SharePoint On-Premises comes with comprehensive support for all Nintex Workflow versions, currently NW2007 – NW2019.

In the second part of the guide we convert Excel documents using Nintex Workflows (O365) with our REST API. This involves integrating the functionality exposed by the Muhimbi Document Converter for SharePoint Online directly into a Nintex Workflow by invoking our comprehensive REST API.

Converting Excel files using Nintex with Document Converter for SharePoint On-Premises

In this example, a Nintex workflow retrieves all the Excel documents modified during the current day and converts them to PDF. In an ideal setup, you will schedule this workflow to run out of office hours to process this as a batch for all new and modified files.

To create a new workflow, you can follow the instructions below or download the complete workflow in NWF format from the following link:

Nintex Workflow to retrieve and convert files to PDF

nintex workflow The finished workflow

Prerequisites

Before we start building the workflow, ensure all prerequisites are in place. It is also assumed that the reader has some knowledge of building Workflows using Nintex Workflow.

  1. Make sure the Document Converter for SharePoint version 4.1 (or newer) is installed.

  2. Naturally, Nintex Workflow will need to be installed as well.

  3. Make sure the Muhimbi.PDFConverter.Nintex.WebApp SharePoint Feature is activated on the relevant Web Application using SharePoint Central Administration.

  4. You will need to have the appropriate privileges to create workflows.

Creating a new workflow

To get started, create a new workflow and choose the blank template. Make sure the workflow doesn’t start automatically and add the workflow variables listed in the following screenshot.

create new workflow

Ensure that the appropriate data types are assigned. They are listed under the ‘Type’ column beside each variable name. The names are largely self-explanatory, but some additional information is provided below:

  • Source Item ID: By default, the item that triggered the workflow (in our case, the MS Excel file) is converted to PDF format. However, as we are iterating over multiple items, we need to specify the ID of the item to convert in this variable. In SharePoint 2010 and later select Integer as the Type, not List Item ID.

  • Source List ID: The Document Converter assumes the MS Excel file that is being converted is located in the same list the workflow is attached to. However, if this is not the case, then the list ID (a GUID) will need to be specified as well. In this example, everything is located in the same list, so this variable is not actually used.

  • Source Files: As we are potentially converting multiple MS Excel files we need to define a variable of type Collection to hold the list of files we will be iterating over.

  • Generated PDF Item ID: Once a file has been converted to PDF, you may want to carry out additional actions on this new file. For example, checking it in. Once converted, the ID of the PDF is automatically stored in this variable. In SharePoint 2010 and later select Integer as the Type, not List Item ID.

  • Generated PDF List ID: As the Document Converter allows files to be written to different document libraries, and even completely different Site Collections, you may want to know the ID of the destination list.

**Adding the workflow actions

You are now ready to add the actions to the workflow. You can start with adding a Query List action, which will allow you to retrieve all files modified today and store the results in the Source Files collection.

add workflow actions

You can fill out the settings for this action as per the screenshot above. You may want to add an additional filter rule to check that Content Type is not equal to Folder or Document Set.

You can continue by adding the For Each action to the workflow. Specify the collection’s name to iterate over and the variable’s name to store the Item’s ID.

specify collection name

The next set of actions you add will need to be added inside the For Each action to ensure they are executed separately for each file in the list.

You need to ensure that the workflow only invokes the Document Converter for those files that are not already in PDF format. To achieve this, add a condition and check that the file type equals ‘pdf’ as per the following screenshot.
file type equals pdf

After this, you need to add the Convert file to PDF action listed under the Muhimbi PDF section to the No branch of the workflow condition (as we want this workflow to only convert those MS Excel files that are not of type pdf). You can fill this section as per the image below:

convert file to pdf

The Document Converter integrates with all Nintex Workflow versions.

You may want to leave the Destination Path empty, which will write the PDF File to the exact location as the source file. Hover the mouse over the small information icons for more information about the Destination Path or any other fields.

The workflow is now done. You may want to add some logging information using the Log In the History List action. In our example, we use the following two logging information:

  • Last action in the No branch:
    List ID: {WorkflowVariable:Generated PDF List ID} - List Item ID: {WorkflowVariable:Generated PDF Item ID}

  • Last action in the Yes branch:
    Already in PDF Format: {WorkflowVariable:Source Item ID}

Running the workflow

You can finalize the workflow by saving and publishing it, after which the workflow is ready to be executed.
You can either run the workflow manually or schedule it to run at a specific time of your choice.

For more information and an example of how to use the output of one PDF Workflow Action as the input of the next Action can be found in our blog Combining multiple Muhimbi PDF SharePoint Workflow Activities into a sequence.

Converting MS Excel Files Using Nintex Workflows (O365) using REST API

Note: This tutorial is for the SharePoint Online version of Nintex Workflow.

You can also convert MS Excel files using Nintex Workflows using REST API. This section shows how to integrate the functionality exposed by the Muhimbi Document Converter for SharePoint Online directly into a Nintex Workflow by invoking our comprehensive REST API.

Although Muhimbi’s comprehensive Web Services (SOAP) interface works well with our on-premise products, the brand-new and much-simplified REST-based interface works very well with cloud-based products.

This new REST-based service is part of the Muhimbi Document Converter Services Online product. It comes as a separate product and does not have any dependencies on SharePoint and can be used to integrate with services such as Microsoft Flow, Azure Logic Apps, C#, Java, PHP, JavaScript, Python Ruby, and many other services including Nintex Workflow for Office 365. Although available as a stand-alone subscription, this new service is automatically included in each Document Converter for SharePoint Online subscription at no additional charge.

Prerequisites

Before you begin, please make sure the following prerequisites are in place:

Building the Workflow

This section explains in detail how you can create the workflow to convert MS Excel files to PDF.

This workflow is available for download as well. If you are downloading, you can import it to Nintex Workflow for Office 365, set the API KEY, and publish it. Once the workflow is published, you are ready to go.

If you are creating the workflow step by step, you can navigate to a site collection and document library containing the MS Excel document and choose to create a new Nintex Workflow. In this example, we use the standard Shared Document library available on most site collections.

Create the Following Workflow Variables:

The following Workflow Variables need to be created for the workflow to work correctly:

  • JSON (Text): Contains the JSON, JavaScript Object Notation, the command that will be sent to the conversion service.

  • API_KEY (Text): A unique ID that will be used to look up your Muhimbi subscription details.

  • ResponseText (Text): The status message returned by the Conversion Service.

  • ResponseCode (Integer): The status code returned by the Conversion Service.

    create workflow variables

As a first step, insert a Set Workflow Status action, edit it and set it to Started. This status will let you know that the workflow has actually been triggered (as there is no other way to track this in MS SharePoint Online). This will also give you the option to click on something to inspect the current status of the workflow.

Add a Build String action and set the Output to the JSON workflow variable. In the String field enter the following:

\[  
"sharepoint_file":  
\[  
"site_url":"‍{Workflow Context:Current site URL}‍",  
"source_file_url":"‍{Current Item:Server Relative URL}‍",  
"destination_file_url":"‍{Current Item:Server Relative URL}‍.pdf"  
\],  
"output_format":"PDF",  
"fail_on_error":true  
\]

add build string action

When you insert code, pay attention to the following:

  • JSON Notation: You may be familiar with JSON notation, but note that we have replaced the curly braces - { } - with square brackets [ ]. This is due to a bug in Nintex Workflow for Office 365. If you have any concerns about using square brackets (as they are also used for Array types) feel free to replace them with anything else. In a follow-up step we will fix them.

  • Copy & Paste: When pasting this JSON code from the browser window, paste it in Notepad (and copy back) to strip out non-standard characters and formatting.

  • References: The text displayed in red are Nintex Workflow references. After pasting the entire fragment, replace each Nintex reference using the Advanced Lookup facility on the bottom of the text box in the screenshot above.

  • Output file name: In this basic example, we just add ‘.pdf’ to the end of the output path and file name. To keep things simple, we are not including the Nintex Workflow actions to strip off the old extension and add the new one. You can use any valid output path and file name.

As mentioned above, we have used square brackets for JSON above and we need to replace these with curly braces again. You can insert a Replace Substring in String action and configure it as follows:

  • Search String: Enter the opening square bracket [.

  • Replace String: Enter the opening curly brace {.

  • String: Insert a reference to the workflow variable named JSON.

  • Output: Pick the JSON workflow variable to store the results in.

  • Click Save button.

    41

Copy the workflow action (using the actions menu), and paste it as the next action. Configure the newly pasted workflow action and replace the opening bracket with the closing bracket ‘]’. Do the same for the curly brace, and replace ‘{’ with ‘}’. Click Save button, and we now have a valid JSON to send to the Conversion Service.

You need to set the API_KEY next. Insert a Set Variable action and configure it to set the API_KEY workflow variable to the API Key you received by email when signing up for the Muhimbi Document Converter Services Online and click the Save button. E.g.:

decafbad-baad-baad-baad-decafbaaaaad

Note: Do not try to use this particular key, as it will not work. Do not put curly braces around the key.

set api key

Next, you need to insert the Web Request action and configure it as follows:

  • URL: https://api.muhimbi.com/api/v1/operations/convert

  • Method: POST

  • Content type: application/json

  • Add header: Click Add header, specify API_KEY as the Header name and insert a reference to the API_KEY workflow variable for the Header value.

  • Body: Select the Content option, add a reference to the JSON workflow variable in the Data field.

  • Store response content in: ResponseText.

  • Store http status code in: ResponseCode.

  • Click Save button.

insert web request action

Finally, insert another Set Workflow Status action and configure it with the text Completed. This will help us when we run the workflow, as we can now easily see when the workflow has been completed.Your completed workflow should look like the following:

set workflow status

run workflow

oublish workflow

The workflow is complete and can now be published.

Once published, open the document library the workflow is associated with and ensure that a MS Excel file is present. You can manually start the workflow. After a few seconds, the PDF file will show up next to the file the workflow was started on.

Troubleshooting

Although both Nintex Workflow for Office 365 and the Muhimbi Document Converter work very well together, there are a lot of moving parts in the workflow like custom generated JSON, customer-specific API keys, paths to the document libraries, etc. So, there are chances that you may encounter some issues when deploying the workflow. Some common issues and troubleshooting tips are provided below for your reference:

  • Check prerequisites: Double-check that the prerequisites listed in the beginning of this section are in place.

  • Log to History List: If it is not clear what is going wrong, log critical parts such as the JSON workflow variable (after the replace operation) as well as the ResponseText workflow variable (after the web request) using the Log To History List workflow action. You can see the contents of this list by clicking on the Workflow Status column for the List Item the workflow is running on.

  • Send email: The amount of text that can be logged to the History List is limited (roughly 250 characters). For larger messages, use the Send an Email action instead to send an email with debug content in the body of the email to yourself.

  • Copy & Paste: When copying the JSON fragment into your workflow, paste it into Notepad first to clean it, and then copy it from Notepad and paste it into your workflow. This is because browsers tend to insert hidden characters that are not filtered out by the Nintex Workflow editor.

  • Nintex References: Make sure that actual Nintex Workflow references replace the Nintex Workflow references in the JSON provided. Double-check if the references are active by logging the JSON workflow variable to the History List. You should see the actual paths and not {Current Item:Server Relative URL}.

  • Muhimbi Support: After double checking all the prerequisites and going over all the troubleshooting steps in this section, if you are still stuck, please contact our friendly support desk, who are here to help.

Fine-tuning

The workflow created in the previous section was to give a quick idea of how to use the Converter. However, it would benefit from error handling and a solution for a possible recursion problem where the workflow will be triggered for PDF files it has created.

We have created a version of the workflow that is more production ready. Full details on the same are beyond the scope of this article. You can download the full workflow here and customize this as per your requirements.

After customization, you can import it into Nintex Workflow for Office 365, and set the API KEY, and then publish it for your use.

import nintex workflow

nintex workflow for office 365

set api key

Other Operations

This section demonstrated how to invoke the Convert action on Muhimbi’s REST interface to convert an MS Excel file to a PDF. In addition to PDF Conversion, we also expose additional end-points for Merge, Watermark, Secure, Split, OCR, and Copy Metadata operations. Complete examples are beyond the scope of this article, but you can find examples in the SharePoint section of our GitHub repository.