PrivateFunctions/ImportXLSConverterFunctions.ps1
<#
.SYNOPSIS This function imports the Spire.XLS converter functions #> function ImportXLSConverterFunctions { param ( # The path for the folder containing the XlsConverter program installation. [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [ValidateScript( {(Test-Path -Path $_ -ErrorAction SilentlyContinue)})] [String]$xlsConverterFolderPath ) try { # Import the Spire.XLS dlls # Use ReadAllBytes to load instead so that there is no lock on the dll files when we're done # This ensures that the dll files can be deleted afterwards Write-Information "Loading the Spire.XLS dll." if (![System.Reflection.Assembly]::Load([IO.File]::ReadAllBytes("$($xlsConverterFolderPath)\Spire.License.dll"))) { throw "Failed to load the Spire.License dll." } if (![System.Reflection.Assembly]::Load([IO.File]::ReadAllBytes("$($xlsConverterFolderPath)\Spire.pdf.dll"))) { throw "Failed to load the Spire.Pdf dll." } if (![System.Reflection.Assembly]::Load([IO.File]::ReadAllBytes("$($xlsConverterFolderPath)\Spire.XLS.dll"))) { throw "Failed to load the Spire.XLS dll." } # Apply License file [Spire.License.LicenseProvider]::SetLicenseFileFullPath("$($xlsConverterFolderPath)\license.elic.xml") } catch { Write-Error "Exception occurred on line $($_.InvocationInfo.ScriptLineNumber):`r`n$($_.Exception.Message)" } finally { # Nothing to do } } |