mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-10 13:23:29 +00:00
Added -FirstDataRow and updated examples
This commit is contained in:
@@ -10,4 +10,4 @@ $header = echo `
|
||||
'Total Radiated Energy (J)' `
|
||||
'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)]
|
||||
$url,
|
||||
$tableIndex=0,
|
||||
$Header
|
||||
$Header,
|
||||
[int]$FirstDataRow=0
|
||||
)
|
||||
|
||||
$r = Invoke-WebRequest $url
|
||||
@@ -11,7 +12,7 @@ function Get-HtmlTable {
|
||||
$propertyNames=$Header
|
||||
$totalRows=@($table.rows).count
|
||||
|
||||
for ($idx = 1; $idx -lt $totalRows; $idx++) {
|
||||
for ($idx = $FirstDataRow; $idx -lt $totalRows; $idx++) {
|
||||
|
||||
$row = $table.rows[$idx]
|
||||
$cells = @($row.cells)
|
||||
|
||||
@@ -4,7 +4,8 @@ function Import-Html {
|
||||
param(
|
||||
$url,
|
||||
$index,
|
||||
$Header
|
||||
$Header,
|
||||
[int]$FirstDataRow=0
|
||||
)
|
||||
|
||||
$xlFile = [System.IO.Path]::GetTempFileName() -replace "tmp","xlsx"
|
||||
@@ -12,7 +13,7 @@ function Import-Html {
|
||||
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user