API Reference

Cmdlet

Get-OfficeExcelUsedRange

Namespace PSWriteOffice
Inputs
OfficeIMO.Excel.ExcelDocument
Outputs
System.Collections.Hashtable System.Data.DataTable System.Management.Automation.PSObject

Reads the used range from an Excel workbook.

Remarks

Returns rows as PSCustomObjects by default, with optional hashtable or DataTable output for scripting and interoperability.

Examples

Authored help example

Example 1: Read the used range and produce a quick status count.

PS>


$rows = Get-OfficeExcelUsedRange -Path .\report.xlsx -Sheet Data
            $rows |
                Group-Object -Property Status |
                Select-Object -Property Name, Count
        

Reads the sheet's used range, treats the first row as headers, and summarizes a status column.

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

Get-OfficeExcelUsedRange [-AsDataTable] [-AsHashtable] [-HeadersInFirstRow <Boolean>] -InputPath <String> [-NumericAsDecimal] [-Sheet <String>] [-SheetIndex <Nullable`1>] [<CommonParameters>]
#
Parameter set: Path

Parameters

AsDataTable SwitchParameter optionalposition: namedpipeline: False
Emit the raw DataTable instead of row objects.
AsHashtable SwitchParameter optionalposition: namedpipeline: False
Emit rows as hashtables instead of PSCustomObjects.
HeadersInFirstRow Boolean optionalposition: namedpipeline: False
Use the first row as column headers.
InputPath String requiredposition: 0pipeline: Falsealiases: FilePath, Path
Path to the workbook.
NumericAsDecimal SwitchParameter optionalposition: namedpipeline: False
Prefer decimals instead of doubles for numeric values.
Sheet String optionalposition: namedpipeline: False
Worksheet name to read; defaults to the first sheet.
SheetIndex Nullable`1 optionalposition: namedpipeline: False
Zero-based worksheet index to read; defaults to the first sheet.

Outputs

System.Collections.Hashtable, System.Data.DataTable, System.Management.Automation.PSObject

Get-OfficeExcelUsedRange [-AllowHttp] [-AsDataTable] [-AsHashtable] [-HeadersInFirstRow <Boolean>] [-NumericAsDecimal] [-Sheet <String>] [-SheetIndex <Nullable`1>] -Uri <Uri> [<CommonParameters>]
#
Parameter set: Uri

Parameters

AllowHttp SwitchParameter optionalposition: namedpipeline: False
Allow HTTP workbook downloads in addition to HTTPS.
AsDataTable SwitchParameter optionalposition: namedpipeline: False
Emit the raw DataTable instead of row objects.
AsHashtable SwitchParameter optionalposition: namedpipeline: False
Emit rows as hashtables instead of PSCustomObjects.
HeadersInFirstRow Boolean optionalposition: namedpipeline: False
Use the first row as column headers.
NumericAsDecimal SwitchParameter optionalposition: namedpipeline: False
Prefer decimals instead of doubles for numeric values.
Sheet String optionalposition: namedpipeline: False
Worksheet name to read; defaults to the first sheet.
SheetIndex Nullable`1 optionalposition: namedpipeline: False
Zero-based worksheet index to read; defaults to the first sheet.
Uri Uri requiredposition: 0pipeline: Falsealiases: Url
Remote workbook URI to read.

Outputs

System.Collections.Hashtable, System.Data.DataTable, System.Management.Automation.PSObject

Get-OfficeExcelUsedRange [-AsDataTable] [-AsHashtable] -Document <ExcelDocument> [-HeadersInFirstRow <Boolean>] [-NumericAsDecimal] [-Sheet <String>] [-SheetIndex <Nullable`1>] [<CommonParameters>]
#
Parameter set: Document

Parameters

AsDataTable SwitchParameter optionalposition: namedpipeline: False
Emit the raw DataTable instead of row objects.
AsHashtable SwitchParameter optionalposition: namedpipeline: False
Emit rows as hashtables instead of PSCustomObjects.
Document ExcelDocument requiredposition: namedpipeline: True (ByValue)
Workbook to inspect.
HeadersInFirstRow Boolean optionalposition: namedpipeline: False
Use the first row as column headers.
NumericAsDecimal SwitchParameter optionalposition: namedpipeline: False
Prefer decimals instead of doubles for numeric values.
Sheet String optionalposition: namedpipeline: False
Worksheet name to read; defaults to the first sheet.
SheetIndex Nullable`1 optionalposition: namedpipeline: False
Zero-based worksheet index to read; defaults to the first sheet.

Outputs

System.Collections.Hashtable, System.Data.DataTable, System.Management.Automation.PSObject