Skip to content

Commit

Permalink
Merge pull request #668 from ili101/TestsRebase
Browse files Browse the repository at this point in the history
Tests improvments and Linux support
  • Loading branch information
dfinke authored Aug 29, 2019
2 parents a2b322d + 600d951 commit 29efd50
Show file tree
Hide file tree
Showing 42 changed files with 981 additions and 440 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ test.xlsx
testCCFMT.ps1
testHide.ps1
ImportExcel.zip
.vscode/launch.json
.vscode/settings.json

~$*
56 changes: 56 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "PowerShell",
"request": "launch",
"name": "PowerShell Pester Tests",
"script": "Import-Module -Name '.\\' -Force ; Invoke-Pester", // Change to '.\\ModuleName.psd1' if Git name different
"args": [""],
"cwd": "${workspaceFolder}"
},
{
"type": "PowerShell",
"request": "launch",
"name": "PowerShell Launch Current File",
"script": "${file}",
"args": [],
"cwd": "${file}"
},
{
"type": "PowerShell",
"request": "launch",
"name": "PowerShell Launch Current File in Temporary Console",
"script": "${file}",
"args": [],
"cwd": "${file}",
"createTemporaryIntegratedConsole": true
},
{
"type": "PowerShell",
"request": "launch",
"name": "PowerShell Launch Current File w/Args Prompt",
"script": "${file}",
"args": [
"${command:SpecifyScriptArgs}"
],
"cwd": "${file}"
},
{
"type": "PowerShell",
"request": "attach",
"name": "PowerShell Attach to Host Process",
"processId": "${command:PickPSHostProcess}",
"runspaceId": 1
},
{
"type": "PowerShell",
"request": "launch",
"name": "PowerShell Interactive Session",
"cwd": ""
}
]
}
File renamed without changes.
28 changes: 0 additions & 28 deletions DoTests.ps1

This file was deleted.

2 changes: 1 addition & 1 deletion Examples/TryMultiplePivotTablesFromOneSheet.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Import-Module ..\ImportExcel.psd1 -Force
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}

$file = "C:\Temp\test.xlsx"

Expand Down
2 changes: 1 addition & 1 deletion Export-StocksToExcel.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
$measure = "Open"
)

$xl = "$env:TEMP\Stocks.xlsx"
$xl = Join-Path ([IO.Path]::GetTempPath()) 'Stocks.xlsx'

Remove-Item $xl -ErrorAction SilentlyContinue

Expand Down
28 changes: 24 additions & 4 deletions ImportExcel.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Add-Type -Path "$($PSScriptRoot)\EPPlus.dll"
. $PSScriptRoot\AddDataValidation.ps1
. $PSScriptRoot\Charting.ps1
. $PSScriptRoot\ColorCompletion.ps1
. $PSScriptRoot\Compare-WorkSheet.ps1
. $PSScriptRoot\ConvertExcelToImageFile.ps1
. $PSScriptRoot\compare-workSheet.ps1
. $PSScriptRoot\ConvertFromExcelData.ps1
. $PSScriptRoot\ConvertFromExcelToSQLInsert.ps1
. $PSScriptRoot\ConvertToExcelXlsx.ps1
Expand All @@ -23,16 +23,17 @@ Add-Type -Path "$($PSScriptRoot)\EPPlus.dll"
. $PSScriptRoot\InferData.ps1
. $PSScriptRoot\Invoke-Sum.ps1
. $PSScriptRoot\Join-Worksheet.ps1
. $PSScriptRoot\Merge-worksheet.ps1
. $PSScriptRoot\Merge-Worksheet.ps1
. $PSScriptRoot\New-ConditionalFormattingIconSet.ps1
. $PSScriptRoot\New-ConditionalText.ps1
. $PSScriptRoot\New-ExcelChart.ps1
. $PSScriptRoot\New-PSItem.ps1
. $PSScriptRoot\Open-ExcelPackage.ps1
. $PSScriptRoot\Pivot.ps1
. $PSScriptRoot\PivotTable.ps1
#. $PSScriptRoot\Plot.ps1
. $PSScriptRoot\RemoveWorksheet.ps1
. $PSScriptRoot\Send-SqlDataToExcel.ps1
. $PSScriptRoot\Send-SQLDataToExcel.ps1
. $PSScriptRoot\Set-CellStyle.ps1
. $PSScriptRoot\Set-Column.ps1
. $PSScriptRoot\Set-Row.ps1
Expand All @@ -45,7 +46,7 @@ Add-Type -Path "$($PSScriptRoot)\EPPlus.dll"
New-Alias -Name Use-ExcelData -Value "ConvertFrom-ExcelData" -Force

if ($PSVersionTable.PSVersion.Major -ge 5) {
. $PSScriptRoot\plot.ps1
. $PSScriptRoot\Plot.ps1

Function New-Plot {
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseShouldProcessForStateChangingFunctions', '', Justification = 'New-Plot does not change system state')]
Expand All @@ -59,6 +60,25 @@ else {
Write-Warning 'PowerShell 5 is required for plot.ps1'
Write-Warning 'PowerShell Excel is ready, except for that functionality'
}
if ($IsLinux -or $IsMacOS) {
$ExcelPackage = [OfficeOpenXml.ExcelPackage]::new()
$Cells = ($ExcelPackage | Add-WorkSheet).Cells['A1']
$Cells.Value = 'Test'
try {
$Cells.AutoFitColumns()
}
catch {
if ($IsLinux) {
Write-Warning -Message 'ImportExcel Module Cannot Autosize. Please run the following command to install dependencies: "sudo apt-get install -y --no-install-recommends libgdiplus libc6-dev"'
}
if ($IsMacOS) {
Write-Warning -Message 'ImportExcel Module Cannot Autosize. Please run the following command to install dependencies: "brew install mono-libgdiplus"'
}
}
finally {
$ExcelPackage | Close-ExcelPackage -NoSave
}
}
#endregion
function Import-Excel {
<#
Expand Down
Loading

0 comments on commit 29efd50

Please sign in to comment.