mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-10 21:33:16 +00:00
Styling Consistency & Punctuation
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
# How to Read an existing Excel File
|
# How to Read an Existing Excel File
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
Import-Module ImportExcel
|
Import-Module ImportExcel
|
||||||
@@ -10,7 +10,7 @@ $ExcelFile = Import-Excel "C:\Test\file.xlsx" -WorksheetName "Sheet1"
|
|||||||
The File C:\Test\file.xlsx contains
|
The File C:\Test\file.xlsx contains
|
||||||

|

|
||||||
|
|
||||||
After Loading this data into ```$ExcelFile``` the data is stored like:
|
After loading this data into ```$ExcelFile``` the data is stored like:
|
||||||

|

|
||||||
|
|
||||||
## Other Common Operations
|
## Other Common Operations
|
||||||
@@ -25,14 +25,14 @@ $SpecificColumn = $ExcelFile."anotherHeader" #loads column with the header "anot
|
|||||||
$SpecificRow = $ExcelFile[1] #Loads row at index 1. Index 1 is the first row instead of 0.
|
$SpecificRow = $ExcelFile[1] #Loads row at index 1. Index 1 is the first row instead of 0.
|
||||||
```
|
```
|
||||||
|
|
||||||
### Map Contents to Hashtable to interpret data
|
### Map Contents to Hashtable to Interpret Data
|
||||||
Sometimes mapping to a HashTable is more convenient to have access to common Hashtable operations. Enumerate a Hashtable with the row's data by:
|
Sometimes mapping to a Hashtable is more convenient to have access to common Hashtable operations. Enumerate a Hashtable with the row's data by:
|
||||||
```powershell
|
```powershell
|
||||||
$HashTable = @{}
|
$HashTable = @{}
|
||||||
$SpecificRow= $ExcelFile[2]
|
$SpecificRow= $ExcelFile[2]
|
||||||
$SpecificRow.psobject.properties | ForEach-Object {$HashTable[$_.Name] = $_.Value}
|
$SpecificRow.psobject.properties | ForEach-Object {$HashTable[$_.Name] = $_.Value}
|
||||||
```
|
```
|
||||||
To then iterate through the enumerated hash...
|
To then iterate through the enumerated Hashtable:
|
||||||
```powershell
|
```powershell
|
||||||
ForEach ($Key in ($HashTable.GetEnumerator()) | Where-Object {$_.Value -eq "x"}){ #Only grabs a key where the value is "x"
|
ForEach ($Key in ($HashTable.GetEnumerator()) | Where-Object {$_.Value -eq "x"}){ #Only grabs a key where the value is "x"
|
||||||
#values accessible with $Key.Name or $Key.Value
|
#values accessible with $Key.Name or $Key.Value
|
||||||
|
|||||||
Reference in New Issue
Block a user