Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No support of System.IO.Packaging.Package.Save()/Flush() in .NET Core #1211

Closed
mhoerandner opened this issue Sep 29, 2022 · 4 comments · Fixed by #1307
Closed

No support of System.IO.Packaging.Package.Save()/Flush() in .NET Core #1211

mhoerandner opened this issue Sep 29, 2022 · 4 comments · Fixed by #1307
Milestone

Comments

@mhoerandner
Copy link

mhoerandner commented Sep 29, 2022

Since OpenXml is based on System.IO.Packaging and there is no support for Flush()/Save() in .NET Core (dotnet 5, ...), I wanted to ask whether OpenXml is planning a better alternative than closing (disposing) the whole OpenXmlPackage (e.g. WordprocessingDocument)?

/// <summary>
/// Gets a value indicating whether saving the package is supported by calling <see cref="Save"/>. Some platforms (such as .NET Core), have limited support for saving.
/// If <c>false</c>, in order to save, the document and/or package needs to be fully closed and disposed and then reopened.
/// </summary>
#if FEATURE_PACKAGE_FLUSH
public static bool CanSave { get; } = true;
#else
public static bool CanSave { get; }
#endif
@mhoerandner mhoerandner reopened this Sep 29, 2022
@mhoerandner mhoerandner changed the title No support of System.IO.Packaging.Package.Save()/Flush() in .NET CoreFeature request for Open XML SDK No support of System.IO.Packaging.Package.Save()/Flush() in .NET Core Sep 29, 2022
@ashahabov
Copy link
Contributor

or we should wait for the implementation of Flush in .NET 8😐: dotnet/runtime#24149

@mikeebowen
Copy link
Collaborator

Hi @mhoerandner , there are no plans to implement this independently. It is scheduled to be in .Net 8.

@twsouthwick
Copy link
Member

I've got this working for v3 of the SDK: #1307

I've replaced the underlying abstraction with our own that we can have much more control over. In the end, we still rely on the System.IO.Packaging.Package APIs, but can now "Reload" the underlying package which will allow this to be enabled.

Once this is merged in, please give it a try and see if it works better for you.

@twsouthwick twsouthwick added this to the v3.0 milestone Jan 14, 2023
@twsouthwick
Copy link
Member

I'm not sure when the underlying issue will be fixed... so fixing it on our side instead. Once it works there, we can remove this work around, but this will allow us to move forward with the expected behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants