Cmdlet
Get-OfficeExcelRange
Reads an explicit A1 range from an Excel workbook.
Syntax
Get-OfficeExcelRange
[-AsDataTable]
[-AsHashtable]
[-HeadersInFirstRow <Boolean>]
[-NumericAsDecimal]
[-Path] <String>
-Range <String>
[-Sheet <String>]
[-SheetIndex <Int32>]
[<CommonParameters>]#Parameter set:
PathGet-OfficeExcelRange
[-AllowHttp]
[-AsDataTable]
[-AsHashtable]
[-HeadersInFirstRow <Boolean>]
[-NumericAsDecimal]
-Range <String>
[-Sheet <String>]
[-SheetIndex <Int32>]
[-Uri] <Uri>
[<CommonParameters>]#Parameter set:
UriGet-OfficeExcelRange
[-AsDataTable]
[-AsHashtable]
-Document <ExcelDocument>
[-HeadersInFirstRow <Boolean>]
[-NumericAsDecimal]
-Range <String>
[-Sheet <String>]
[-SheetIndex <Int32>]
[<CommonParameters>]#Parameter set:
DocumentDescription
Returns rows as PSCustomObjects by default, with optional hashtable or DataTable output for scripting and interoperability.
Examples
Read a rectangular range and summarize revenue.
$rows = Get-OfficeExcelRange -Path .\report.xlsx -Sheet Data -Range A1:C10 -NumericAsDecimal
$rows |
Group-Object -Property Region |
Select-Object Name, CountUses the first row as headers, returns row objects, and keeps numeric values decimal-friendly.
Parameters
- -AsDataTable SwitchParameter
- Emit the raw DataTable instead of row objects.
- -AsHashtable SwitchParameter
- Emit rows as hashtables instead of PSCustomObjects.
- -HeadersInFirstRow Boolean
- Use the first row as column headers.
- -NumericAsDecimal SwitchParameter
- Prefer decimals instead of doubles for numeric values.
- -Path String
- Path to the workbook.
- -Range String
- A1 range to read.
- -Sheet String
- Worksheet name to read; defaults to the first sheet.
- -SheetIndex Int32
- Zero-based worksheet index to read; defaults to the first sheet.
- -AllowHttp SwitchParameter
- Allow HTTP workbook downloads in addition to HTTPS.
- -Uri Uri
- Remote workbook URI to read.
- -Document ExcelDocument
- Workbook to inspect.
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.