Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
20
getting this error while generating xlsx file in c#
posted
Can not access a closed Stream.
System.ObjectDisposedException: Can not access a closed Stream.
   at System.IO.Compression.DeflateStream.EnsureNotDisposed()
   at MS.Internal.IO.Packaging.CompressStream.Flush()
   at MS.Internal.IO.Zip.ZipIOLocalFileBlock.FlushExposedStreams()
   at MS.Internal.IO.Zip.ZipIOLocalFileBlock.UpdateReferences(Boolean closingFlag)
   at MS.Internal.IO.Zip.ZipIOBlockManager.SaveContainer(Boolean closingFlag)
   at MS.Internal.IO.Zip.ZipIOBlockManager.SaveStream(ZipIOLocalFileBlock blockRequestingFlush, Boolean closingFlag)
   at MS.Internal.IO.Zip.ZipIOModeEnforcingStream.Dispose(Boolean disposing)
   at System.IO.Stream.Close()
   at System.IO.Packaging.PackagePart.Close()
   at System.IO.Packaging.Package.DoClose(PackagePart p)
   at System.IO.Packaging.Package.DoOperationOnEachPart(PartOperation operation)
   at System.IO.Packaging.Package.System.IDisposable.Dispose()
   at Infragistics.Documents.OfficeOpenXml.Core.OfficeDocumentManager.Dispose(Boolean disposing)
   at Infragistics.Documents.Excel.Serialization.WorkbookSaveManagerExcel2007.Dispose(Boolean disposing)
   at Infragistics.Documents.Excel.Workbook.SaveXLSXFileHelper(Stream stream, WorkbookSaveOptions saveOptions)
   at Infragistics.Documents.Excel.Workbook.Save(String fileName, WorkbookSaveOptions saveOptions)

Top Replies

  • 0
    Offline posted

    That error usually means the file stream is getting closed before the workbook finishes saving. Try wrapping the save in a using (var stream = new FileStream(...)) { ... } block so it only disposes after the save is complete. Infragistics community

  • 0
    Offline posted in reply to Kabir Singh

    If you’ve been hesitant to try, trust me — these ilford escorts are the real deal. Classy, confident, and full of energy. It was everything I was hoping for and more.

  • 0
    Offline posted

    Learning how to make a cookbook on Canva is a game-changer for food bloggers who want to monetize their content or offer free recipe books to their audience. With Canva’s user-friendly interface, bloggers can easily drag and drop images, customize fonts and colors, and create an eye-catching layout. KitchenBloggers provides step-by-step guidance on how to create an attractive and functional cookbook that can be shared digitally or printed for distribution.

  • 0
    Offline posted

    Many students search for the most common MCQ answer when unsure about a question. While some test patterns may show a slight preference for certain answers, the key to success in multiple-choice exams is understanding the subject matter, identifying keywords, and eliminating distractors. Instead of randomly choosing an option, students should develop strong analytical skills to make informed guesses. StudyRight provides effective methods for mastering MCQ exams beyond simple guessing.

  • 0
    Offline posted

    "Getting errors while generating an XLSX file in C# can be frustrating. Make sure to check your code for any issues with data types or the libraries you’re using. Sometimes, incorrect formatting can lead to these errors. If you need a break from troubleshooting, treating yourself to something sweet can help clear your mind. I love checking out the Dairy Queen Menu for a quick snack while I work through coding challenges. Good luck with your XLSX generation!"