In this guide you'll learn how to convert Microsoft Excel files to PDF using SharePoint Designer Workflows.
Muhimbi's PDF 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 PDF 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:
Create a Document Library named Proposal Documents. You can use any name of your choice.
Once created, navigate to the library’s Settings →
Document Library Settings → Versioning Settings screen and enable Requires content approval for submitted items.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:
Start MS SharePoint Designer and open the site collection that contains the Proposal Documents Document Library.
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.
Click Create button to proceed.
We are now ready to create the workflow. From the ‘Conditions’ menu, select the ‘If any value equals value’ condition.
Click the first value followed by the display data binding (fx) button.
Select ‘Current Item’ as the Source and select ‘Approval Status’ in the field.
Click OK button to continue.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:
Add another ‘If any value equals value’ condition.
Click the first value followed by the display data binding (fx) button.
Select ‘Current Item’ as the Source and select ‘File Type’ in the Field. Click OK button to continue.
Select ‘equals’ and change it to ‘not equals’.
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.
From the Actions menu, select Convert to PDF. It may be hidden behind the All Actions option.
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:
Leave it empty: When no value is specified, then the converted PDF is written to the same folder as the source file.
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’.
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.
Insert a new action named ‘Log to History List’ and enter ‘File converted’.
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.
Click Publish button to deploy and activate the workflow.
Testing the Workflow
You can test the workflow created by performing the following steps:
Create or upload an MS Excel file to the ‘Confidential Proposals’ folder.
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.
Once the workflow has been completed, you will find the PDF version of the document in the ‘Approved PDF Files’ folder.
If an error occurs during the execution of the workflow, you can perform the following to troubleshoot the same:
Check the messages on the workflow status screen.
Check for errors in the Windows Event log.
Check for errors in the SharePoint trace log.