API Reference

Cmdlet

Add-OfficeExcelTableRow

Namespace PSWriteOffice
Inputs
OfficeIMO.Excel.ExcelDocument OfficeIMO.Excel.ExcelTable System.Object
Outputs
OfficeIMO.Excel.ExcelTable

Appends one or more data rows to an existing Excel table.

Remarks

Use this command when a workbook already contains a named table and the script should extend that table without recreating the worksheet through the Excel DSL. The command accepts a workbook path, an open ExcelDocument, or an existing ExcelTable object. Objects, dictionaries, DataTable, DataView, IDataReader, and DataRow input are normalized through the same table input pipeline used by Add-OfficeExcelTable. When a path is supplied, PSWriteOffice opens the workbook, appends the rows, saves the workbook, and releases the document. When an open workbook or table is supplied, the caller controls the lifetime and should close or save the workbook after all edits are complete.

Examples

Authored help example

Append a row to a named table in an open workbook.

PS>


$doc = Get-OfficeExcel -Path .\Report.xlsx
            $doc | Add-OfficeExcelTableRow -Sheet Data -TableName Sales -InputObject ([pscustomobject]@{ Region='APAC'; Revenue=300 })
            $doc | Close-OfficeExcel -Save
        

Uses the existing OfficeIMO Excel table append API and keeps the workbook open for further changes.

Append several service-readiness rows to an existing table.

PS>


$rows = @(
                [pscustomobject]@{ Service='Identity'; Status='Ready'; Owner='IAM' }
                [pscustomobject]@{ Service='Network'; Status='Investigating'; Owner='Platform' }
            )
            Add-OfficeExcelTableRow -Path .\Readiness.xlsx -Sheet Readiness -TableName ServiceReadiness -InputObject $rows
        

Opens the workbook from disk, appends both objects to the named table, and saves the file.

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

Add-OfficeExcelTableRow -InputObject <Object> -InputPath <String> [-PassThru] [-Sheet <String>] [-SheetIndex <Nullable`1>] -TableName <String> [<CommonParameters>]
#
Parameter set: Path

Parameters

InputObject Object requiredposition: 1pipeline: True (ByValue)aliases: Data, Values
Rows to append. Accepts objects, dictionaries, DataTables, DataViews, IDataReaders, and DataRows.
InputPath String requiredposition: 0pipeline: Falsealiases: FilePath, Path
Workbook path to open, update, save, and close.
PassThru SwitchParameter optionalposition: namedpipeline: False
Emit the updated table wrapper for open document or table inputs. Path-owned workbooks are saved and closed by this command, so they do not emit a live table wrapper.
Sheet String optionalposition: namedpipeline: Falsealiases: WorksheetName
Worksheet name that owns the table. Use this when table names might repeat across sheets.
SheetIndex Nullable`1 optionalposition: namedpipeline: False
Zero-based worksheet index that owns the table.
TableName String requiredposition: namedpipeline: Falsealiases: Name
Existing table name or display name, for example the name returned by Get-OfficeExcelTable.

Outputs

OfficeIMO.Excel.ExcelTable

Add-OfficeExcelTableRow -Document <ExcelDocument> -InputObject <Object> [-PassThru] [-Sheet <String>] [-SheetIndex <Nullable`1>] -TableName <String> [<CommonParameters>]
#
Parameter set: Document

Parameters

Document ExcelDocument requiredposition: namedpipeline: True (ByValue)
Open workbook to update. The caller remains responsible for saving and closing it.
InputObject Object requiredposition: 1pipeline: True (ByValue)aliases: Data, Values
Rows to append. Accepts objects, dictionaries, DataTables, DataViews, IDataReaders, and DataRows.
PassThru SwitchParameter optionalposition: namedpipeline: False
Emit the updated table wrapper for open document or table inputs. Path-owned workbooks are saved and closed by this command, so they do not emit a live table wrapper.
Sheet String optionalposition: namedpipeline: Falsealiases: WorksheetName
Worksheet name that owns the table. Use this when table names might repeat across sheets.
SheetIndex Nullable`1 optionalposition: namedpipeline: False
Zero-based worksheet index that owns the table.
TableName String requiredposition: namedpipeline: Falsealiases: Name
Existing table name or display name, for example the name returned by Get-OfficeExcelTable.

Outputs

OfficeIMO.Excel.ExcelTable

Add-OfficeExcelTableRow -InputObject <Object> [-PassThru] -Table <ExcelTable> [<CommonParameters>]
#
Parameter set: Table

Parameters

InputObject Object requiredposition: 1pipeline: True (ByValue)aliases: Data, Values
Rows to append. Accepts objects, dictionaries, DataTables, DataViews, IDataReaders, and DataRows.
PassThru SwitchParameter optionalposition: namedpipeline: False
Emit the updated table wrapper for open document or table inputs. Path-owned workbooks are saved and closed by this command, so they do not emit a live table wrapper.
Table ExcelTable requiredposition: namedpipeline: True (ByValue)
Existing OfficeIMO Excel table wrapper to append to when the table has already been resolved.

Outputs

OfficeIMO.Excel.ExcelTable