question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Open .xlsm and save error with large worksheet.

See original GitHub issue

Read 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:open
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
igiturcommented, Aug 11, 2020

Thanks @kenleese . Didn’t know you still hang around here! Silent partner (mostly), hey?!

1reaction
kenleesecommented, Aug 11, 2020

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to troubleshoot errors when you save Excel workbooks
Select Yes. Open a new Excel workbook, and try to save it. If that works, try again to save the problem file.
Read more >
Excel Errors Were Detected While Saving | Here's the Guide
Step 1: Copy data from the workbook. Step 2: Open a new Excel document and paste the data into a new workbook. Step...
Read more >
Solved: Errors Were Detected While Saving Excel [2023]
Click File > Open, on the open box, select the corrupted Excel workbook;; Go to the open button with the arrow next and...
Read more >
4 Fixes To Resolve Excel XLSM Files Won't Open Issue
First, save it to a folder on the hard disk then open the saved workbook. Now check out the below-given tricks on how...
Read more >
Very Large Spreadsheet Gets Corrupted in Various ...
Today I got the "Module not Found" error (when I press OK Excel crashes) upon opening an XLSM file that I successfully saved...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found