SpreadsheetGear Engine for .NET enables developers for .NET, .NET Framework, .NET Core, iOS, Android, Linux, macOS and UWP to easily take advantage of scalable Excel Reporting, comprehensive Excel compatible charting APIs, the fastest and most complete Excel compatible calculations and more using the same API enjoyed by thousands of Windows developers for more than a decade.
This library supports the Microsoft .NET Framework, ASP.NET Core, .NET Core, .NET 6.0, Universal Windows Platform, Xamarin.iOS, Xamarin.Android, Xamarin.Forms, Mono and any other platform which supports .NET Standard 2.0.
For comprehensive Excel compatible Windows Forms, WPF and Silverlight UI controls and ASP.NET image rendering see the SpreadsheetGear.Windows Nuget package and the SpreadsheetGear 2023 family of products at www.spreadsheetgear.com.
As an experiment I tried getting the DLLs from spreadsheetgear.com instead, which gave me a set of DLLs. The ones I required were called differently (SpreadsheetGear2017.dll and SpreadsheetGear2017.Drawing.dll) and only required very few adaptations to fit, but they are from the full-featured version, meaning they are part of the 30 day trial. We only require the limited free license:
I've also tried various older versions that of the SpreadsheetGear.dll that I could get my hands on via NuGet, but they all come with the same issue. Manually downgrading it back to 6.0.3.222 "fixes" this issue, but the upgrade was necessary in the first place because of other issues.
Version 9 of SpreadsheetGear Engine for .NET (formerly called SpreadsheetGear for .NET Standard) is now available and adds support for all of the various DataTable- and DataSet-related APIs that were missing in the previous version. Please update your NuGet package reference to this new version to start using these APIs.
The product on NuGet, SpreadsheetGear for .NET Standard, is an entirely different product from the one available as installers on the SpreadsheetGear website, which is SpreadsheetGear for .NET Framework, and what you have been using previously (6.0.3.222). There are some limitations with the .NET Standard product, currently including DataTable / DataSet related APIs which I'll get into below.
The SpreadsheetGear for .NET Standard NuGet product does come by default in a "free mode" but with the limitations you pointed out. If you want to unlock the fully licensed mode, you'd need to purchase a subscription to it. The SpreadsheetGear for .NET Framework does not have such a free mode but does have a 30-day trial.
SpreadsheetGear for .NET Standard targets .NET Standard and so provides cross-platform support such as .NET Core, Mono on Linux, Xamarin, etc. You can also use this product on the full .NET Framework if you are using .NET Framework 4.6 or higher. The current version of this product depends on .NET Standard 1.3, which itself did not have support for DataTables and DataSets. Therefore, SpreadsheetGear for .NET Standard could not support APIs such as IWorkbook.GetDataSet(...), IRange.CopyFromDataTable(...), etc. The next major release (V9) will target a later version of the .NET Standard which added support for DataTables / DataSets, and so these APIs will be added in. Do note there are other differences between the .NET Standard and .NET Framework products (mainly relating to graphics capabilities). Please see the Comparison page for a breakdown of these differences.
SpreadsheetGear for .NET Framework - targets the full .NET Framework and would probably be the most appropriate upgrade path for your current 6.0.3.222 version. However, you would have to pay for the fully-licensed version of this product to get the latest version, unless you already have an active subscription.
If you've not caught on already, I work for SpreadsheetGear. If you are interested in getting up-to-date with the latest version, feel free to Contact Us and we can continue this conversation off of StackOverflow.
I'm trying to determine the best way to open a protected worksheet, if even possible. I've done a little research in spreadsheetgear's documentation and I haven't really been able to track down a solution yet.
I've come across two options that I think might be able to help. Spreadsheetgear does have an Unprotect(string password) method but as of right now I cant get it to work. I have the user select a workbook on their local system and upload it to the server. When I try to open and read the file, the page breaks and throws an exception
This works fine on an unprotected workbook but when its protected I get the corrupt document error. Ideally, I would want to unprotect and open at the same time but I'm not sure how to accomplish this.OpenFromStream does have an overload where you can feed it a string as a password which I tried but no luck there. The documentation isn't great for these methods so I'm not sure if I was even using them correctly.
You are likely running into a known limitation, which will be addressed soon. SpreadsheetGear 2012's implementation of workbook and worksheet protection was based off Excel 2007 (ECMA-376 1st Edition). However, Microsoft has since added a number of new workbook protection options as well as stronger encryption forms to later editions of the Open XML (XLSX/XLSM) file format spec. SpreadsheetGear 2012 has not yet added support for these new file format options and encryption forms, so you could receive either a "Corrupt OpenXML document" or "Unsupported encryption type" exception when attempting to open these types of workbooks, the former of which you are receiving.
The good news is that Excel 2010/2013-compatible password protection will be added in the next major release of SpreadsheetGear, V8, which is slated to be released sometime later this year, though the timeline for this could slip.
Until V8 is released, one workaround would be to unprotect any workbooks and individual worksheets using Excel 2010 or Excel 2013, then use SpreadsheetGear itself or Excel 2007 to re-protect these workbook/worksheets, which will use the older protection/encryption options. There are also ways to hack the Windows Registry that would tell Excel 2010 and Excel 2013 to save workbooks out with the encryption options used in Excel 2007 (see this link), but that's not a very good solution IMO.
As of this writing, V8 of SpreadsheetGear hasn't been released, so I thought I would mention how we worked around this limitation. Manually unprotecting then re-protecting in an earlier of Excel version isn't an option for us as it's used in a commercial application. Also note that the second work-around actually doesn't work. It took many hours of arm-twisting Microsoft support to get them to admit this.
It turns out that worksheet protection doesn't encrypt any content, it only hashes the password, and relies on Excel to obtain it from the user before allowing access. In 2013, they changed the hash algorithm, and that's the piece that SpreadsheetGear doesn't support yet. The fact that the data is unencrypted makes this "protection" trivial to defeat (as long as you don't mind a little low-level XML parsing, which in fact I do very much ;-).
Every time we open a workbook with SpreadsheetGear, we pass the XML stream through a pre-processor that simply strips off the element containing the hash, and then passes the stream on to SpreadsheetGear, which then sees the worksheets as unprotected. We keep track of which worksheets were "unprotected", and then re-protect them with SpreadsheetGear (using the old hash algorithm) prior to saving the workbook. Note that this doesn't provide a "real" Unprotect method, where you would require the caller to supply the proper password before allowing access. If that was a requirement then presumably you could implement that piece as well. This approach has a big performance hit, mostly because we have to re-zip the worksheet streams prior to passing the whole thing on to SpreadsheetGear. Not an issue for us because in our typical workbooks, re-calc swamps open times. Obviously this isn't an approach for casual users, but it was non-negotiable for us to get this working somehow.
the latest update to SpreadsheetGear 2012 includes a hotfix (7.4.8.100) which allows the opening of these "password-protected" sheets. The ProtectContents method still takes a password parameter, but it is dropped and not used.
"We are adding support for the new encryption options provided for overall workbook protection in our V8 release. Adding 'full' support for worksheet protection (which doesn't drop the password) is not a sure thing for V8, though."
c80f0f1006