Convert Invoice Details to Excel Using AI Builder in Power Automate

Last July, I wrote a post about how we can extract invoice details using AI Builder and store them in a SharePoint list. That flow has been working great, but recently, I got a new requirement from the same team.

They no longer wanted to store the invoice data in a SharePoint list. Instead, they wanted to save the extracted invoice details directly into an Excel file.

Initially, I thought of using a “Run a prompt” action to extract the data, create an Excel file, and add the data to it. But this month, Microsoft released a brand-new feature called “Document output (preview)”, and it changes everything!

In this tutorial, I’ll show you step by step how you can convert invoice details into Excel using AI Builder’s new Document Output (preview) feature in Power Automate.

Convert Invoice Details to Excel Using AI Builder

Before I explain the step-by-step process, let me give you an overview of how the flow will work. I will create an Instant Cloud Flow, and when you run the flow, you will need to upload the invoice file (PDF or JPG).

The flow will then use the Run a Prompt action to generate an Excel file with all the extracted invoice details. Finally, the Excel file will be saved to a SharePoint document library.

Now, follow the steps below to do this:

  1. Go to Power Automate, click on Create, choose Instant cloud flow, select Manually trigger a flow, give your flow a name, and click Create.
    • Then add a File content Input.
power automate ai builder invoice processing
  1. Then, add a Run a prompt action from the Prompt select “+ New custom prompt”:
    • Give your prompt a name, like Extract Invoice Details.
    • In the prompt box, type something like:
Task:
Extract key details from uploaded travel receipts and generate a structured expense report.

Inputs:
Travel Receipts: Document input

Output Format:
JSON Array: each entry represents a single processed receipt.
– Properties:
-Date: Receipt date in YYYY-MM-DD format.
-VendorName: Name of the business/vendor on the receipt.
-ExpenseAccountName: Corresponding account name (from provided file, if available).
-TotalAmount: Grand total including taxes (decimal).
-CurrencyType: Currency symbol from the receipt (e.g., “INR”, “USD”, “EUR”,etc).
-Comments: Notes on errors, missing data, or validation remarks.

Instructions:
Receipt Count: Include a field summarizing the total number of receipts successfully processed.
Error Handling: If a receipt cannot be processed or data extraction fails, record the issue in the Comments field and continue with the remaining receipts.
Expense Code Mapping: Match each receipt to an account code and name from the provided file. If no match is found, leave the ExpenseAccountName field blank.
Formatting Consistency: Ensure all JSON entries follow the same structure, consistent date formats, and correct data types.
Accuracy Check: Verify that all extracted data accurately reflects the details on the original receipt.
power automate invoice processing

Replace the Document input.

  1. Next, from the output section, change the text to json.
Extract Invoice Details With Power Automate And AI Builder
  1. To test this prompt, add an invoice to the document and then click the text button. Then you can see the prompt will extract the data and show it in a json format.
Use the invoice processing in Power Automate
  1. Next, click the Save button to save this prompt. After that, in the Document input, add the File content contentBytes.
Invoice processing  AI model
  1. Then, add a Run a prompt action and select “+ New custom prompt”:
    • Give your prompt a name, such as “Convert JSON to Excel.”
    • In the prompt box, type something like:
Task:
Create an Excel file including all values found in the receipts JSON

Inputs:
– Receipts Data: Text input 

Additional Notes:
– Order of columns is: Date, Vendor Name, Expense Account Code, Expense, Account Name, Total Amount, Comments
– Autofit all cells in the spreadsheet.
– Use the modern pandas style (no writer.save() and safer handling of the buffer), so it won’t break depending on pandas version
How to automate invoice data copy to Excel in 1 minute
  1. Now, to this, we need to enable the code interpreter. Click on the three dots -> Settings.
document processing model in Power Automate
  1. Then enable code interpreter.
How to use Power Automate in Excel using AI
  1. To test this, add the json to the sample text, then click the test button. After the result, you see the right section convert the text to Document/Image.
power automate ai builder extract invoice
  1. Then, in the Text input, provide the text from the above run a prompt action.
Power Automate invoice to Excel
  1. Then add the create file and provide the parameters below:
    • Site Address: Select the site.
    • Folder Path: Choose the library.
    • File Name: concat(‘receipts_’,formatDateTime(utcNow(),’yyyymmddhhMMss’),’.xlsx’)
    • File Content:
base64toBinary(first(outputs('Run_a_prompt_1')?['body/responsev2/predictionOutput']?['files'])['base64_content'])
Automating Invoice with power automate

Now our flow is ready, save and click one test button. After that, manually upload an invoice file (PDF or JPG).

Convert Invoice Details to Excel Using AI Builder

After the flow runs successfully, open your SharePoint document library. You’ll see a newly created Excel file containing all the extracted invoice details.

Convert Invoice Details to Excel Using AI Builder in Power Automate

I hope this article helps you out!

Here, I explained how you can extract invoice details and automatically put them into an Excel file using AI Builder’s new Document Output (preview) feature in Power Automate.

You may also like:

Power Apps functions free pdf

30 Power Apps Functions

This free guide walks you through the 30 most-used Power Apps functions with real business examples, exact syntax, and results you can see.

Download User registration canvas app

DOWNLOAD USER REGISTRATION POWER APPS CANVAS APP

Download a fully functional Power Apps Canvas App (with Power Automate): User Registration App