mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-06 00:23:20 +00:00
Added the function 'Update-FirstObjectProperties'
Added help text in 'Export-Excel' Added try/catch to 'Install' and 'InstallModule' Improved code readability in 'Install' and 'InstallModule'
This commit is contained in:
@@ -1,40 +1,76 @@
|
||||
$ModuleName = "ImportExcel"
|
||||
$ModulePath = "C:\Program Files\WindowsPowerShell\Modules"
|
||||
$TargetPath = "$($ModulePath)\$($ModuleName)"
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Install the module in the PowerShell module folder.
|
||||
|
||||
if(!(Test-Path $TargetPath)) { md $TargetPath | out-null}
|
||||
.DESCRIPTION
|
||||
Install the module in the PowerShell module folder by copying all the files.
|
||||
#>
|
||||
|
||||
$targetFiles = echo `
|
||||
*.psm1 `
|
||||
*.psd1 `
|
||||
*.dll `
|
||||
New-ConditionalText.ps1 `
|
||||
New-ConditionalFormattingIconSet.ps1 `
|
||||
Export-Excel.ps1 `
|
||||
Export-ExcelSheet.ps1 `
|
||||
New-ExcelChart.ps1 `
|
||||
Invoke-Sum.ps1 `
|
||||
InferData.ps1 `
|
||||
Get-ExcelColumnName.ps1 `
|
||||
Get-XYRange.ps1 `
|
||||
Charting.ps1 `
|
||||
New-PSItem.ps1 `
|
||||
Pivot.ps1 `
|
||||
Get-ExcelSheetInfo.ps1 `
|
||||
Get-ExcelWorkbookInfo.ps1 `
|
||||
New-ConditionalText.ps1 `
|
||||
Get-HtmlTable.ps1 `
|
||||
Import-Html.ps1 `
|
||||
Get-Range.ps1 `
|
||||
TrackingUtils.ps1 `
|
||||
Copy-ExcelWorkSheet.ps1 `
|
||||
Set-CellStyle.ps1 `
|
||||
ConvertFromExcelToSQLInsert.ps1 `
|
||||
ConvertFromExcelData.ps1 `
|
||||
ConvertToExcelXlsx.ps1 `
|
||||
plot.ps1
|
||||
[CmdLetBinding()]
|
||||
Param (
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[String]$ModuleName = 'ImportExcel',
|
||||
[ValidateScript({Test-Path -Path $_ -Type Container})]
|
||||
[String]$ModulePath = 'C:\Program Files\WindowsPowerShell\Modules'
|
||||
)
|
||||
|
||||
Get-ChildItem $targetFiles |
|
||||
ForEach-Object {
|
||||
Copy-Item -Verbose -Path $_.FullName -Destination "$($TargetPath)\$($_.name)"
|
||||
}
|
||||
Begin {
|
||||
Try {
|
||||
Write-Verbose "$ModuleName module installation started"
|
||||
|
||||
$Files = @(
|
||||
'*.dll',
|
||||
'*.psd1',
|
||||
'*.psm1',
|
||||
'Charting.ps1',
|
||||
'ConvertFromExcelData.ps1',
|
||||
'ConvertFromExcelToSQLInsert.ps1',
|
||||
'ConvertToExcelXlsx.ps1',
|
||||
'Copy-ExcelWorkSheet.ps1',
|
||||
'Export-Excel.ps1',
|
||||
'Export-ExcelSheet.ps1',
|
||||
'Get-ExcelColumnName.ps1',
|
||||
'Get-ExcelSheetInfo.ps1',
|
||||
'Get-ExcelWorkbookInfo.ps1',
|
||||
'Get-HtmlTable.ps1',
|
||||
'Get-Range.ps1',
|
||||
'Get-XYRange.ps1',
|
||||
'Import-Html.ps1',
|
||||
'InferData.ps1',
|
||||
'Invoke-Sum.ps1',
|
||||
'New-ConditionalText.ps1',
|
||||
'New-ConditionalFormattingIconSet.ps1',
|
||||
'New-ExcelChart.ps1',
|
||||
'New-PSItem.ps1',
|
||||
'Pivot.ps1',
|
||||
'Plot.ps1',
|
||||
'Set-CellStyle.ps1',
|
||||
'TrackingUtils.ps1',
|
||||
'Update-FirstObjectProperties.ps1'
|
||||
)
|
||||
}
|
||||
Catch {
|
||||
throw "Failed installing the module '$ModuleName': $_"
|
||||
}
|
||||
}
|
||||
|
||||
Process {
|
||||
Try {
|
||||
$TargetPath = Join-Path -Path $ModulePath -ChildPath $ModuleName
|
||||
|
||||
if (-not (Test-Path $TargetPath)) {
|
||||
New-Item -Path $TargetPath -ItemType Directory -EA Stop | Out-Null
|
||||
Write-Verbose "$ModuleName created module folder '$TargetPath'"
|
||||
}
|
||||
|
||||
Get-ChildItem $Files | ForEach-Object {
|
||||
Copy-Item -Path $_.FullName -Destination "$($TargetPath)\$($_.Name)"
|
||||
Write-Verbose "$ModuleName installed module file '$($_.Name)'"
|
||||
}
|
||||
|
||||
Write-Verbose "$ModuleName module installation successful"
|
||||
}
|
||||
Catch {
|
||||
throw "Failed installing the module '$ModuleName': $_"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user