Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

Join-OfficeExcelSheet

Aliases: ExcelSheetJoin, ExcelSheetMerge, Merge-OfficeExcelSheet
Module PSWriteOffice
Aliases
ExcelSheetJoin ExcelSheetMerge Merge-OfficeExcelSheet
Inputs
OfficeIMO.Excel.ExcelDocument
Outputs
OfficeIMO.Excel.ExcelWorksheetMergeResult

Appends or merges rows from one worksheet into another.

Syntax

Join-OfficeExcelSheet [-BlankRowsBefore <Int32>] [-IncludeSourceHeader] [-MatchColumnsByHeader] [-NoSourceHeader] [-OverwriteExistingCells] [-SourceDocument <ExcelDocument>] [-SourcePath <String>] [-SourceRange <String>] -SourceSheet <String> [-TargetHeaderRow <Int32>] [-TargetSheet <String>] [-TargetSheetIndex <Int32>] [-TargetStartColumn <Int32>] [-TargetStartRow <Int32>] [<CommonParameters>]
#
Parameter set: Context
Join-OfficeExcelSheet [-BlankRowsBefore <Int32>] [-IncludeSourceHeader] [-MatchColumnsByHeader] [-NoSourceHeader] [-OverwriteExistingCells] [-Path] <String> [-SourceDocument <ExcelDocument>] [-SourcePath <String>] [-SourceRange <String>] -SourceSheet <String> [-TargetHeaderRow <Int32>] [-TargetSheet <String>] [-TargetSheetIndex <Int32>] [-TargetStartColumn <Int32>] [-TargetStartRow <Int32>] [<CommonParameters>]
#
Parameter set: Path
Join-OfficeExcelSheet [-BlankRowsBefore <Int32>] -Document <ExcelDocument> [-IncludeSourceHeader] [-MatchColumnsByHeader] [-NoSourceHeader] [-OverwriteExistingCells] [-SourceDocument <ExcelDocument>] [-SourcePath <String>] [-SourceRange <String>] -SourceSheet <String> [-TargetHeaderRow <Int32>] [-TargetSheet <String>] [-TargetSheetIndex <Int32>] [-TargetStartColumn <Int32>] [-TargetStartRow <Int32>] [<CommonParameters>]
#
Parameter set: Document

Examples

Authored help example

Append source rows below a combined sheet.

$result = Join-OfficeExcelSheet -Path .\Report.xlsx -TargetSheet Combined -SourceSheet Data -MatchColumnsByHeader -BlankRowsBefore 1
$result |
    Select-Object -Property SourceSheet, TargetSheet, RowsCopied, ColumnsCopied

Copies rows from Data into Combined, aligns columns by header, and returns the merge result.

Parameters

-BlankRowsBefore Int32 optional
Blank rows to leave before appended data.
-IncludeSourceHeader SwitchParameter optional
Include the source header row in copied rows.
-MatchColumnsByHeader SwitchParameter optional
Match source columns to target columns by header text.
-NoSourceHeader SwitchParameter optional
Treat the first source row as data instead of a header row.
-OverwriteExistingCells SwitchParameter optional
Allow copied values to replace existing target cells.
-SourceDocument ExcelDocument optional
Optional source workbook object for cross-workbook joins.
-SourcePath String optional
Optional source workbook path for cross-workbook joins.
-SourceRange String optional
Source A1 range to copy. Defaults to the source used range.
-SourceSheet String required
Source worksheet name.
-TargetHeaderRow Int32 optional
1-based target header row when matching columns by header.
-TargetSheet String optional
Target worksheet name. Defaults to the current sheet inside an ExcelSheet block.
-TargetSheetIndex Int32 optional
Target worksheet index when using a workbook object or path.
-TargetStartColumn Int32 optional
1-based target start column. Defaults to the source range start column.
-TargetStartRow Int32 optional
1-based target start row. Defaults to appending after the target used range.
-Path String requiredposition: 0aliases: FilePath, InputPathsets: Path
Target workbook path to update.
-Document ExcelDocument requiredpipeline: True (ByValue)sets: Document
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.