Compare commits

..

10 Commits

Author SHA1 Message Date
Doug Finke
09f35b5fd5 Merge pull request #1078 from dfinke/Add-Checks-And-Warnings-for-Add-Member-Open-Excel-Package
Add-Checks-And-Warnings-for-Add-Member-Open-Excel-Package
2021-09-14 18:15:47 -04:00
dfinke
23a2ac394f Add try/catch, warning, and tests 2021-09-14 15:44:32 -04:00
dfinke
50928e8e3b Update 2021-09-14 15:44:11 -04:00
dfinke
26827b0764 bump version 2021-09-14 15:44:03 -04:00
Doug Finke
6c35d5b018 Updated 2021-09-10 18:41:03 -04:00
Doug Finke
ab5600c9ba bump version 2021-09-10 18:40:57 -04:00
Doug Finke
47dcc636d9 Merge pull request #1077 from stahler/Open-ExcelPackage
Update open-excelpackage.md
2021-09-10 18:39:00 -04:00
Stahler
1768c0ac92 Update open-excelpackage.md 2021-09-10 14:17:44 -04:00
Doug Finke
694fcdd8c1 Merge pull request #1059 from dfinke/add-test-for-ps-5-to-7-and-linux
Improved checks for Linux, Mac and PS 5.1 - #1056, #1057
2021-07-30 19:27:06 -04:00
dfinke
0192f4d822 Improved checks for Linux, Mac and PS 5.1 - #1056, #1057 2021-07-30 19:21:37 -04:00
7 changed files with 86 additions and 35 deletions

View File

@@ -6,7 +6,7 @@
RootModule = 'ImportExcel.psm1'
# Version number of this module.
ModuleVersion = '7.2.1'
ModuleVersion = '7.3.0'
# ID used to uniquely identify this module
GUID = '60dd4136-feff-401a-ba27-a84458c57ede'

View File

@@ -35,7 +35,12 @@
if ($pkgobj) {
foreach ($w in $pkgobj.Workbook.Worksheets) {
$sb = [scriptblock]::Create(('$this.workbook.Worksheets["{0}"]' -f $w.name))
Add-Member -InputObject $pkgobj -MemberType ScriptProperty -Name $w.name -Value $sb
try {
Add-Member -InputObject $pkgobj -MemberType ScriptProperty -Name $w.name -Value $sb -ErrorAction Stop
}
catch {
Write-Warning "Could not add sheet $($w.name) as 'short cut', you need to access it via `$wb.Worksheets['$($w.name)'] "
}
}
return $pkgobj
}

View File

@@ -1,3 +1,4 @@
#Requires -Version 5
function Read-Clipboard {
<#
.SYNOPSIS
@@ -22,9 +23,11 @@ function Read-Clipboard {
$Header
)
if ($IsWindows) {
$osInfo = Get-CimInstance -ClassName Win32_OperatingSystem
if ($osInfo.ProductType -eq 1) {
if ($IsLinux -or $IsMacOS) {
Write-Error "Read-Clipboard only runs on Windows"
return
}
$cvtParams = @{
Data = Get-Clipboard -Raw
}
@@ -39,14 +42,6 @@ function Read-Clipboard {
ReadClipboardImpl @cvtParams
}
else {
Write-Error "This command is only supported on the desktop."
}
}
else {
Write-Error "This function is only available on Windows desktop"
}
}
function ReadClipboardImpl {
param(

View File

@@ -0,0 +1,39 @@
#Requires -Modules Pester
if (-not (Get-command Import-Excel -ErrorAction SilentlyContinue)) {
Import-Module $PSScriptRoot\..\ImportExcel.psd1
}
<#
Methods
-------
Dispose
Equals
GetAsByteArray
GetHashCode
GetType
Load
Save
SaveAs
ToString
Properties
----------
Compatibility
Compression
DoAdjustDrawings
Encryption
File
Package
Stream
Workbook
#>
Describe "Test Open Excel Package" -Tag Open-ExcelPackage {
It "Should handle opening a workbook with Worksheet Names that will cause errors" {
$xlFilename = "$PSScriptRoot\UnsupportedWorkSheetNames.xlsx"
{ Open-ExcelPackage -Path $xlFilename -ErrorAction Stop } | Should -Not -Throw
}
}

Binary file not shown.

View File

@@ -1,7 +1,19 @@
# v7.3.0
- Fix throwing error when a Worksheet name collides with a method, or property name on the `OfficeOpenXml.ExcelPackage` package
# v7.2.3
- Fix inline help, thank you [Wes Stahler](https://github.com/stahler)
# v7.2.2
- Improved checks for Linux, Mac and PS 5.1
# v7.2.1
- Improve auto-detection of data on the clipboard
# v7.2.0
- Added `Read-Clipboard` support for Windows. Read text from clipboard. It can read CSV or JSON. Plus, you can specify the delimiter and headers.

View File

@@ -9,7 +9,7 @@ schema: 2.0.0
## SYNOPSIS
Returns an ExcelPackage object for the specified XLSX fil.e
Returns an ExcelPackage object for the specified XLSX file.
## SYNTAX