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:
- 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.

- 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.

Replace the Document input.
- Next, from the output section, change the text to json.

- 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.

- Next, click the Save button to save this prompt. After that, in the Document input, add the File content contentBytes.

- 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

- Now, to this, we need to enable the code interpreter. Click on the three dots -> Settings.

- Then enable code interpreter.

- 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.

- Then, in the Text input, provide the text from the above run a prompt action.

- 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'])

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

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

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:
- Retrieve Specific Item in Power Automate
- Set Multiple Approvers in Power Automate
- Send Email Reminders from a SharePoint List using Power Automate
- Send an Email with Attachments from Local Folder using Power Automate
- The file Document.docx is locked for shared use by user in Power Automate

Hey! I’m Bijay Kumar, founder of SPGuides.com and a Microsoft Business Applications MVP (Power Automate, Power Apps). I launched this site in 2020 because I truly enjoy working with SharePoint, Power Platform, and SharePoint Framework (SPFx), and wanted to share that passion through step-by-step tutorials, guides, and training videos. My mission is to help you learn these technologies so you can utilize SharePoint, enhance productivity, and potentially build business solutions along the way.