API Reference

Cmdlet

Join-OfficeExcelWorkbook

Aliases: ExcelWorkbookJoin, ExcelWorkbookMerge, Merge-OfficeExcelWorkbook
Namespace PSWriteOffice
Aliases
ExcelWorkbookJoin ExcelWorkbookMerge Merge-OfficeExcelWorkbook
Inputs
OfficeIMO.Excel.ExcelDocument System.String[]
Outputs
OfficeIMO.Excel.ExcelWorkbookMergeResult

Merges worksheets from one or more workbooks into a target workbook.

Remarks

Merges worksheets from one or more workbooks into a target workbook.

Examples

Authored help example

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: Path

Parameters

CopyMode ExcelWorksheetCopyMode optionalposition: namedpipeline: Falsevalues: 2
Controls whether cross-workbook copies use package-level copy or value materialization.
Possible values: Values, Package
InputPath String requiredposition: 0pipeline: Falsealiases: FilePath, OutputPath, Path
Target workbook path to create or update.
SheetNamePrefix String optionalposition: namedpipeline: False
Prefix added to every imported worksheet name.
SourceDocument ExcelDocument optionalposition: namedpipeline: False
Optional source workbook object.
SourcePath String[] optionalposition: 1pipeline: True (ByPropertyName)aliases: FullName, LiteralPath
Source workbook paths to merge into the target workbook.
SourceSheet String[] optionalposition: namedpipeline: Falsealiases: Sheet, SheetName, WorksheetName
Specific source worksheet names to import. Defaults to all source sheets.
ValidationMode SheetNameValidationMode optionalposition: namedpipeline: Falsevalues: 2
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: Document

Parameters

CopyMode ExcelWorksheetCopyMode optionalposition: namedpipeline: Falsevalues: 2
Controls whether cross-workbook copies use package-level copy or value materialization.
Possible values: Values, Package
Document ExcelDocument requiredposition: namedpipeline: True (ByValue)
Target workbook to update outside the DSL context.
SheetNamePrefix String optionalposition: namedpipeline: False
Prefix added to every imported worksheet name.
SourceDocument ExcelDocument optionalposition: namedpipeline: False
Optional source workbook object.
SourcePath String[] optionalposition: 1pipeline: True (ByPropertyName)aliases: FullName, LiteralPath
Source workbook paths to merge into the target workbook.
SourceSheet String[] optionalposition: namedpipeline: Falsealiases: Sheet, SheetName, WorksheetName
Specific source worksheet names to import. Defaults to all source sheets.
ValidationMode SheetNameValidationMode optionalposition: namedpipeline: Falsevalues: 2
Controls how invalid or duplicate destination sheet names are handled.
Possible values: Sanitize, Strict

Outputs

OfficeIMO.Excel.ExcelWorkbookMergeResult