跳到主要内容

从工作表中提取工作表 ExcelPower Automate

PDF4me 提取工作表 是一个 Power Automate 将一个、多个或所有工作表从……转换的操作 Excel 将工作簿整理成结构化的形式 JSON使用每个工作表的第一行作为列标题。用它来将工作表数据导入到…… API数据库导入,或 JSON 无需编写任何解析代码即可进行归档。

此操作的作用

PDF4me 提取工作表 需要 Excel 文件加上可选的工作表选择,并返回一个 JSON 每个提取的工作表名称对应一个键,该键包含一个行对象数组。数组中的行对象由该工作表的标题行和数据行构成,其中的数字、日期、布尔值和文本均以其原始格式保留。 JSON 类型。

相关博客文章
目前尚无关于此功能的博客文章——敬请期待。
在此期间,您可以浏览 PDF4me 博客,查看适用于各平台的教程和工作流程。
访问博客

验证您的身份 API 要求

要访问 PDF4me 网站 API 通过 Power Automate每个请求都必须包含一个有效的 API 密钥。身份验证用于验证您的身份,并使连接器能够访问。 PDF4meExcel 从您的流程中提取工作表。

您不容错过的重要事实

空白选择表示所有工作表
将工作表名称和工作表索引都留空,即可一次性提取工作簿中的所有工作表。
名称和索引选择合并为一个联合
如果两个字段都已填写,则匹配任一列表的每个工作表都会被提取一次,而不仅仅是匹配两个列表的工作表。
工作表索引从 0 开始。
索引 0 代表第一个工作表,索引 1 代表第二个工作表,依此类推。工作表名称区分大小写。
Power Automate PDF4me Excel 提取工作表操作显示文件内容、文件名、工作表名称和工作表索引字段

从先前的操作映射文件内容和文件名,然后设置工作表名称和/或工作表索引,或者两者都留空以提取每个工作表。

参数

必需的: 文件内容和文件名必须提供。工作表名称和工作表索引均为可选;留空将提取所有工作表。

范围必需的它的作用例子
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

提取工作表会返回什么?

场地类型它包含什么
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": []
}

解码后的文档内容示例:

{
"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}
]
}

常见错误信息

错误信息原因解决方案
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.

如何在[此处应填写具体内容,例如“如何设置提取工作表”]中设置[此处应填写具体内容,例如“如何设置提取工作表”] Power Automate

  1. 添加 PDF4me提取工作表 致你 Power Automate 流动。
  2. 地图 文件内容文件名 源自之前的操作,例如 SharePoint 或者 OneDrive 获取文件内容。
  3. 工作表名称工作表索引或者两者都选,或者两者都留空以提取所有工作表。
  4. 运行流程。每个选定工作表的第一行将成为 JSON 键,结果返回为 document,一个经过 Base64 编码的文本。 JSON 按工作表名称筛选对象。

何时应该使用工作表名称,何时应该使用工作表索引?

使用 工作表名称 当目标工作表具有稳定且已知的名称时,例如“摘要”或“客户数据”,即使工作表顺序发生变化,选择结果也保持不变。 工作表索引 当流程生成工作簿时,工作表顺序固定,但名称可变。同时设置“提取两个选定项”会提取两个选定项的并集,因此它们之间的重叠不会导致输出中出现重复的工作表。

典型配置

工作流程示例Common Power Automate flow patterns using Extract Worksheets from Excel.
多页工作簿 API 喂养
  1. 当多页数据时,流程触发。 Excel 工作簿已上传到 SharePoint “数据导出”文件夹。
  2. 获取文件内容以检索工作簿。
  3. “提取工作表”功能会将工作表名称和工作表索引都留空,以便转换每个工作表。
  4. 解析 JSON 处理结果,然后“应用到每个”循环将每个工作表的数据发布到它自己的工作表中。 API 终点。
已安排 JSON 档案
  1. 循环触发器会运行每月一次的归档流程。
  2. 获取文件内容以检索已完成的项目 Excel 来自文件 SharePoint
  3. 提取工作表将每个工作簿转换为 JSON 包含所有床单。
  4. JSON 输出存储到 Azure Blob 存储或 SharePoint 与原始存档文件一起保存。
选择性客户出口
  1. Microsoft Forms 提交请求导出特定于客户的数据。
  2. 获取文件内容功能从安全位置检索主工作簿。 SharePoint 图书馆。
  3. “提取工作表”功能会将工作表名称设置为客户端有权查看的工作表,例如“Summary,ClientData”。
  4. 由此产生的 JSON 以电子邮件形式发送给请求者,完全不将无关的内部表格包含在导出文件中。

实用技巧

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.

速查表

场地价值
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

常见问题

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.

行业应用案例及应用

IT与系统集成用例

  • 系统迁移将整个 Excel 工作簿导出为 JSON 格式,以便进行系统迁移
  • 多API集成将不同的工作表发送到不同的 API 端点
  • 数据备份创建多工作表 Excel 文件的 JSON 备份
  • 云迁移将 Excel 工作簿转换为 JSON 格式以便云存储

相关操作

在其他平台上执行相同任务

获取帮助