Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

Import-OfficeExcel

Module
PSWriteOffice
Inputs
OfficeIMO.Excel.ExcelDocument System.String[]

Reads rows from a worksheet, range or table as objects.

Syntax

Import-OfficeExcel
[-As <Object|Hashtable|DataTable|DataReader|Column>]
[-ChunkRows <Int32>]
[-Culture <CultureInfo>]
[-Document <ExcelDocument>]
[-FormulaMode <CachedValue|FormulaText>]
[-NoHeader]
[-NumericAsDecimal]
[-Range <String>]
[-SchemaSampleRows <Int32>]
[-Sheet <OfficeSheetSelector[]>]
[<CommonParameters>]
#
Parameter set: Document
Import-OfficeExcel
[-As <Object|Hashtable|DataTable|DataReader|Column>]
[-ChunkRows <Int32>]
[-Culture <CultureInfo>]
[-FormulaMode <CachedValue|FormulaText>]
[-NoHeader]
[-NumericAsDecimal]
[-Path] <String[]>
[-Range <String>]
[-SchemaSampleRows <Int32>]
[-Sheet <OfficeSheetSelector[]>]
[<CommonParameters>]
#
Parameter set: Path
Import-OfficeExcel
[-As <Object|Hashtable|DataTable|DataReader|Column>]
[-ChunkRows <Int32>]
[-Culture <CultureInfo>]
[-FormulaMode <CachedValue|FormulaText>]
[-NoHeader]
[-NumericAsDecimal]
[-Path] <String[]>
[-SchemaSampleRows <Int32>]
-Table <String>
[<CommonParameters>]
#
Parameter set: PathTable
Import-OfficeExcel
[-As <Object|Hashtable|DataTable|DataReader|Column>]
[-ChunkRows <Int32>]
[-Culture <CultureInfo>]
[-FormulaMode <CachedValue|FormulaText>]
-LiteralPath <String[]>
[-NoHeader]
[-NumericAsDecimal]
[-Range <String>]
[-SchemaSampleRows <Int32>]
[-Sheet <OfficeSheetSelector[]>]
[<CommonParameters>]
#
Parameter set: LiteralPath
Import-OfficeExcel
[-AllowHttp]
[-AllowPrivateNetworkAddresses]
[-As <Object|Hashtable|DataTable|DataReader|Column>]
[-ChunkRows <Int32>]
[-Culture <CultureInfo>]
[-FormulaMode <CachedValue|FormulaText>]
[-NoHeader]
[-NumericAsDecimal]
[-Range <String>]
[-SchemaSampleRows <Int32>]
[-Sheet <OfficeSheetSelector[]>]
[-Uri] <Uri>
[<CommonParameters>]
#
Parameter set: Uri
Import-OfficeExcel
[-As <Object|Hashtable|DataTable|DataReader|Column>]
[-ChunkRows <Int32>]
[-Culture <CultureInfo>]
[-FormulaMode <CachedValue|FormulaText>]
-LiteralPath <String[]>
[-NoHeader]
[-NumericAsDecimal]
[-SchemaSampleRows <Int32>]
-Table <String>
[<CommonParameters>]
#
Parameter set: LiteralPathTable
Import-OfficeExcel
[-AllowHttp]
[-AllowPrivateNetworkAddresses]
[-As <Object|Hashtable|DataTable|DataReader|Column>]
[-ChunkRows <Int32>]
[-Culture <CultureInfo>]
[-FormulaMode <CachedValue|FormulaText>]
[-NoHeader]
[-NumericAsDecimal]
[-SchemaSampleRows <Int32>]
-Table <String>
[-Uri] <Uri>
[<CommonParameters>]
#
Parameter set: UriTable
Import-OfficeExcel
[-As <Object|Hashtable|DataTable|DataReader|Column>]
[-ChunkRows <Int32>]
[-Culture <CultureInfo>]
[-Document <ExcelDocument>]
[-FormulaMode <CachedValue|FormulaText>]
[-NoHeader]
[-NumericAsDecimal]
[-SchemaSampleRows <Int32>]
-Table <String>
[<CommonParameters>]
#
Parameter set: DocumentTable

Examples

Read the first sheet as objects

Import-OfficeExcel -Path .\Reports\Q3-Sales.xlsx

Reads the used range of the first worksheet, using the header row as property names.

Find the largest open orders

Import-OfficeExcel -Path .\Reports\Q3-Sales.xlsx -Sheet Orders -Range A5 |
                Where-Object Status -eq 'Open' |
                Sort-Object Amount -Descending |
                Select-Object -First 10 OrderId, Customer, Region, Amount

Reads the Orders sheet from row 5, where the header starts below a title block, and lists the ten largest open orders.

Read a named table

Import-OfficeExcel -Path .\Reports\Helpdesk.xlsx -Table Tickets |
                Where-Object Status -ne 'Closed' |
                Group-Object Assignee |
                Sort-Object Count -Descending |
                Select-Object Name, Count

Reads the rows of the Tickets table wherever it sits in the workbook and counts open tickets per assignee.

Combine every sheet of many workbooks

Get-ChildItem -Path .\Branches -Filter *.xlsx |
                Import-OfficeExcel -Sheet * |
                Export-OfficeExcel -Path .\Reports\All-Branches.xlsx -Sheet 'All branches' -Title 'Branch sales, October 2026'

Reads every worksheet of each branch workbook (each row carries its WorksheetName) and writes one consolidated workbook.

Parameters

-As ExcelImportOutput optional
Selects objects, hashtables, a DataTable, an owned IDataReader or column output.
Possible values: Object, Hashtable, DataTable, DataReader, Column
-ChunkRows Int32 optional
Worksheet row count requested from each streaming chunk when -As DataReader is used.
-Culture CultureInfo optional
Culture used for value conversion and number-format presets.
-Document ExcelDocument optionalpipeline: True (ByValue)sets: Document, DocumentTable
Caller-owned workbook; omission uses the enclosing Excel content block.
-FormulaMode OfficeExcelFormulaMode optional
Formula read mode. CachedValue returns workbook cached results; FormulaText returns formula expressions when present.
Possible values: CachedValue, FormulaText
-NoHeader SwitchParameter optional
Writes data without a header row.
-NumericAsDecimal SwitchParameter optional
Prefer decimals instead of doubles for numeric values.
-Range String optionalsets: Document, Path, LiteralPath, Uri
A1 cell range on the selected worksheet.
-SchemaSampleRows Int32 optional
Maximum row count inspected when -As DataReader infers the reader schema.
-Sheet OfficeSheetSelector[] optionalaliases: WorksheetNamesets: Document, Path, LiteralPath, Uri
Worksheet name, one-based position or native worksheet object. Native worksheet objects need -Document or an enclosing Excel content block. Multi-sheet commands also accept wildcard names.
-Path String[] requiredposition: 0pipeline: True (ByValue)aliases: FilePathsets: Path, PathTable
Workbook paths resolved with filesystem wildcard support.
-Table String requiredsets: PathTable, LiteralPathTable, UriTable, DocumentTable
Native Excel table used to resolve the source range or header.
-LiteralPath String[] requiredpipeline: True (ByPropertyName)aliases: FullName, PSPathsets: LiteralPath, LiteralPathTable
Literal workbook paths, including FileInfo.FullName and provider PSPath.
-AllowHttp SwitchParameter optionalsets: Uri, UriTable
Allow HTTP workbook downloads in addition to HTTPS.
-AllowPrivateNetworkAddresses SwitchParameter optionalsets: Uri, UriTable
Allow a workbook on a loopback, private, link-local or other non-public network address. Use only for trusted internal sources.
-Uri Uri requiredposition: 0sets: Uri, UriTable
Remote workbook URI to import.

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.