Cmdlet
Join-OfficeExcelWorkbook
Merges worksheets from one or more workbooks into a target workbook.
Syntax
Join-OfficeExcelWorkbook [-CopyMode <Values|Package>] [-Path] <String> [-SheetNamePrefix <String>] [-SourceDocument <ExcelDocument>] [[-SourcePath] <String[]>] [-SourceSheet <String[]>] [-ValidationMode <Sanitize|Strict>] [<CommonParameters>]#Parameter set:
PathJoin-OfficeExcelWorkbook [-CopyMode <Values|Package>] -Document <ExcelDocument> [-SheetNamePrefix <String>] [-SourceDocument <ExcelDocument>] [[-SourcePath] <String[]>] [-SourceSheet <String[]>] [-ValidationMode <Sanitize|Strict>] [<CommonParameters>]#Parameter set:
DocumentExamples
Merge workbook sheets using the package fast path.
$sources = Get-ChildItem .\Incoming\*.xlsx | Select-Object -ExpandProperty FullName
$results = Join-OfficeExcelWorkbook -Path .\Combined.xlsx -SourcePath $sources -CopyMode Package -SheetNamePrefix Import
$results | Select-Object SheetCount, SourceSheets, TargetSheetsCopies worksheets between packages without importing rows into PowerShell objects, which is the preferred path for large workbook merge workflows.
Import selected source sheets with a prefix.
$merge = Join-OfficeExcelWorkbook -Path .\Target.xlsx -SourcePath .\Source.xlsx -SourceSheet Data,Summary -SheetNamePrefix 'Imported '
Get-OfficeExcelSummary -Path .\Target.xlsx |
Select-Object Path, WorksheetCountCopies selected worksheets from Source.xlsx into Target.xlsx using OfficeIMO workbook merge logic.
Parameters
- -CopyMode ExcelWorksheetCopyMode
- Controls whether cross-workbook copies use package-level copy or value materialization.
- Possible values:
Values,Package - -Path String
- Target workbook path to create or update.
- -SheetNamePrefix String
- Prefix added to every imported worksheet name.
- -SourceDocument ExcelDocument
- Optional source workbook object.
- -SourcePath String[]
- Source workbook paths to merge into the target workbook.
- -SourceSheet String[]
- Specific source worksheet names to import. Defaults to all source sheets.
- -ValidationMode ExcelSheetNameValidationMode
- Controls how invalid or duplicate destination sheet names are handled.
- Possible values:
Sanitize,Strict - -Document ExcelDocument
- Target workbook to update outside the DSL context.
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.