Cmdlet
Merge-OfficeExcelSheet
Appends worksheet rows or merges a source range into a target worksheet.
Syntax
Merge-OfficeExcelSheet
[-Address <String>]
[-BlankRowsBefore <Int32>]
[-Document <ExcelDocument>]
[-HeaderRow <Int32>]
[-IncludeSourceHeader]
[-MatchColumnsByHeader]
[-NoSourceHeader]
[-OverwriteExistingCells]
[-Sheet <OfficeSheetSelector>]
[-Source <Object>]
[-SourceRange <String>]
-SourceSheet <OfficeSheetSelector>
[<CommonParameters>]#Parameter set:
DocumentMerge-OfficeExcelSheet
[-Address <String>]
[-BlankRowsBefore <Int32>]
[-HeaderRow <Int32>]
[-IncludeSourceHeader]
[-MatchColumnsByHeader]
[-NoSourceHeader]
[-OverwriteExistingCells]
[-Path] <String[]>
[-Sheet <OfficeSheetSelector>]
[-Source <Object>]
[-SourceRange <String>]
-SourceSheet <OfficeSheetSelector>
[<CommonParameters>]#Parameter set:
PathMerge-OfficeExcelSheet
[-Address <String>]
[-BlankRowsBefore <Int32>]
[-HeaderRow <Int32>]
[-IncludeSourceHeader]
-LiteralPath <String[]>
[-MatchColumnsByHeader]
[-NoSourceHeader]
[-OverwriteExistingCells]
[-Sheet <OfficeSheetSelector>]
[-Source <Object>]
[-SourceRange <String>]
-SourceSheet <OfficeSheetSelector>
[<CommonParameters>]#Parameter set:
LiteralPathDescription
Source accepts a native ExcelDocument, a workbook path or FileInfo. Omit Source to copy rows within the target workbook. File targets are saved in place; live documents remain caller-owned and require an explicit save. The result reports the actual copied rows and columns.
Examples
Append monthly rows by their column headers.
Merge-OfficeExcelSheet -Path ./Sales.xlsx -Sheet Year -SourceSheet October -MatchColumnsByHeaderMerge a literal source file at a chosen target cell.
Get-Item -LiteralPath './Combined[1].xlsx' | Merge-OfficeExcelSheet -Sheet Combined -Source (Get-Item -LiteralPath './Branch[1].xlsx') -SourceSheet Sales -Address B5 -HeaderRow 4 -MatchColumnsByHeaderParameters
- -Address String
- Gets or sets the target start cell; omission appends after the used range.
- -BlankRowsBefore Int32
- Gets or sets blank rows before appended data; an explicit Address takes precedence.
- -Document ExcelDocument
- Gets or sets the live target workbook; omission uses the enclosing worksheet scope.
- -HeaderRow Int32
- Gets or sets the one-based target header row used for matching columns.
- -IncludeSourceHeader SwitchParameter
- Gets or sets whether to copy the source header along with its data rows.
- -MatchColumnsByHeader SwitchParameter
- Gets or sets whether columns are aligned by header text rather than position.
- -NoSourceHeader SwitchParameter
- Gets or sets whether the first source row is data rather than a header.
- -OverwriteExistingCells SwitchParameter
- Gets or sets whether source values may replace existing target cells.
- -Sheet OfficeSheetSelector
- Gets or sets the target worksheet name, one-based position or native worksheet.
- -Source Object
- Gets or sets another workbook as a native ExcelDocument, path or literal FileInfo.
- -SourceRange String
- Gets or sets the source A1 range; omission copies its used range.
- -SourceSheet OfficeSheetSelector
- Gets or sets the source worksheet name, one-based position or native worksheet.
- -Path String[]
- Gets or sets target workbook paths with filesystem wildcard expansion.
- -LiteralPath String[]
- Gets or sets literal target paths, including FileInfo.FullName and provider PSPath.
Common Parameters
This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
For more information, see about_CommonParameters.