-
Notifications
You must be signed in to change notification settings - Fork 579
Description
Description
When opening an excel document in .NET 6 (Kestrel web server) I get an exception that synch reads are not allowed. And this is for a good reason, no libraries should force user to do blocking operations because it limits where the library can be used (on a web server in this case).
Information
- .NET Target: .NET 6
- DocumentFormat.OpenXml Version: 2.15
Repro
Call Spreadsheet.Load from a ASP.NET Core Action or in Blazor Server callback.
Observed
System.NotSupportedException: Synchronous reads are not supported.
at Microsoft.AspNetCore.Components.Forms.BrowserFileStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at System.IO.Stream.CopyTo(Stream destination, Int32 bufferSize)
at System.IO.Stream.CopyTo(Stream destination)
at System.IO.Compression.ZipArchive..ctor(Stream stream, ZipArchiveMode mode, Boolean leaveOpen, Encoding entryNameEncoding)
at System.IO.Packaging.ZipPackage..ctor(Stream s, FileMode packageFileMode, FileAccess packageFileAccess)
at System.IO.Packaging.Package.Open(Stream stream, FileMode packageMode, FileAccess packageAccess)
at DocumentFormat.OpenXml.Packaging.PackageLoader.OpenCore(Stream stream, Boolean readWriteMode)
at DocumentFormat.OpenXml.Packaging.SpreadsheetDocument.Open(Stream stream, Boolean isEditable, OpenSettings openSettings)
at DocumentFormat.OpenXml.Packaging.SpreadsheetDocument.Open(Stream stream, Boolean isEditable)
Expected
I would expect there to be a Spreadsheet.OpenAsync or some similar mechanism to prevent blocking IO while loading the document.