mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-22 11:13:32 +00:00
Added -FirstDataRow and updated examples
This commit is contained in:
@@ -10,4 +10,4 @@ $header = echo `
|
|||||||
'Total Radiated Energy (J)' `
|
'Total Radiated Energy (J)' `
|
||||||
'Calculated Total Impact Energy (kt)'
|
'Calculated Total Impact Energy (kt)'
|
||||||
|
|
||||||
Import-Html http://neo.jpl.nasa.gov/fireballs/ 5 -Header $header
|
Import-Html http://neo.jpl.nasa.gov/fireballs/ 5 -Header $header -FirstDataRow 1
|
||||||
@@ -3,7 +3,8 @@ function Get-HtmlTable {
|
|||||||
[Parameter(Mandatory=$true)]
|
[Parameter(Mandatory=$true)]
|
||||||
$url,
|
$url,
|
||||||
$tableIndex=0,
|
$tableIndex=0,
|
||||||
$Header
|
$Header,
|
||||||
|
[int]$FirstDataRow=0
|
||||||
)
|
)
|
||||||
|
|
||||||
$r = Invoke-WebRequest $url
|
$r = Invoke-WebRequest $url
|
||||||
@@ -11,7 +12,7 @@ function Get-HtmlTable {
|
|||||||
$propertyNames=$Header
|
$propertyNames=$Header
|
||||||
$totalRows=@($table.rows).count
|
$totalRows=@($table.rows).count
|
||||||
|
|
||||||
for ($idx = 1; $idx -lt $totalRows; $idx++) {
|
for ($idx = $FirstDataRow; $idx -lt $totalRows; $idx++) {
|
||||||
|
|
||||||
$row = $table.rows[$idx]
|
$row = $table.rows[$idx]
|
||||||
$cells = @($row.cells)
|
$cells = @($row.cells)
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ function Import-Html {
|
|||||||
param(
|
param(
|
||||||
$url,
|
$url,
|
||||||
$index,
|
$index,
|
||||||
$Header
|
$Header,
|
||||||
|
[int]$FirstDataRow=0
|
||||||
)
|
)
|
||||||
|
|
||||||
$xlFile = [System.IO.Path]::GetTempFileName() -replace "tmp","xlsx"
|
$xlFile = [System.IO.Path]::GetTempFileName() -replace "tmp","xlsx"
|
||||||
@@ -12,7 +13,7 @@ function Import-Html {
|
|||||||
|
|
||||||
Write-Verbose "Exporting to Excel file $($xlFile)"
|
Write-Verbose "Exporting to Excel file $($xlFile)"
|
||||||
|
|
||||||
$data = Get-HtmlTable -url $url -tableIndex $index -Header $Header
|
$data = Get-HtmlTable -url $url -tableIndex $index -Header $Header -FirstDataRow $FirstDataRow
|
||||||
|
|
||||||
$data | Export-Excel $xlFile -Show -AutoSize
|
$data | Export-Excel $xlFile -Show -AutoSize
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user