Skip to content

"IBM437 is not supported encoding name" exception when saving Excel workbook on daily PS 7.3 build #18537

@kborowinski

Description

@kborowinski

Prerequisites

Steps to reproduce

Saving Excel workbook with ImportExcel module on latest daily build of PS 7.3 throws following exception:
(It works correctly on PowerShell 7.3.0 GA and PowerShell 7.2.7 or PowerShell 5.1)

PSMessageDetails      :
Exception             : System.Management.Automation.MethodInvocationException: Exception calling "SaveAs" with "1" argument(s): "Error saving file ---"
                         ---> System.InvalidOperationException: Error saving file ---
                         ---> System.ArgumentException: 'IBM437' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method. (Parameter 'name')
                           at System.Text.EncodingTable.InternalGetCodePageFromName(String name)
                           at System.Text.EncodingTable.GetCodePageFromName(String name)
                           at System.Text.Encoding.GetEncoding(String name)
                           at OfficeOpenXml.Packaging.Ionic.Zip.ZipOutputStream..ctor(Stream stream, Boolean leaveOpen)
                           at OfficeOpenXml.Packaging.ZipPackage.Save(Stream stream)
                           at OfficeOpenXml.ExcelPackage.Save()
                           --- End of inner exception stack trace ---
                           at OfficeOpenXml.ExcelPackage.Save()
                           at CallSite.Target(Closure, CallSite, ExcelPackage, Object)
                           --- End of inner exception stack trace ---
                           at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception) in D:\DEVELOPMENT\PowerShellCore\src\System.Management.Automation\engine\runtime\Operations\MiscOps.cs:line 1659
                           at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame) in D:\DEVELOPMENT\PowerShellCore\src\System.Management.Automation\engine\interpreter\CallInstruction.Generated.cs:line 504
                           at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) in D:\DEVELOPMENT\PowerShellCore\src\System.Management.Automation\engine\interpreter\ControlFlowInstructions.cs:line 338
                           at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) in D:\DEVELOPMENT\PowerShellCore\src\System.Management.Automation\engine\interpreter\ControlFlowInstructions.cs:line 338
                           at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame) in D:\DEVELOPMENT\PowerShellCore\src\System.Management.Automation\engine\interpreter\Interpreter.cs:line 101
                           at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0) in D:\DEVELOPMENT\PowerShellCore\src\System.Management.Automation\engine\interpreter\LightLambda.Generated.cs:line 82
                           at System.Management.Automation.PSScriptCmdlet.RunClause(Action`1 clause, Object dollarUnderbar, Object inputToProcess) in D:\DEVELOPMENT\PowerShellCore\src\System.Management.Automation\engine\runtime\CompiledScriptBlock.cs:line 2435
                           at System.Management.Automation.CommandProcessorBase.Complete() in D:\DEVELOPMENT\PowerShellCore\src\System.Management.Automation\engine\CommandProcessorBase.cs:line 593
TargetObject          :
CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
FullyQualifiedErrorId : InvalidOperationException
ErrorDetails          :
InvocationInfo        : System.Management.Automation.InvocationInfo
ScriptStackTrace      : at Close-ExcelPackage, C:\Program Files\WindowsPowerShell\Modules\ImportExcel\7.8.2\Public\Close-ExcelPackage.ps1: line 25
                        at Export-KBExcelNodeStatusReport<End>, <No file>: line 1001
                        at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {}

Expected behavior

The Excel workbook should be saved without exception like on PowerShell 7.3.0 GA and PowerShell 7.2.7, or PowerShell 5.1

Actual behavior

An exception is thrown.

Error details

PSMessageDetails      :
Exception             : System.Management.Automation.MethodInvocationException: Exception calling "SaveAs" with "1" argument(s): "Error saving file ---"
                         ---> System.InvalidOperationException: Error saving file ---
                         ---> System.ArgumentException: 'IBM437' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method. (Parameter 'name')
                           at System.Text.EncodingTable.InternalGetCodePageFromName(String name)
                           at System.Text.EncodingTable.GetCodePageFromName(String name)
                           at System.Text.Encoding.GetEncoding(String name)
                           at OfficeOpenXml.Packaging.Ionic.Zip.ZipOutputStream..ctor(Stream stream, Boolean leaveOpen)
                           at OfficeOpenXml.Packaging.ZipPackage.Save(Stream stream)
                           at OfficeOpenXml.ExcelPackage.Save()
                           --- End of inner exception stack trace ---
                           at OfficeOpenXml.ExcelPackage.Save()
                           at CallSite.Target(Closure, CallSite, ExcelPackage, Object)
                           --- End of inner exception stack trace ---
                           at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception) in D:\DEVELOPMENT\PowerShellCore\src\System.Management.Automation\engine\runtime\Operations\MiscOps.cs:line 1659
                           at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame) in D:\DEVELOPMENT\PowerShellCore\src\System.Management.Automation\engine\interpreter\CallInstruction.Generated.cs:line 504
                           at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) in D:\DEVELOPMENT\PowerShellCore\src\System.Management.Automation\engine\interpreter\ControlFlowInstructions.cs:line 338
                           at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) in D:\DEVELOPMENT\PowerShellCore\src\System.Management.Automation\engine\interpreter\ControlFlowInstructions.cs:line 338
                           at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame) in D:\DEVELOPMENT\PowerShellCore\src\System.Management.Automation\engine\interpreter\Interpreter.cs:line 101
                           at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0) in D:\DEVELOPMENT\PowerShellCore\src\System.Management.Automation\engine\interpreter\LightLambda.Generated.cs:line 82
                           at System.Management.Automation.PSScriptCmdlet.RunClause(Action`1 clause, Object dollarUnderbar, Object inputToProcess) in D:\DEVELOPMENT\PowerShellCore\src\System.Management.Automation\engine\runtime\CompiledScriptBlock.cs:line 2435
                           at System.Management.Automation.CommandProcessorBase.Complete() in D:\DEVELOPMENT\PowerShellCore\src\System.Management.Automation\engine\CommandProcessorBase.cs:line 593
TargetObject          :
CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
FullyQualifiedErrorId : InvalidOperationException
ErrorDetails          :
InvocationInfo        : System.Management.Automation.InvocationInfo
ScriptStackTrace      : at Close-ExcelPackage, C:\Program Files\WindowsPowerShell\Modules\ImportExcel\7.8.2\Public\Close-ExcelPackage.ps1: line 25
                        at Export-KBExcelNodeStatusReport<End>, <No file>: line 1001
                        at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {}

Environment data

Name                           Value
----                           -----
PSVersion                      7.3.0-preview.3
PSEdition                      Core
GitCommitId                    7.3.0-preview.3-461-g9f459c05f617fe530dac340aa546d198724d85da
OS                             Microsoft Windows 10.0.19045
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0, 5.0, 5.1, 6.0.0, 6.1.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

exception

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions