Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

Add-OfficeExcelTableOfContents

Aliases: ExcelTableOfContents
Module
PSWriteOffice
Aliases
ExcelTableOfContents
Inputs
OfficeIMO.Excel.ExcelDocument

Adds or refreshes a table-of-contents sheet with links to every sheet.

Syntax

Add-OfficeExcelTableOfContents
[-BackLink]
[-BackLinkAddress <String>]
[-BackLinkText <String>]
[-Document <ExcelDocument>]
[-IncludeHiddenNamedRanges]
[-IncludeNamedRanges]
[-Name <String>]
[-NoHyperlinks]
[-NoMoveFirst]
[-NoStyle]
[-PassThru]
[<CommonParameters>]
#
Parameter set: Default

Examples

Add a contents sheet

Open-OfficeExcel -Path .\Reports\Board-Pack.xlsx {
    ExcelTableOfContents
}

Adds a first sheet with a link to every other sheet.

Build a navigable report pack

$orders = Import-OfficeCsv -Path .\Data\Q3-Orders.csv
New-OfficeExcel -Path .\Reports\Q3-Regions.xlsx {
    foreach ($group in $orders | Group-Object Region) {
        ExcelSheet $group.Name {
            ExcelTable $group.Group -Address A3
        }
    }
    ExcelTableOfContents -Name 'Contents' -BackLink -BackLinkAddress A1 -BackLinkText 'Back to contents'
}

Writes one sheet per region, then adds a contents sheet with links and a back link on each regional sheet.

Parameters

Adds a link from each listed worksheet back to the table of contents.
-BackLinkAddress String optional
A1 destination for worksheet back links; omission chooses an unused cell.
-BackLinkText String optional
Text used for back links.
-Document ExcelDocument optionalpipeline: True (ByValue)
Caller-owned workbook; omission uses the enclosing Excel content block.
-IncludeHiddenNamedRanges SwitchParameter optional
Include hidden named ranges when listing named ranges.
-IncludeNamedRanges SwitchParameter optional
Include named ranges in the TOC.
-Name String optional
Named range name.
Disable internal hyperlinks in the TOC sheet.
-NoMoveFirst SwitchParameter optional
Keeps the table-of-contents worksheet at its current position.
-NoStyle SwitchParameter optional
Disable formatted TOC styling.
-PassThru SwitchParameter optional
Emits the native result after the operation.

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.