Open .xlsm and save error with large worksheet.
See original GitHub issueRead and complete the full issue template
Do not randomly delete sections. They are here for a reason.
Do you want to request a feature or report a bug?
- Bug
- Feature
- Question
Did you test against the latest CI build?
- Yes
- No
If you answered No
, please test with the latest development build first.
Version of ClosedXML
0.95.3 and also 0.95.2
What is the current behavior?
- After open macro-enable excel file (.xlsm) as template and add new worksheet with large data about 3500 rows and 500 columns.
When call SaveAs(filename), it throw an error
Exception calling "SaveAs" with "1" argument(s): "Unable to determine the identity of domain."
- Full exception stack
ErrorRecord : Exception calling "SaveAs" with "1" argument(s): "Unable to determine the identity of
domain."
WasThrownFromThrowStatement : False
Message : Exception calling "SaveAs" with "1" argument(s): "Unable to determine the identity of
domain."
Data : {System.Management.Automation.Interpreter.InterpretedFrameInfo}
InnerException : System.IO.IsolatedStorage.IsolatedStorageException: Unable to determine the identity of
domain.
at System.IO.IsolatedStorage.IsolatedStorage._GetAccountingInfo(Evidence evidence,
Type evidenceType, IsolatedStorageScope fAssmDomApp, Object& oNormalized)
at System.IO.IsolatedStorage.IsolatedStorage.GetAccountingInfo(Evidence evidence,
Type evidenceType, IsolatedStorageScope fAssmDomApp, String& typeName, String&
instanceName)
at System.IO.IsolatedStorage.IsolatedStorage._InitStore(IsolatedStorageScope scope,
Evidence domainEv, Type domainEvidenceType, Evidence assemEv, Type assemblyEvidenceType,
Evidence appEv, Type appEvidenceType)
at System.IO.IsolatedStorage.IsolatedStorage.InitStore(IsolatedStorageScope scope,
Type domainEvidenceType, Type assemblyEvidenceType)
at System.IO.IsolatedStorage.IsolatedStorageFile.GetStore(IsolatedStorageScope scope,
Type domainEvidenceType, Type assemblyEvidenceType)
at
MS.Internal.IO.Packaging.PackagingUtilities.ReliableIsolatedStorageFileFolder.GetCu
rrentStore()
at
MS.Internal.IO.Packaging.PackagingUtilities.ReliableIsolatedStorageFileFolder..ctor()
at MS.Internal.IO.Packaging.PackagingUtilities.GetDefaultIsolatedStorageFile()
at
MS.Internal.IO.Packaging.PackagingUtilities.CreateUserScopedIsolatedStorageFileStre
amWithRandomName(Int32 retryCount, String& fileName)
at MS.Internal.IO.Packaging.SparseMemoryStream.EnsureIsolatedStoreStream()
at MS.Internal.IO.Packaging.SparseMemoryStream.SwitchModeIfNecessary()
at MS.Internal.IO.Packaging.SparseMemoryStream.Write(Byte[] buffer, Int32 offset,
Int32 count)
at MS.Internal.IO.Packaging.CompressEmulationStream.Write(Byte[] buffer, Int32
offset, Int32 count)
at MS.Internal.IO.Packaging.CompressStream.Write(Byte[] buffer, Int32 offset, Int32
count)
at MS.Internal.IO.Zip.ProgressiveCrcCalculatingStream.Write(Byte[] buffer, Int32
offset, Int32 count)
at MS.Internal.IO.Zip.ZipIOModeEnforcingStream.Write(Byte[] buffer, Int32 offset,
Int32 count)
at System.Xml.XmlUtf8RawTextWriter.FlushBuffer()
at System.Xml.XmlUtf8RawTextWriter.RawText(Char* pSrcBegin, Char* pSrcEnd)
at System.Xml.XmlUtf8RawTextWriter.RawText(String s)
at System.Xml.XmlUtf8RawTextWriter.WriteStartElement(String prefix, String localName,
String ns)
at System.Xml.XmlWellFormedWriter.WriteStartElement(String prefix, String localName,
String ns)
at DocumentFormat.OpenXml.OpenXmlElement.WriteTo(XmlWriter xmlWriter)
at DocumentFormat.OpenXml.OpenXmlCompositeElement.WriteContentTo(XmlWriter w)
at DocumentFormat.OpenXml.OpenXmlElement.WriteTo(XmlWriter xmlWriter)
at DocumentFormat.OpenXml.OpenXmlCompositeElement.WriteContentTo(XmlWriter w)
at DocumentFormat.OpenXml.OpenXmlPartRootElement.WriteTo(XmlWriter xmlWriter)
at DocumentFormat.OpenXml.OpenXmlPartRootElement.SaveToPart(OpenXmlPart openXmlPart)
at DocumentFormat.OpenXml.Packaging.OpenXmlPackage.TrySavePartContent(OpenXmlPart
part)
at DocumentFormat.OpenXml.Packaging.OpenXmlPackage.SavePartContents()
at DocumentFormat.OpenXml.Packaging.OpenXmlPackage.Dispose(Boolean disposing)
at DocumentFormat.OpenXml.Packaging.OpenXmlPackage.Dispose()
at ClosedXML.Excel.XLWorkbook.CreatePackage(String filePath, SpreadsheetDocumentType
spreadsheetDocumentType, SaveOptions options)
at ClosedXML.Excel.XLWorkbook.SaveAs(String file, SaveOptions options)
at CallSite.Target(Closure , CallSite , Object , Object )
TargetSite : Void CheckActionPreference(System.Management.Automation.Language.FunctionContext,
System.Exception)
StackTrace : at
System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext
funcContext, Exception exception)
at
System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame
frame)
at
System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(Interp
retedFrame frame)
at
System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(Interp
retedFrame frame)
HelpLink :
Source : System.Management.Automation
HResult : -2146233087
- However I can use excel application application to manual add large worksheet and successfully save as expect.
- Also, if additional worksheet is not much large for example 350 rows and 5 columns, and can be saved by ClosedXML with this approach.
- Moreover, it can be successfully save this large worksheet if create emtpy XLWorkbook (not open from template file).
What is the expected behavior or new feature?
Should be save xlsm file with new large worksheet. Total file size when I use excel application to save this worksheet is about 12MB.
Is this a regression from the previous version?
Regressions get higher priority. Test against the latest build of the previous minor version. For example, if you experience a problem on v0.95.3, check whether it the problem occurred in v0.94.2 too.
Reproducibility
This is an important section. Read it carefully. Failure to do so will cause a ‘RTFM’ comment.
Without a code sample, it is unlikely that your issue will get attention. Don’t be lazy. Do the effort and assist the developers to reproduce your problem. Code samples should be minimal complete and verifiable. Sample spreadsheets should be attached whenever applicable. Remove sensitive information.
Code to reproduce problem:
# Powershell
function Test-XLSMProcess($templateFile, $outputFile) {
$wb = New-Object -TypeName ClosedXML.Excel.XLWorkbook($templateFile)
$ws = $eclWorkBook.Worksheets.Add("Return")
for ($r = 1; $r -le 3500; $r++) {
for ($c = 1; $c -le 500; $c++) {
$ws.Cell($r,$c).Value = ("'{0}-{1}" -f $r, $c)
}
}
[void] $wb.SaveAs($outputFile)
[void] $wb.Dispose()
}
- I attached a sample spreadsheet. (You can drag files on to this issue) template.zip
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Top GitHub Comments
Thanks @kenleese . Didn’t know you still hang around here! Silent partner (mostly), hey?!
I suspect this issue is reproduced with Legacy PowerShell, although the PowerShell version is not reported. I suggest trying with PowerShell Core, e.g. PowerShell 7.0.3 https://github.com/powershell/powershell which will use .NET Core. See https://github.com/ClosedXML/ClosedXML/issues/619#issuecomment-349684554 and specifically the reference to https://github.com/dotnet/runtime/issues/24154