API Reference
Cmdlet
Join-OfficeExcelWorkbook
Merges worksheets from one or more workbooks into a target workbook.
Remarks
Merges worksheets from one or more workbooks into a target workbook.
Examples
Merge workbook sheets using the package fast path.
PS>
$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, TargetSheets
Copies 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.
PS>
$merge = Join-OfficeExcelWorkbook -Path .\Target.xlsx -SourcePath .\Source.xlsx -SourceSheet Data,Summary -SheetNamePrefix 'Imported '
Get-OfficeExcelSummary -Path .\Target.xlsx |
Select-Object Path, WorksheetCount
Copies selected worksheets from Source.xlsx into Target.xlsx using OfficeIMO workbook merge logic.
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.
Syntax
Join-OfficeExcelWorkbook [-CopyMode <Values|Package>] -InputPath <String> [-SheetNamePrefix <String>] [-SourceDocument <ExcelDocument>] [-SourcePath <String[]>] [-SourceSheet <String[]>] [-ValidationMode <Sanitize|Strict>] [<CommonParameters>]#Parameter set:
PathParameters
- CopyMode ExcelWorksheetCopyMode
- Controls whether cross-workbook copies use package-level copy or value materialization.
- Possible values:
Values,Package - InputPath 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 SheetNameValidationMode
- Controls how invalid or duplicate destination sheet names are handled.
- Possible values:
Sanitize,Strict
Outputs
OfficeIMO.Excel.ExcelWorkbookMergeResult
Join-OfficeExcelWorkbook [-CopyMode <Values|Package>] -Document <ExcelDocument> [-SheetNamePrefix <String>] [-SourceDocument <ExcelDocument>] [-SourcePath <String[]>] [-SourceSheet <String[]>] [-ValidationMode <Sanitize|Strict>] [<CommonParameters>]#Parameter set:
DocumentParameters
- CopyMode ExcelWorksheetCopyMode
- Controls whether cross-workbook copies use package-level copy or value materialization.
- Possible values:
Values,Package - Document ExcelDocument
- Target workbook to update outside the DSL context.
- 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 SheetNameValidationMode
- Controls how invalid or duplicate destination sheet names are handled.
- Possible values:
Sanitize,Strict
Outputs
OfficeIMO.Excel.ExcelWorkbookMergeResult