Compare commits

..

17 Commits

Author SHA1 Message Date
Doug Finke
5387c06146 Merge pull request #1695 from scriptingstudio/master
[Get-HtmlTable] XPath optimization
2025-04-23 08:16:05 -04:00
Matthew Gray
45ed6a06dc [Get-HtmlTable] XPath optimization
```powershell
$rows =    $h.SelectNodes("//table[$TableIndex]//tr")
```
XPath selector in line 53 uses complex expression that can lead to unexpected result. The problem is that HtmlAgilityPack may have specific issues. In particular, on websites containing multiple tables this selector can find not one table. This is aggravated by the fact that tables can have different structures.
To avoid ambiguity this PR suggests to separate queries. Oneliner simplifies error checking
```powershell
$rows = try {
  $h.SelectSingleNode("//table[$TableIndex]").SelectNodes(".//tr")
} catch {}
if (-not $rows) {Write-Warning "Could not find rows for `"//table[$TableIndex]`" in $Url ."}
```
This expression doesn't even need testing, it just works.
2025-04-23 13:36:32 +03:00
dfinke
fa447a745c move llms text to root 2025-04-11 07:10:31 -04:00
dfinke
49affcfba7 add llms text of Examples directort for use in LLMs 2025-04-11 06:51:18 -04:00
dfinke
dc4a5e9db9 chore: Update changelog for version 7.8.10 and acknowledge PR contributions 2024-10-21 19:44:36 -04:00
Doug Finke
85e48acf36 Merge pull request #1648 from evenmartinsen/master
Remove flagged URL
2024-10-21 19:42:23 -04:00
dfinke
fb41d3de83 chore: Update module version to 7.8.10 2024-10-21 19:39:44 -04:00
dfinke
db84a59dd0 chore: Update module version to 7.8.10 2024-10-21 19:37:58 -04:00
Even Martinsen
5a61c5dda4 Re-add icon variable (Commented)
re-added variable for easier modification in the future.
2024-10-21 14:37:55 +02:00
Even Martinsen
a2bc50aeb0 Remove flagged URI
Removed due to various AV's flagging the link as malicious thus flagging and quarentining the module.
2024-10-21 14:35:50 +02:00
dfinke
fa907da4a4 chore: Update module version to 7.8.9 2024-05-18 09:41:57 -04:00
dfinke
24c205e65d feat: Improve ConvertTo-ExcelXlsx robustness
This commit improves the `ConvertTo-ExcelXlsx` function by making it more robust. Thanks to Edward Miller for the contribution.

Note: This message follows the established convention of starting with a type (feat for feature) and providing a concise and clear description of the changes made.
2024-05-18 09:41:50 -04:00
Doug Finke
a1418a336e Merge pull request #1603 from edwardmiller-mesirow/read-only
[ConvertTo-ExcelXlsx] open XLS as read-only
2024-05-18 09:37:38 -04:00
dfinke
63683db543 chore: Update module version to 7.8.8 2024-05-18 09:33:54 -04:00
Edward Miller
36b5495bd5 check for null first 2024-05-17 23:28:26 -05:00
Edward Miller
722516de7c use try-finally 2024-05-17 23:24:11 -05:00
Edward Miller
57bb049111 open XLS as read-only 2024-05-17 22:41:53 -05:00
5 changed files with 5622 additions and 9 deletions

View File

@@ -6,7 +6,7 @@
RootModule = 'ImportExcel.psm1' RootModule = 'ImportExcel.psm1'
# Version number of this module. # Version number of this module.
ModuleVersion = '7.8.7' ModuleVersion = '7.8.10'
# ID used to uniquely identify this module # ID used to uniquely identify this module
GUID = '60dd4136-feff-401a-ba27-a84458c57ede' GUID = '60dd4136-feff-401a-ba27-a84458c57ede'
@@ -150,7 +150,7 @@ Check out the How To Videos https://www.youtube.com/watch?v=U3Ne_yX4tYo&list=PL5
Tags = @("Excel", "EPPlus", "Export", "Import") Tags = @("Excel", "EPPlus", "Export", "Import")
# The web address of an icon which can be used in galleries to represent this module # The web address of an icon which can be used in galleries to represent this module
#IconUri = "http://pesterbdd.com/images/Pester.png" #IconUri =
# The web address of this module's project or support homepage. # The web address of this module's project or support homepage.
ProjectUri = "https://github.com/dfinke/ImportExcel" ProjectUri = "https://github.com/dfinke/ImportExcel"
@@ -215,4 +215,4 @@ Check out the How To Videos https://www.youtube.com/watch?v=U3Ne_yX4tYo&list=PL5
# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
# DefaultCommandPrefix = '' # DefaultCommandPrefix = ''
} }

View File

@@ -45,11 +45,18 @@ function ConvertTo-ExcelXlsx {
throw "Could not create Excel.Application ComObject. Please verify that Excel is installed." throw "Could not create Excel.Application ComObject. Please verify that Excel is installed."
} }
$Excel.Visible = $false try {
$null = $Excel.Workbooks.Open($xlsFile.FullName) $Excel.Visible = $false
$Excel.ActiveWorkbook.SaveAs($xlsxPath, $xlFixedFormat) $null = $Excel.Workbooks.Open($xlsFile.FullName, $null, $true)
$Excel.ActiveWorkbook.Close() $Excel.ActiveWorkbook.SaveAs($xlsxPath, $xlFixedFormat)
$Excel.Quit() }
finally {
if ($null -ne $Excel.ActiveWorkbook) {
$Excel.ActiveWorkbook.Close()
}
$Excel.Quit()
}
} }
} }

View File

@@ -50,7 +50,9 @@ function Get-HtmlTable {
else { else {
$h = ConvertFrom-Html -Content $r.Content $h = ConvertFrom-Html -Content $r.Content
if ($TableIndex -is [valuetype]) { $TableIndex += 1} if ($TableIndex -is [valuetype]) { $TableIndex += 1}
$rows = $h.SelectNodes("//table[$TableIndex]//tr") $rows = try {
$h.SelectSingleNode("//table[$TableIndex]").SelectNodes(".//tr")
} catch {}
if (-not $rows) {Write-Warning "Could not find rows for `"//table[$TableIndex]`" in $Url ."} if (-not $rows) {Write-Warning "Could not find rows for `"//table[$TableIndex]`" in $Url ."}
if ( -not $propertyNames) { if ( -not $propertyNames) {
if ( $tableHeaders = $rows[$FirstDataRow].SelectNodes("th")) { if ( $tableHeaders = $rows[$FirstDataRow].SelectNodes("th")) {

View File

@@ -1,3 +1,15 @@
# 7.8.10
- Thank you https://github.com/evenmartinsen for the PR to fix the AV
# 7.8.9
- Thanks to (Edward Miller)[https://github.com/edwardmiller-mesirow] for improving `ConvertTo-ExcelXlsx`and making it more robust
# 7.8.8
- Fix the release
# 7.8.7 # 7.8.7
- Thanks to [Phil Bossman](https://github.com/pbossman) for the PR and fixing this. - Thanks to [Phil Bossman](https://github.com/pbossman) for the PR and fixing this.

5592
llms-examples.txt Normal file

File diff suppressed because it is too large Load Diff