Compare commits

...

39 Commits

Author SHA1 Message Date
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
Doug Finke
74cbca8b2f Merge pull request #1591 from pbossman/master
Resolve worksheet ArgumentCompleter Fixes:#1590
2024-05-03 13:50:52 -04:00
Doug Finke
53712d4f7f bump version 2024-05-03 13:46:19 -04:00
Doug Finke
98e2ac96ea update changelog and add image 2024-05-03 13:46:02 -04:00
Phil Bossman
efa73b37a0 Resolve worksheet argumentcompleter Fixes:#1590 2024-04-30 11:59:08 -04:00
Doug Finke
c1b395fac6 Merge pull request #1578 from RipFence/ChartDataSeparateBranch
ChartDataSeparatePage.ps1
2024-03-15 08:24:32 -04:00
dfinke
0d8d125222 Add infrastructure change and new features 2024-03-15 08:21:17 -04:00
dfinke
f77ee7b060 Ignore Examples folder in CI workflow 2024-03-15 08:21:07 -04:00
Tim Kremer
8ff1757c06 ChartDataSeparatePage.ps1 2024-03-14 13:33:49 -05:00
dfinke
ab526558a3 more badges 2023-12-27 16:00:40 -05:00
Doug Finke
61744012cd Merge pull request #1522 from kyllath/master
Add missing parameter aliases to align with caller/callee
2023-10-12 17:16:46 -04:00
dfinke
2cb4712bc5 bump version 2023-10-12 17:10:00 -04:00
dfinke
6847a49baa update log 2023-10-12 17:09:56 -04:00
John Boyne
b8a8f4c565 Add missing parameter aliases to align with caller/callee 2023-10-11 20:36:26 +01:00
Doug Finke
edf25cf946 Merge pull request #1465 from dfinke/Extend-Get-Excel-File-Summary
Add Get-ExcelFileSchema
2023-06-14 05:54:11 -04:00
dfinke
77ec946b84 update changelog 2023-06-14 05:45:57 -04:00
dfinke
637c11c2e6 needs to work xplat 2023-06-10 16:40:25 -04:00
dfinke
cd2a70197c use -BeExactly 2023-06-10 16:00:11 -04:00
dfinke
d99bd8fc9e add tests 2023-06-10 15:45:35 -04:00
dfinke
23f1d92c1b first pass 2023-06-10 15:27:53 -04:00
Doug Finke
ab4d03c984 Merge pull request #1392 from stahler/patch-7
minor spelling edit
2023-02-05 06:41:07 -05:00
Doug Finke
ca4dfb7040 Merge pull request #1391 from stahler/patch-6
minor syntax changes
2023-02-05 06:40:54 -05:00
Wes Stahler
a9eca05303 minor spelling edit 2023-02-04 22:16:22 -05:00
Wes Stahler
195efdea54 minor syntax changes 2023-02-04 22:04:08 -05:00
Doug Finke
24e5fccafe Merge pull request #1361 from dfinke/thkn-hofa-Issue1344
Fix Issue 1344 with Freeze Top Row
2022-12-28 15:58:09 -05:00
14 changed files with 5816 additions and 17 deletions

View File

@@ -3,8 +3,11 @@ on:
branches:
- master
- Set-up-GHA-CI/CD
paths-ignore:
- 'Examples/**'
pull_request:
jobs:
validate:

View File

@@ -0,0 +1,35 @@
$data = ConvertFrom-Csv @"
Region,State,Units,Price
West,Texas,927,923.71
North,Tennessee,466,770.67
East,Florida,520,458.68
East,Maine,828,661.24
West,Virginia,465,053.58
North,Missouri,436,235.67
South,Kansas,214,992.47
North,North Dakota,789,640.72
South,Delaware,712,508.55
"@
$xlfile = "$PSScriptRoot\spike.xlsx"
Remove-Item $xlfile -ErrorAction SilentlyContinue
$xlpkg = $data | Export-Excel $xlfile -WorksheetName Data -AutoNameRange -PassThru
$null = Add-Worksheet -ExcelPackage $xlpkg -WorksheetName Summary -Activate
$params = @{
Worksheet = $xlpkg.Summary
Title = "Sales by Region"
ChartType = 'ColumnClustered'
# XRange = "Data!A2:A10"
# YRange = "Data!C2:C10"
XRange = 'Data!Region'
YRange = 'Data!Units'
}
Add-ExcelChart @params
Close-ExcelPackage $xlpkg -Show

View File

@@ -6,7 +6,7 @@
RootModule = 'ImportExcel.psm1'
# Version number of this module.
ModuleVersion = '7.8.4'
ModuleVersion = '7.8.10'
# ID used to uniquely identify this module
GUID = '60dd4136-feff-401a-ba27-a84458c57ede'
@@ -54,6 +54,7 @@ Check out the How To Videos https://www.youtube.com/watch?v=U3Ne_yX4tYo&list=PL5
'Export-Excel',
'Export-ExcelSheet',
'Get-ExcelColumnName',
'Get-ExcelFileSchema',
'Get-ExcelFileSummary',
'Get-ExcelSheetDimensionAddress',
'Get-ExcelSheetInfo',
@@ -149,7 +150,7 @@ Check out the How To Videos https://www.youtube.com/watch?v=U3Ne_yX4tYo&list=PL5
Tags = @("Excel", "EPPlus", "Export", "Import")
# 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.
ProjectUri = "https://github.com/dfinke/ImportExcel"
@@ -214,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.
# DefaultCommandPrefix = ''
}
}

View File

@@ -67,9 +67,8 @@ function WorksheetArgumentCompleter {
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)
$xlPath = $fakeBoundParameter['Path']
if (Test-Path -Path $xlPath) {
$xlpkg = Open-ExcelPackage -ReadOnly -Path $xlPath
$WorksheetNames = $xlPkg.Workbook.Worksheets.Name
Close-ExcelPackage -nosave -ExcelPackage $xlpkg
$xlSheet = Get-ExcelSheetInfo -Path $xlPath
$WorksheetNames = $xlSheet.Name
$WorksheetNames.where( { $_ -like "*$wordToComplete*" }) | foreach-object {
New-Object -TypeName System.Management.Automation.CompletionResult -ArgumentList "'$_'",
$_ , ([System.Management.Automation.CompletionResultType]::ParameterValue) , $_

View File

@@ -8,7 +8,8 @@ function ConvertFrom-ExcelData {
[ScriptBlock]$ScriptBlock,
[Alias("Sheet")]
$WorksheetName = 1,
[int]$HeaderRow = 1,
[Alias('HeaderRow', 'TopRow')]
[int]$StartRow = 1,
[string[]]$Header,
[switch]$NoHeader,
[switch]$DataOnly

View File

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

View File

@@ -0,0 +1,47 @@
function Get-ExcelFileSchema {
<#
.SYNOPSIS
Gets the schema of an Excel file.
.DESCRIPTION
The Get-ExcelFileSchema function gets the schema of an Excel file by returning the property names of the first row of each worksheet in the file.
.PARAMETER Path
Specifies the path to the Excel file.
.PARAMETER Compress
Indicates whether to compress the json output.
.OUTPUTS
Json
.EXAMPLE
Get-ExcelFileSchema -Path .\example.xlsx
#>
[CmdletBinding()]
param(
[Parameter(ValueFromPipelineByPropertyName, Mandatory)]
[Alias('FullName')]
$Path,
[Switch]$Compress
)
Begin {
$result = @()
}
Process {
$excelFiles = Get-ExcelFileSummary $Path
foreach ($excelFile in $excelFiles) {
$data = Import-Excel $Path -WorksheetName $excelFile.WorksheetName | Select-Object -First 1
$names = $data[0].PSObject.Properties.name
$result += $excelFile | Add-Member -MemberType NoteProperty -Name "PropertyNames" -Value $names -PassThru
}
}
End {
$result | ConvertTo-Json -Compress:$Compress
}
}

View File

@@ -19,10 +19,13 @@ Consider donating. Thank you!
<br>
<br>
[![Build Status](https://dougfinke.visualstudio.com/ImportExcel/_apis/build/status/dfinke.ImportExcel?branchName=master)](https://dougfinke.visualstudio.com/ImportExcel/_build)
[![Follow on Twitter](https://img.shields.io/twitter/follow/dfinke.svg?style=social&label=Follow%20%40dfinke)](https://twitter.com/dfinke)
[![Subscribe on YouTube](https://img.shields.io/youtube/channel/subscribers/UCP47ZkO5EDkoI2sr-3P4ShQ
)](https://youtube.com/@dougfinke/)
<br/>
<br/>
[![](https://img.shields.io/powershellgallery/v/ImportExcel.svg)](https://www.powershellgallery.com/packages/ImportExcel)
[![](https://img.shields.io/powershellgallery/dt/ImportExcel.svg)](https://www.powershellgallery.com/packages/ImportExcel)
[![](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/dfinke/ImportExcel/tree/70ab9e46c776e96fb287682d5b9b4b51a0ec3bac/LICENSE.txt)
<a href="https://www.paypal.com/paypalme/DougCharlesFinke"><img src="https://img.shields.io/badge/Donate-PayPal-green.svg" alt="Donate"></a>
# Overview

View File

@@ -0,0 +1,54 @@
if (-not (Get-command Import-Excel -ErrorAction SilentlyContinue)) {
Import-Module $PSScriptRoot\..\ImportExcel.psd1
}
Describe "Test getting the schema of an Excel file" -Tag GetExcelFileSchema {
BeforeAll {
$script:excelFile = "TestDrive:\test.xlsx"
$data = ConvertFrom-Csv @"
Region,State,Units,Price
West,Texas,927,923.71
North,Tennessee,466,770.67
East,Florida,520,458.68
East,Maine,828,661.24
West,Virginia,465,053.58
North,Missouri,436,235.67
South,Kansas,214,992.47
North,North Dakota,789,640.72
South,Delaware,712,508.55
"@
$data | Export-Excel $excelFile
}
It "Test Get-ExcelFileSchema function exists" {
$function = Get-Command Get-ExcelFileSchema -ErrorAction SilentlyContinue
$function | Should -Not -Be $null
}
It "Test Get-ExcelFileSchema returns json" {
$actual = Get-ExcelFileSchema -Path $excelFile
$actual | Should -Not -Be $null
$actual | Should -BeOfType [string]
}
It "Test Get-ExcelFileSchema correct json" {
$actual = Get-ExcelFileSchema -Path $excelFile
$actual = $actual | ConvertFrom-Json
$actual.ExcelFile | Should -BeExactly "test.xlsx"
$actual.WorksheetName | Should -BeExactly "Sheet1"
$actual.Visible | Should -Be $true
$actual.Rows | Should -Be 10
$actual.Columns | Should -Be 4
$actual.Address | Should -BeExactly "A1:D10"
$actual.Path | Should -BeExactly ("TestDrive:" + [System.IO.Path]::DirectorySeparatorChar)
$actual.PropertyNames.Count | Should -Be 4
$actual.PropertyNames[0] | Should -BeExactly "Region"
$actual.PropertyNames[1] | Should -BeExactly "State"
$actual.PropertyNames[2] | Should -BeExactly "Units"
$actual.PropertyNames[3] | Should -BeExactly "Price"
}
}

View File

@@ -1,3 +1,60 @@
# 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
- Thanks to [Phil Bossman](https://github.com/pbossman) for the PR and fixing this.
Now, back again, you can type `Import-Excel .\yearlySales.xlsx`, press <ctrl+space> and get a list of the worksheets in the Excel file
![alt text](images/AutoCompleteSheetNames.png)
# Infrastructure change
- Thank you to [RipFence](https://github.com/RipFence) who asked how to place a chart on a different sheet from the data and then did a PR adding the example.
- added `ignore` so files checked into examples do not trigger a CI run
# 7.8.6
- Thank you [John Boyne](https://github.com/kyllath)
- Add missing parameter aliases to align with caller/callee
# 7.8.5
- Added `Get-ExcelFileSchema` to get the schema of an Excel file.
- This was added to support interacting with `ChatGPT`. Passing the schema to the `ChatGPT` via `PowerShellAI` let's you ask questions about the data including generating code based on the schema.
```powershell
Get-ExcelFileSchema .\salesData.xlsx
```
```json
{
"ExcelFile": "salesData.xlsx",
"WorksheetName": "Sheet1",
"Visible": true,
"Rows": 10,
"Columns": 4,
"Address": "A1:D10",
"Path": ".",
"PropertyNames": [
"Region",
"State",
"Units",
"Price"
]
}
```
# 7.8.x
Thanks to [Thomas Hofkens](https://github.com/thkn-hofa)

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

5592
llms-examples.txt Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -66,7 +66,7 @@ PS\> $excel = $avdata | Export-Excel -Path (Join-path $FilePath "\Machines.XLSX"
$excel.Save() ; $excel.Dispose()
```
Here Export-Excel is called with the -PassThru parameter, so the ExcelPackage object representing Machines.XLSX is stored in $Excel.The desired worksheet is selected, and then columns" B" and "I" are conditionally formatted \(excluding the top row\) to show red text if they contain "2003" or "Disabled" respectively.
Here Export-Excel is called with the -PassThru parameter, so the ExcelPackage object representing Machines.XLSX is stored in $Excel. The desired worksheet is selected, and then columns" B" and "I" are conditionally formatted \(excluding the top row\) to show red text if they contain "2003" or "Disabled" respectively.
A fixed date format is then applied to columns D to G, and the top row is formatted.
@@ -83,7 +83,7 @@ Again Export-Excel has been called with -PassThru leaving a package object in $E
This time B1:B100 has been conditionally formatted with 3 icons, using the "Flags" Icon-Set.
Add-ConditionalFormatting does not provide accessto every option in the formatting rule, so -PassThru has been used and the rule is modified to apply the flags in reverse order, and transitions between flags are set to 100 and 1000.
Add-ConditionalFormatting does not provide access to every option in the formatting rule, so -PassThru has been used and the rule is modified to apply the flags in reverse order, and transitions between flags are set to 100 and 1000.
### EXAMPLE 3

View File

@@ -81,7 +81,7 @@ PS\> $Excel = Invoke-Sum (Get-Process) Company Handles, PM, VirtualMemorySize |
The first line exports information to a table in new file; and captures the excel Package object in $Excel
The second line creates a chart on the first page of the work sheet, using the notation "TableName\[ColumnnName\]" to refer to the data, the labels come Name column in the table, and the data series from its PM and VirtualMemorySize columns. The display names for these in the header are set to 'PM' and 'VMSize'.
The second line creates a chart on the first page of the work sheet, using the notation "TableName\[ColumnName\]" to refer to the data, the labels come Name column in the table, and the data series from its PM and VirtualMemorySize columns. The display names for these in the header are set to 'PM' and 'VMSize'.
### EXAMPLE 4