Project

PSWriteOffice

PowerShell document automation across OfficeIMO's document, spreadsheet, presentation, PDF, Project, Access, EPUB, invoicing, and conversion engines.

Stars 654
Forks 82
Open issues 1
Total downloads 4,320,051
Release OfficeIMO-v3.5.3
Language: C# Updated: 2026-11-03
Cmdlet

Get-OfficeExcelUsedRange

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

Reads the used range from an Excel workbook.

Syntax

Get-OfficeExcelUsedRange
[-AsDataTable]
[-AsHashtable]
[-HeadersInFirstRow <Boolean>]
[-NumericAsDecimal]
[-Path] <String>
[-Sheet <String>]
[-SheetIndex <Int32>]
[<CommonParameters>]
#
Parameter set: Path
Get-OfficeExcelUsedRange
[-AllowHttp]
[-AsDataTable]
[-AsHashtable]
[-HeadersInFirstRow <Boolean>]
[-NumericAsDecimal]
[-Sheet <String>]
[-SheetIndex <Int32>]
[-Uri] <Uri>
[<CommonParameters>]
#
Parameter set: Uri
Get-OfficeExcelUsedRange
[-AsDataTable]
[-AsHashtable]
-Document <ExcelDocument>
[-HeadersInFirstRow <Boolean>]
[-NumericAsDecimal]
[-Sheet <String>]
[-SheetIndex <Int32>]
[<CommonParameters>]
#
Parameter set: Document

Description

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

Examples

Read the used range and produce a quick status count.

$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.

Parameters

-AsDataTable SwitchParameter optional
Emit the raw DataTable instead of row objects.
-AsHashtable SwitchParameter optional
Emit rows as hashtables instead of PSCustomObjects.
-HeadersInFirstRow Boolean optional
Use the first row as column headers.
-NumericAsDecimal SwitchParameter optional
Prefer decimals instead of doubles for numeric values.
-Path String requiredposition: 0aliases: FilePath, InputPathsets: Path
Path to the workbook.
-Sheet String optional
Worksheet name to read; defaults to the first sheet.
-SheetIndex Int32 optional
Zero-based worksheet index to read; defaults to the first sheet.
-AllowHttp SwitchParameter optionalsets: Uri
Allow HTTP workbook downloads in addition to HTTPS.
-Uri Uri requiredposition: 0aliases: Urlsets: Uri
Remote workbook URI to read.
-Document ExcelDocument requiredpipeline: True (ByValue)sets: Document
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.