cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
FayHudson
Regular Visitor

Trying to convert an excel to PDF

Im trying to build a flow to convert a sheet in an excel file into a PDF s that a second flow can email it out as an attachment but im failing at the first hurdle. my flow to convert to PDF wont run.

 

Id already added a step to copy the file from sharepoint to one drive as i couldnt find a convert tool to do it direct from sharepoint.

 

My flow looks like this..

 

FayHudson_0-1633629235991.png

 

error message ...

 

FayHudson_1-1633629376958.png

 

FayHudson_2-1633629419840.png

 any ideas??

 

11 REPLIES 11
DamoBird365
Super User
Super User

Hi @FayHudson 

 

xlsx to pdf is supported but based on my testing, I was able to recreate the error by running the conversion on an invalid xlsx file.  You mention that the file is copied from another location, have you manually tried opening the xlsx file on OneDrive?  My guess is that the create file action in your other flow isn't creating a valid xlsx as expected and you need to sort the original flow out for this flow to work 😉

 

Please consider accepting my answer as a solution if it helps to solve your problem.

Cheers
Damien

Please take a look and subscribe to my YouTube Channel for more Power Platform ideas and concepts, or take a look at my website. Thanks

FayHudson
Regular Visitor

Thanks Damien, however the previous flow to create the xls file in one drive appears to be working so im not sure what is going wrong?

 

The previous flow is as follows:

 

FayHudson_0-1634157587556.png

This flow successfully runs and i can see the xls file now in my one drive

FayHudson_1-1634157717014.png

Any ideas?

Hi @FayHudson 

 

Can you open the file on OneDrive? How basic or complicated are the contents of the file? 

 

Damien

Hi @DamoBird365 

 

Now that you mention it, it is a spreadsheet with a number of sheets that contain tables feeding into a query.  Is that a problem?

 

Ultimately im only copying to one drive because i cant find a convert to PDF straight from sharepoint (unless im missing something else that could help?!)

 

I have a file in excel and each week i want to issue a PDF of one of the sheets out to a dist list

@FayHudson maybe?! Joys of testing and troubleshooting these things. I’ve just read over the docs https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_get_content_format?view=o... and whilst there are known limitations, i can’t see anything about complex or multiple sheet workbooks. Can you try the routine on a simplified version of the workbook? Remove all but one sheet? 

Using office scripts, it is possible to remove additional sheets but we need to discover if that’s the cause first.

 

Damien

it works with a simple excel file so is clearly an issue with the excel file itself!!  

 

Thanks - but now still at a loss as to how i resolve

 

Can you try it on the sheet that you want to save as pdf? If that works, I can give you a solution for stripping out the other sheets on your copy file.

 

Damien

Sorry @DamoBird365  Im not sure I understand what you mean, as in save a copy of the file i want to convert but with all the other sheets stripped out and then see if the conversion works?

 

Thanks

Fay

Hi @FayHudson 

 

Exactly that. Yes.

I have now got the flow to succeed and create the PDF - however the flow seems to run twice and the first time it succeeds and then creates a failed run as well? Not sure if this is important?

 

The convert to PDF flow is as follows:

FayHudson_0-1634203402519.png

 

Im guessing now once ive copied the original file to one drive  i need to understand how to delete the other worksheets to enable the PDF creation to occur. Is it best to do that or simply only copy the relevant worksheet?

Hi @FayHudson 

 

One possible way to do this is to use the 2nd of two office scripts in this video https://youtu.be/4ZiMjjV1c3Q which allows you to delete sheets from an existing file. 

Please consider accepting my answer as a solution if it helps to solve your problem.

Cheers
Damien

Please take a look and subscribe to my YouTube Channel for more Power Platform ideas and concepts, or take a look at my website. Thanks

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

Carousel_PP_768x460_Wave2 (1).png

2022 Release Wave 2 Plan

Power Platform release plan for the 2022 release wave 2 describes all new features releasing from October 2022 through March 2023.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (3,092)