refactor: Remove OpenXML dependency and improve Excel COM cleanup

This commit is contained in:
Bobby Abellana (aider) 2025-02-21 10:46:42 -08:00
parent 01a86be2a1
commit a5057f2a0d
2 changed files with 0 additions and 34 deletions

View File

@ -39,31 +39,6 @@ foreach ($module in $graphModules) {
}
}
# Install OpenXML via NuGet package (not module)
try {
# Install NuGet package provider if not exists
if (-not (Get-PackageProvider -Name NuGet)) {
Install-PackageProvider -Name NuGet -Force
}
# Install OpenXML SDK package
$openXmlPackage = Install-Package DocumentFormat.OpenXml -ProviderName NuGet -Force -SkipDependencies
$packagePath = Join-Path $env:USERPROFILE ".nuget\packages\DocumentFormat.OpenXml"
$dllPath = Resolve-Path (Join-Path $packagePath "*\lib\net*\DocumentFormat.OpenXml.dll") -ErrorAction SilentlyContinue | Select-Object -First 1
if ($dllPath -and (Test-Path $dllPath)) {
Add-Type -Path $dllPath
Write-Host "DocumentFormat.OpenXml assembly loaded successfully" -ForegroundColor Green
}
else {
throw "OpenXML DLL not found in NuGet packages. Tried path: $packagePath"
}
}
catch {
Write-Host "Failed to install DocumentFormat.OpenXml: $($_.Exception.Message)" -ForegroundColor Red
Write-Host "You may need to install the Open XML SDK manually from:"
Write-Host "https://www.microsoft.com/en-us/download/details.aspx?id=30425" -ForegroundColor Yellow
}
# Check for Excel installation
try {

View File

@ -2,15 +2,6 @@ Add-Type -AssemblyName System.Windows.Forms
Import-Module Microsoft.Graph.Sites
Import-Module Microsoft.Graph.Files
# Load Open XML assembly from installed NuGet package
try {
$openXmlPath = Join-Path $env:USERPROFILE ".nuget\packages\DocumentFormat.OpenXml\*\lib\net46\DocumentFormat.OpenXml.dll"
Add-Type -Path (Resolve-Path $openXmlPath -ErrorAction Stop)
}
catch {
[System.Windows.Forms.MessageBox]::Show("OpenXML assembly missing! Install dependencies first.")
exit
}
# Import our components
. "$PSScriptRoot\GraphConfig.ps1"