跳到主要内容

从以下位置删除工作表 ExcelPower Automate

PDF4me 删除工作表 是一个 Power Automate 从……中移除一张或多张纸的操作 Excel 只需一次调用,即可按名称、索引或两者同时选择工作簿。使用此功能可以从模板中提取示例工作表、在分发报表前删除临时计算标签页,或按计划清理旧的工作表标签页,所有操作均无需打开工作簿。 Excel

此操作的作用

PDF4me 删除工作表 需要 Excel 文件中包含工作表名称列表、工作表索引或两者兼有,并返回已删除匹配工作表的工作簿。内置的安全检查会在请求会删除所有工作表的情况下阻止该请求,因为有效的工作簿必须始终至少保留一个工作表。

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

验证您的身份 API 要求

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

您不容错过的重要事实

工作表索引从 1 开始。
索引 1 对应第一个工作表,索引 2 对应第二个工作表,依此类推。此操作使用从 1 开始的索引,这与其他一些操作不同。 PDF4me Excel 行动。
至少要保留一份工作表。
删除工作簿中所有工作表的请求会被拒绝并返回错误,原因如下: Excel 至少需要一张纸。
名称和索引选择合并为一个联合
如果两个字段都已填写,则与任一列表匹配的所有工作表都会被删除一次,而不仅仅是与两个列表都匹配的工作表。
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 NameRequiredName of the Excel file including its extension, used for processing and output naming.data.xlsx
Worksheet NamesConditionalComma-separated list of worksheet names to delete. Case-sensitive, and combines with Worksheet Indexes as a union when both are set. Required only if Worksheet Indexes is left blank.Temp,Draft,Old
Worksheet IndexesConditionalComma-separated list of 1-based worksheet indexes to delete, for example "1,3" for the first and third sheets. Required only if Worksheet Names is left blank.1,3

删除工作表会返回什么?

场地类型它包含什么
documentBase64Excel document with the specified worksheets deleted.
SuccessBooleantrue when the deletion 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 Excel Content with Worksheets Deleted]",
"Success": true,
"ErrorMessage": null,
"Errors": []
}

常见错误信息

错误信息原因解决方案
Request is emptyRequest object is null.Provide a valid request object.
Document is emptyDocument object is null.Provide a valid Excel document.
Invalid worksheet selectionWorksheet name doesn't exist or index is out of range.Use valid worksheet names, or valid 1-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.
Cannot delete all worksheets. At least one worksheet must remain.The combined selection matches every worksheet in the workbook.Remove at least one worksheet from the deletion list so one sheet remains.

如何在设置中删除工作表 Power Automate

  1. 添加 PDF4me删除工作表 致你 Power Automate 流动。
  2. 地图 文件内容文件名 源自之前的操作,例如 SharePoint 或者 OneDrive 获取文件内容。
  3. 工作表名称工作表索引或者两者兼而有之,以确定要移除的床单。
  4. 运行流程。 PDF4me 删除匹配的工作表,并返回更新后的工作簿。 document如果该请求会删除所有工作表,则阻止该请求。

我应该按名称还是按索引选择工作表?

使用 工作表名称 当要删除的图纸具有稳定且已知的名称时,例如“Sample1”或“Draft”,即使图纸顺序之后发生变化,选择仍然正确。 工作表索引 当流程生成工作簿时,如果工作表顺序可预测但名称可变,请记住,这里的索引是 基于 1 的同时设置会删除两个选定项的并集,因此它们之间的重叠不会导致错误,它只会删除该工作表一次。

典型配置

工作流程示例Common Power Automate flow patterns using Delete Worksheets from Excel.
清理新员工入职培训模板
  1. 当人力资源系统中创建新的员工记录时,就会触发一个流程。
  2. 获取文件功能从文档库中检索主费用报告模板。
  3. 删除工作表,运行工作表名称设置为“Sample1,Sample2,Instructions”以删除占位符工作表。
  4. 清理后的模板会通过电子邮件发送给新员工,只保留他们需要的“费用”和“收据”标签页。
报告定稿后方可分发
  1. 月度报告生成流程完成并生成工作报告。 Excel 文件。
  2. 获取文件功能从文件中检索报告。 SharePoint
  3. 删除工作表会按名称删除内部的“计算”、“原始数据”和“草稿”选项卡,只保留“汇总”和“图表”。
  4. 最终定稿文件将通过电子邮件发送给领导层,而不会泄露内部工作表。
定期归档工作表清理
  1. 循环触发器会按季度运行归档流程,生成滚动 12 个月的报告。
  2. 获取文件功能可检索滚动报告,该报告每月累积一个工作表。
  3. 删除工作表会删除最早季度的月份标签,这些标签按名称标识(例如“2026 年 1 月”、“2026 年 2 月”、“2026 年 3 月”)。
  4. 精简后的工作簿已保存。 SharePoint保持文件大小在可控范围内。

实用技巧

Double-check the index base before mapping a value
Delete Worksheets uses 1-based indexes, so index 1 is the first sheet. Other PDF4me Excel actions use 0-based indexing; mixing the two up is the most common source of the wrong sheet being deleted.
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.
Always leave one worksheet standing
Build the deletion list so at least one sheet survives. Attempting to delete every worksheet fails outright rather than leaving an empty workbook.
Combining names and indexes extracts a union, not an intersection
If a worksheet matches either list, it is removed once. Use only one selection method if you need a fully predictable deletion set.
Read the error message for the available worksheet list
An invalid worksheet selection error includes the workbook's actual worksheet names or count, which is faster to debug against than guessing at a typo.

速查表

场地价值
ActionDelete Worksheets
File ContentMapped from a prior file-retrieval action
File Namee.g. data.xlsx
Worksheet NamesComma-separated, case-sensitive
Worksheet Indexes1-based, comma-separated
At least one requiredWorksheet Names or Worksheet Indexes must be set
Both filledUnion of name matches and index matches
Safety checkBlocks deletion if it would remove every worksheet
Outputdocument (Base64 Excel), Success, Error Message, Errors

常见问题

How do I delete a worksheet from Excel in Power Automate?+
Add the PDF4me Delete Worksheets action, map File Content and File Name from a prior action, then set Worksheet Names, Worksheet Indexes, or both to choose which sheets to remove. The action returns the updated workbook with the matching worksheets deleted.
Are Worksheet Indexes 0-based or 1-based in Delete Worksheets?+
Worksheet Indexes are 1-based in this action, so index 1 refers to the first worksheet, index 2 to the second, and so on. This differs from some other PDF4me Excel actions, so check the field's placeholder text before mapping a value. 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.
What happens if I try to delete every worksheet in a workbook?+
The action blocks the request and returns an error, because a valid Excel workbook must always contain at least one worksheet. Adjust the Worksheet Names or Worksheet Indexes list so at least one sheet remains.
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 deletes the union of the two selections, so any worksheet matching either list is removed once, even if it appears in both.
What if a worksheet name or index does not exist in the workbook?+
The action returns an invalid worksheet selection error naming the missing sheet, along with the worksheets actually available in the workbook. See <a href="https://learn.microsoft.com/en-us/office/vba/api/excel.worksheets" target="_blank" rel="noopener noreferrer">Microsoft's Worksheets collection reference</a> for how Excel itself models worksheet collections.

行业应用案例及应用

财务与会计应用案例

  • 模板分发在发送给新用户之前,请从会计模板中删除示例工作表。
  • 报告定稿:在分发财务报告之前,删除计算工作表。
  • 期末结算从滚动月度报告中移除前期工作表
  • 审计准备从审计交付物中删除内部审核工作表

相关操作

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

获取帮助