Project

PSWriteOffice

PowerShell document automation across Word, Excel, PowerPoint, PDF, Reader, Confluence, Visio, and open text formats.

Stars 159
Forks 14
PowerShell Gallery downloads 158,661
Release v3.0.5
Language: C# Updated: 2026-09-03

API Reference

Cmdlet

Get-OfficeExcelRange

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

Reads an explicit A1 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

Read a rectangular range and summarize revenue.

PS>


$rows = Get-OfficeExcelRange -Path .\report.xlsx -Sheet Data -Range A1:C10 -NumericAsDecimal
            $rows |
                Group-Object -Property Region |
                Select-Object Name, Count
        

Uses the first row as headers, returns row objects, and keeps numeric values decimal-friendly.

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-OfficeExcelRange [-AsDataTable] [-AsHashtable] [-HeadersInFirstRow <Boolean>] [-NumericAsDecimal] -Path <String> -Range <String> [-Sheet <String>] [-SheetIndex <Int32>] [<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.
NumericAsDecimal SwitchParameter optionalposition: namedpipeline: False
Prefer decimals instead of doubles for numeric values.
Path String requiredposition: 0pipeline: Falsealiases: FilePath, InputPath
Path to the workbook.
Range String requiredposition: namedpipeline: False
A1 range to read.
Sheet String optionalposition: namedpipeline: False
Worksheet name to read; defaults to the first sheet.
SheetIndex Int32 optionalposition: namedpipeline: False
Zero-based worksheet index to read; defaults to the first sheet.

Outputs

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

Get-OfficeExcelRange [-AllowHttp] [-AsDataTable] [-AsHashtable] [-HeadersInFirstRow <Boolean>] [-NumericAsDecimal] -Range <String> [-Sheet <String>] [-SheetIndex <Int32>] -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.
Range String requiredposition: namedpipeline: False
A1 range to read.
Sheet String optionalposition: namedpipeline: False
Worksheet name to read; defaults to the first sheet.
SheetIndex Int32 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.Management.Automation.PSObject, System.Collections.Hashtable, System.Data.DataTable

Get-OfficeExcelRange [-AsDataTable] [-AsHashtable] -Document <ExcelDocument> [-HeadersInFirstRow <Boolean>] [-NumericAsDecimal] -Range <String> [-Sheet <String>] [-SheetIndex <Int32>] [<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.
Range String requiredposition: namedpipeline: False
A1 range to read.
Sheet String optionalposition: namedpipeline: False
Worksheet name to read; defaults to the first sheet.
SheetIndex Int32 optionalposition: namedpipeline: False
Zero-based worksheet index to read; defaults to the first sheet.

Outputs

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