跳到主要内容

删除行 ExcelPower Automate

PDF4me 删除行 Excel 是一个 Power Automate 从列表中删除一个或多个行范围的操作 Excel 使用逗号分隔的范围语法来处理工作表。当流程向其传递工作簿和范围字符串时,可以使用此方法修剪标题行、删除过期记录或清除示例数据,并返回一个清理后的工作表。 Excel 文件已准备好进行下一步操作。

此操作的作用

PDF4me 删除行 Excel 需要 Excel 文件加上行范围字符串,即可从目标工作表中删除指定的行。一次请求中可以同时包含单行和带连字符的跨行。 PDF4me 总是从最高行号向下删除,因此同一调用中的较早范围永远不会移位。

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

验证您的身份 API 要求

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

您不容错过的重要事实

行范围是一个以逗号分隔的字符串
将单行和连字符范围合并到一个字段中,例如 1-5,10,15-20。可选的括号 [1-5] 与 1-5 一样有效。
删除操作总是从下往上执行。
PDF4me 会自动首先删除最高行号,因此同一请求中的其他范围永远不会因先前的删除而移位。
工作表名称(可选)
留空则选取工作簿中的第一个工作表,或者输入区分大小写的确切名称以选取特定工作表。
Power Automate PDF4me Excel 删除行操作显示文件内容、文件名、工作表名称和行范围字段

从先前的操作中映射文件内容和文件名,如果目标不是第一个工作表,则设置工作表名称,然后输入行范围。

参数

必需的: 文件内容、文件名和行范围必须始终提供。工作表名称为可选,默认为第一个工作表。

范围必需的它的作用例子
File ContentRequiredBase64 or buffer content of the source Excel file, typically mapped from a prior action like SharePoint Get File Content or OneDrive.[File Content from Get File]
File NameRequiredName of the Excel file including its extension, used for processing and naming the output.data.xlsx
Worksheet NameOptionalExact, case-sensitive name of the worksheet to delete rows from. Blank defaults to the first worksheet (index 0).Sheet1
Row RangesRequiredComma-separated row ranges in 1-based format. A single number deletes one row, a hyphenated pair deletes a span, and multiple entries can be combined, for example 1-5,10,15-20.1-5,10,15-20

删除行会返回什么?

场地类型它包含什么
documentBase64The Excel document with the specified rows removed.
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 with Code and Message, empty when Success is true.

常见错误信息

错误信息原因解决方案
Request is emptyRequest object is null.Provide a valid request object.
Document is emptyDocument object is null.Provide a valid Excel document.
Row ranges are requiredRowRanges is null or an empty string.Provide a valid row range specification.
Invalid worksheet selectionWorksheetName doesn't exist in the workbook.Use an existing worksheet name.
Invalid start row {row}. Row numbers must be positive.Row number is less than 1, such as "0-5" or "-1".Use row numbers of 1 or greater (1-based indexing).
Row {row} exceeds maximum data row ({maxRow})Row number is greater than the worksheet's data row count.Use row numbers within the valid range, 1 to maxRow.
Invalid range {start}-{end}: End row cannot be less than start rowEnd row is smaller than start row, such as "10-5".Make sure the end row is greater than or equal to the start row.
Invalid row range formatMalformed range string that couldn't be parsed.Check the syntax, use commas and hyphens correctly.

如何在……中设置删除行 Power Automate

  1. 添加 PDF4me删除行 Excel 致你 Power Automate 流动。
  2. 地图 文件内容文件名 源自之前的操作,例如 SharePoint 或者 OneDrive 获取文件内容。
  3. 工作表名称 如果目标不是第一个工作表,则留空。
  4. 进入 行范围 例如,以逗号分隔的字符串形式。 1-5,10,15-20
  5. 运行流程。行将自下而上自动删除,清理后的文件将返回为 document

典型配置

工作流程示例Common Power Automate flow patterns using Delete Rows from Excel.
报告页眉和页脚清理
  1. 当内部报告被标记为已准备好交付给客户时,流程触发器就会触发。
  2. 获取文件内容从中检索报告 SharePoint
  3. 删除行 Excel 运行时,行范围设置为内部页眉和页脚行,例如“1-3,96-100”。
  4. 清理后的文件将通过电子邮件发送给客户,而原始文件将单独存档。
计划事务日志修剪
  1. 循环触发器会运行每月一次的归档流程。
  2. 获取文件内容 Excel 来自事务日志 SharePoint
  3. 先前的步骤会识别早于保留窗口的行,并动态构建行范围字符串。
  4. 删除行 Excel 删除这些行,并将精简后的日志保存回目标位置。 SharePoint
模板样本数据删除
  1. 新员工入职流程从人力资源系统开始。
  2. 获取文件内容从模板库中检索费用报告模板。
  3. 删除行 Excel 删除行范围设置为“2-10”且工作表名称设置为“费用”的示例行。
  4. 干净的模板会以电子邮件的形式发送给新员工,第一行标题保持不变。

实用技巧

Count rows before building the range string
Row Ranges rejects any row number past the worksheet's data row count, so confirm the row count first if you are constructing ranges dynamically from another action's output.
Combine ranges in one call instead of looping
A single Row Ranges string like "1-5,10,15-20" deletes multiple spans in one action run, which is simpler to maintain than chaining several Delete Rows actions.
Match Worksheet Name 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.
Brackets around a range are optional
Both "1-5" and "[1-5]" are accepted for the same range, so either format works if the string is being generated by another system.
Don't worry about deletion order in the input
You can list ranges in any order in Row Ranges. PDF4me sorts and deletes from the highest row number down automatically to avoid index shifting.

速查表

场地价值
ActionDelete Rows from Excel
File ContentMapped from a prior file-retrieval action
File Namee.g. data.xlsx
Worksheet NameBlank = first worksheet, or exact case-sensitive name
Row Ranges format1-based, comma-separated: "1-5,10,15-20"
Deletion orderBottom-to-top automatically, no action needed
Outputdocument (Base64), Success, Error Message, Errors

常见问题

How do I delete rows in Excel using Power Automate?+
Add the PDF4me Delete Rows from Excel action, map File Content and File Name from a prior action, set Worksheet Name if needed, and provide Row Ranges as a comma-separated string such as 1-5,10,15-20. Running the flow returns the Excel file with those rows removed.
What format does Row Ranges use?+
Row Ranges is a comma-separated string using 1-based row numbers. Use a single number for one row, a hyphenated pair for a range, and commas to combine several, for example 1-5,10,15-20 deletes rows 1 through 5, row 10, and rows 15 through 20.
Why are rows deleted bottom-to-top instead of top-to-bottom?+
Deleting from the bottom up prevents index shifting. If rows were removed top-to-bottom, every deletion would shift the remaining row numbers up by one, causing later ranges in the same request to target the wrong rows. See <a href="https://learn.microsoft.com/en-us/office/vba/api/excel.range.delete" target="_blank" rel="noopener noreferrer">Microsoft's Excel Range.Delete reference</a> for how row shifting works natively in Excel.
What happens if a row range is invalid?+
The action returns Success as false with an ErrorMessage describing the problem, for example a row number that exceeds the worksheet data row count, or a range where the end row is smaller than the start row. No rows are deleted when the request fails validation.
Can I delete rows from a worksheet other than the first one?+
Yes. Set Worksheet Name to the exact, case-sensitive name of the target worksheet. Leaving it blank defaults to the first worksheet in the workbook. 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.

行业应用案例及应用

财务与会计应用案例

  • 交易清理从会计日志中删除旧的或无效的交易记录
  • 期末结算月末结算后删除临时计算行
  • 报告分发删除客户报告中的内部备注和审核评论
  • 预算模板从新的预算模板中移除上一年的示例数据

相关操作

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

获取帮助