86 Commits

Author SHA1 Message Date
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
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
John Boyne
b8a8f4c565 Add missing parameter aliases to align with caller/callee 2023-10-11 20:36:26 +01:00
dfinke
23f1d92c1b first pass 2023-06-10 15:27:53 -04:00
dfinke
840870df11 Resolve conflict 2022-12-28 14:26:43 -05:00
Thomas Hofkens
16820a30c4 Add -NoHyperLinkConversion 2022-12-26 01:22:22 +01:00
Thomas Hofkens
438d7e2b03 Fix Issue 1344 2022-12-25 23:44:21 +01:00
dfinke
3c23a064bc Add -ShowOnlyIcon to New-ConditionalFormattingIconSet. Base on https://github.com/dfinke/ImportExcel/discussions/1340 2022-12-10 18:22:36 -05:00
Thomas Hofkens
828b2caf9f Implement Set Column by range in Add-ExcelTable + simplify adding table from Export-Excel 2022-11-14 17:32:39 +01:00
Thomas Hofkens
f760b63818 Update Set-CellComment to use 'Range' parameter + Create tests file 2022-11-14 17:31:36 +01:00
Thomas Hofkens
ce49038b75 Changed TotalSettings to TableTotalSettings + Changed the way custom formulas are added + added possibility to add comments tot totals row 2022-11-12 00:25:56 +01:00
Thomas Hofkens
652a611137 Added new function 'Set-CellComment' 2022-11-12 00:24:17 +01:00
Thomas Hofkens
f494635b48 Added custom formula for totals row + Example File 2022-11-09 11:35:19 +01:00
Thomas Hofkens
9f4307f6c0 Add TotalSettings parameter to Export-Excel 2022-11-04 15:05:28 +01:00
Stephen Brown
c1be6a8d82 Merge branch 'dfinke:master' into master 2022-10-18 09:51:53 +01:00
dfinke
201b9cd984 Add Sheet visibility property 2022-10-15 19:34:58 -04:00
Stephen Brown
4bd3efa1ef Set Validate Range for rows to max rows available
$StartRow parameter had ValidateRange(1,9999) which was limiting the start row to a maximum of 9999. There's no good reason this cannot be any row in the spreadsheet, of which the maximum is 1048576 in modern instances of Excel.
2022-10-14 19:00:42 +01:00
Wes Stahler
be1e55cf8d Update Export-Excel.ps1
Fixed case on -BarChart switch.
2022-10-11 16:18:16 -04:00
WilsonStewart
6322bafaed Fixed typo of 'pararameter' to 'parameter' 2022-09-21 16:25:40 -06:00
Jeremiah Adams
fcde64780e Update Add-Worksheet.ps1 - 'worsheet' to 'worksheet' in warnings 2022-09-15 09:04:08 -05:00
g-pearl
fa4f3a23cd Update Bottom Spelling Error 2022-08-24 08:54:36 -06:00
James O'Neill
37e6896741 Merge branch 'dfinke:master' into PivotTableUpdates 2022-07-14 20:27:59 +01:00
James O'Neill
5ab9d6f23f Add column to GroupNumeric/Date in PivotTables. 2022-07-14 17:43:55 +01:00
dfinke
f2544ed1ec Fix -UnderLineType parameter is ignored in Set-ExcelColumn #1204 2022-07-04 10:29:39 -04:00
dfinke
f0a2d076e3 Update Import-Html with better defaults 2022-06-17 11:38:19 -04:00
James O'Neill
701b8e2062 Fix Get-HTMLTable for .NET core 2022-06-17 09:42:36 +01:00
dfinke
ab56ae4409 Add additional tests 2022-06-12 10:42:16 -04:00
dfinke
ef35c4fca8 Fix for EndRow and EndColumn Parameters Ignored in Import-Excel #1194 2022-06-12 09:53:52 -04:00
dfinke
4fa34ae257 Rename switch NotAsDictionary to Raw 2022-05-04 18:33:19 -04:00
dfinke
aea90aa8d6 Fix reading multiple sheets in the xlsx where row/col count is diff 2022-05-03 17:53:58 -04:00
dfinke
964cf9e9c6 Merge branch 'master' of https://github.com/dfinke/ImportExcel into add-helper-functions 2022-04-30 08:21:18 -04:00
dfinke
61b44f826d Merge branch 'master' of https://github.com/dfinke/ImportExcel into adding-to-import-excel 2022-04-30 07:25:58 -04:00
dfinke
b634bf9d93 Fix fir #1172 2022-04-29 20:39:51 -04:00
dfinke
eb10364722 Add helpers 2022-04-28 19:44:49 -04:00
dfinke
7f36b44fa8 renamed to NotAsDictionary 2022-04-12 18:08:11 -04:00
dfinke
483f761016 Add switch to not return data as a dictionary 2022-04-12 18:03:34 -04:00
dfinke
d55f0e64d4 WIP - Add sheets and contents to a hashtable 2022-04-11 18:48:17 -04:00
dfinke
f83f654c4a Update how Import-Excel reads sheets, and remain backward compatible 2022-04-11 16:58:55 -04:00
James Mueller
96493e059b ConvertFrom-ExcelToSQLInsert fix single quotes
If data in the Excel file contains single quotes, then the insert will bomb as it will be malformed. Quotes would need escaped. Not all languages will support the same escape method, so I recommend it being set by an optional parameter.

Example of what will fail:
  Name
  -----------
  Fry's

INSERT INTO [Name] Values ( 'Fry's' ) 

Corrected for quotes (such as needing to escape a single quote with an additional single quote)

INSERT INTO [Name] Values ('Fry''s') 


Example code:
$ConvertToSqlParams = @{TableName = ‘dbo.Names’
Path = ‘C:\temp\data.xlsx’
ConvertEmptyStringsToNull = $true
UseMSSQLSyntax = $true
SingleQuoteStyle = "''"
}

$SQLInsert = ConvertFrom-ExcelToSqlInsert @ConvertToSqlParams
2022-03-11 16:09:38 -06:00
dfinke
aa1b042767 Add -ReZip to Close-ExcelPackage like in Export-Excel #1111 2021-11-30 15:50:11 -05:00
dfinke
536cdaa841 tweaked spelling 2021-11-20 15:53:23 -05:00
Doug Finke
829d854c3d Merge pull request #1102 from muschebubusche/AddSelectiveColumnImport
Add selective column import
2021-11-20 15:36:05 -05:00
muschebubusche
73fc96166c Refactor selective column import
Move code into the function Get-PropertyNames and remove the rest.
Now it only replaces $Columns with $ImportColumns after a couple of checks. So the heavy work like arranging and getting the right values is done in the original way of Import-Excel.
2021-11-20 16:51:40 +01:00
muschebubusche
8f0fc7397d Add example and automatic column arrangement
Add example and automatic column arrangement
2021-11-09 22:40:40 +01:00
Roy Ashbrook
4fa6fbda01 update warning msg for Read-OleDbData 2021-11-09 09:05:15 -05:00
Roy Ashbrook
ae31e9d39b update skip/help msgs in invoke cmd 2021-11-08 18:08:45 -05:00
Roy Ashbrook
eabaab79c5 add ace check 2021-11-08 14:43:57 -05:00
Roy Ashbrook
7a8bbb9771 add to exported functions, formatting, fix typo. 2021-11-04 20:54:51 -04:00