Skip to main content

Extract Worksheets from Excel in Power Automate

PDF4me Extract Worksheets is a Power Automate action that converts one, several, or all worksheets from an Excel workbook into structured JSON, using each sheet's first row as column headers. Use it to feed worksheet data into an API, a database import, or a JSON archive without writing any parsing code.

What this action does

PDF4me Extract Worksheets takes an Excel file plus an optional worksheet selection and returns a JSON object with one key per extracted worksheet name. Each key holds an array of row objects built from that sheet's header row and data rows, with numbers, dates, booleans, and text preserved in their native JSON types.

Related Blog Posts
No blog post yet for this feature — coming soon.
In the meantime, browse the PDF4me blog for tutorials and workflows across every platform.
Visit the blog

Authenticating Your API Request

To access the PDF4me Web API through Power Automate, every request must include a valid API key. Authentication validates your identity and enables the connector to reach PDF4me's Excel worksheet extraction service from your flow.

Important Facts You Should Not Miss

Blank selection means all worksheets
Leave Worksheet Names and Worksheet Indexes both empty to extract every worksheet in the workbook in one call.
Name and index selections combine as a union
If both fields are filled, every worksheet matching either list is extracted once, not just the ones matching both.
Worksheet Indexes are 0-based
Index 0 is the first worksheet, index 1 the second, and so on. Worksheet Names comparison is case-sensitive.
Power Automate PDF4me Excel Extract Worksheets action showing File Content, File Name, Worksheet Names, and Worksheet Indexes fields

Map File Content and File Name from a prior action, then set Worksheet Names and/or Worksheet Indexes, or leave both blank to extract every sheet.

Parameters

Required: File Content and File Name must always be provided. Worksheet Names and Worksheet Indexes are both optional; leaving them blank extracts all worksheets.

ParameterRequiredWhat it doesExample
File ContentRequiredBase64 or buffer content of the source Excel file, typically mapped from a prior action like SharePoint or OneDrive Get File Content.[File Content from Get File]
File NameConditionalName of the Excel file including its extension. Shown as a plain field in the connector UI and used for processing and output naming; supply it even though the connector does not mark it with an asterisk.data.xlsx
Worksheet NamesOptionalComma-separated list of worksheet names to extract. Case-sensitive, and combines with Worksheet Indexes as a union when both are set.Employees,Sales
Worksheet IndexesOptionalComma-separated list of 0-based worksheet indexes to extract, for example "0,2,4" for the first, third, and fifth sheets.0,2,4

What Does Extract Worksheets Return?

FieldTypeWhat it contains
documentBase64The extracted JSON data as a byte array, saved as a .txt file, keyed by worksheet name.
FileNameStringOutput file name with a .txt extension.
SuccessBooleantrue when extraction completed, false if the request failed validation or processing.
Error MessageStringDescription of what went wrong, null when Success is true.
ErrorsArrayDetailed error entries, empty when Success is true.
{
"document": "[Base64 JSON Data]",
"FileName": "report.txt",
"Success": true,
"ErrorMessage": null,
"Errors": []
}

Decoded document content example:

{
"Employees": [
{"Name": "John Doe", "Age": 30, "Department": "IT"},
{"Name": "Jane Smith", "Age": 28, "Department": "HR"}
],
"Sales": [
{"Product": "Widget", "Units": 100, "Revenue": 2500.00},
{"Product": "Gadget", "Units": 75, "Revenue": 1875.00}
]
}

Common Error Messages

Error MessageCauseSolution
Request is emptyRequest object is null.Provide a valid request object.
Document is emptyDocument object is null or DocData is null.Provide a valid Excel document.
Workbook contains no worksheetsExcel file has 0 worksheets.Provide a valid Excel file with at least one worksheet.
Invalid worksheet selectionWorksheet name does not exist or index is out of range.Use valid worksheet names or 0-based indexes.
Available worksheets in workbook (X total)Informational message appended when worksheet selection validation fails.Review worksheet names or indexes and use valid values from the X available worksheets listed.

How Do I Set Up Extract Worksheets in Power Automate?

  1. Add PDF4meExtract Worksheets to your Power Automate flow.
  2. Map File Content and File Name from a previous action, such as SharePoint or OneDrive Get File Content.
  3. Set Worksheet Names, Worksheet Indexes, both, or leave both blank to extract every worksheet.
  4. Run the flow. Each selected worksheet's first row becomes the JSON keys, and the result returns as document, a Base64-encoded JSON object keyed by worksheet name.

When Should I Use Worksheet Names Versus Worksheet Indexes?

Use Worksheet Names when the target sheets have stable, known names, such as "Summary" or "ClientData", since the selection stays correct even if the sheet order changes. Use Worksheet Indexes when a flow generates workbooks with predictable sheet order but variable names. Setting both extracts the union of the two selections, so overlap between them does not duplicate a worksheet in the output.

Typical Setups

Workflow ExamplesCommon Power Automate flow patterns using Extract Worksheets from Excel.
Multi-sheet workbook to API feed
  1. A flow triggers when a multi-sheet Excel workbook is uploaded to a SharePoint "Data Export" folder.
  2. Get File Content retrieves the workbook.
  3. Extract Worksheets runs with both Worksheet Names and Worksheet Indexes left blank to convert every sheet.
  4. Parse JSON processes the result, and an Apply to each loop posts each worksheet's data to its own API endpoint.
Scheduled JSON archival
  1. A recurrence trigger runs a monthly archival flow.
  2. Get File Content retrieves completed project Excel files from SharePoint.
  3. Extract Worksheets converts each workbook to JSON with all sheets included.
  4. The JSON output is stored to Azure Blob Storage or SharePoint alongside the original archived file.
Selective client export
  1. A Microsoft Forms submission requests a client-specific data export.
  2. Get File Content retrieves the master workbook from a secure SharePoint library.
  3. Extract Worksheets runs with Worksheet Names set to only the sheets the client is authorized to see, for example "Summary,ClientData".
  4. The resulting JSON is emailed to the requestor, leaving unrelated internal sheets out of the export entirely.

Practical Tips

Leave both selection fields blank for a full export
Extracting every worksheet in one call is simpler than chaining several Extract Worksheets actions when a flow needs the whole workbook as JSON.
Match Worksheet Names exactly, including case
Worksheet name comparison is case-sensitive. A mismatch returns an invalid worksheet selection error even if the name looks correct at a glance.
Remember Worksheet Indexes start at 0
Index 0 is the first sheet, not the second. Off-by-one index values are a common source of the wrong worksheet being extracted.
Combining names and indexes extracts a union, not an intersection
If a worksheet matches either list, it is included once. Use only one selection method if you need precise, predictable output.
Parse JSON before looping through worksheets
The output document decodes to an object keyed by worksheet name, so a Parse JSON action followed by Apply to each on the object's keys is the standard pattern for per-sheet processing.

Cheat Sheet

FieldValue
ActionExtract Worksheets
File ContentMapped from a prior file-retrieval action
File Namee.g. data.xlsx
Worksheet NamesComma-separated, case-sensitive, or blank
Worksheet Indexes0-based, comma-separated, or blank
Blank + blankExtracts all worksheets
Both filledUnion of name matches and index matches
Outputdocument (Base64 JSON, .txt), FileName, Success, Error Message, Errors

Common Questions

How do I convert an Excel worksheet to JSON in Power Automate?+
Add the PDF4me Extract Worksheets action, map File Content and File Name from a prior action, then set Worksheet Names or Worksheet Indexes to choose which sheets to convert. Leaving both blank extracts every worksheet, returning a JSON document keyed by worksheet name. See the connector reference below for the full action list.
What happens if I leave Worksheet Names and Worksheet Indexes both blank?+
The action extracts every worksheet in the workbook and returns them all as JSON, one array per worksheet name in the output document. This is the simplest setup for a full workbook-to-JSON export.
Can I select worksheets by name and by index in the same request?+
Yes. If both Worksheet Names and Worksheet Indexes are provided, the action extracts the union of the two selections, so any worksheet matching either the name list or the index list is included once in the result.
Are Worksheet Indexes 0-based or 1-based?+
Worksheet Indexes are 0-based, so index 0 refers to the first worksheet, index 1 to the second, and so on. See <a href="https://learn.microsoft.com/en-us/office/dev/scripts/resources/samples/get-table-data" target="_blank" rel="noopener noreferrer">Microsoft's guide to reading Excel table data</a> for how worksheet and range indexing works natively in Excel.
What does the output JSON look like?+
The output document is a JSON object with one key per extracted worksheet name, and each key holds an array of row objects built from that sheet's header row and data rows, with numbers, dates, booleans, and text preserved in their native JSON types. See <a href="https://learn.microsoft.com/en-us/connectors/pdf4meconnect/" target="_blank" rel="noopener noreferrer">the PDF4me Power Automate connector reference</a> for the full action list.

Industry Use Cases & Applications

IT & System Integration Use Cases

  • System Migration: Export entire Excel workbooks as JSON for system migrations
  • Multi-API Integration: Send different worksheets to different API endpoints
  • Data Backup: Create JSON backups of multi-sheet Excel files
  • Cloud Migration: Convert Excel workbooks to JSON for cloud storage

Same Task on Other Platforms

Get Help