Posted 19 March 2026, 1:50 am EST - Updated 19 March 2026, 1:52 am EST
Workbook.FromSjsJson(stream, new SjsOpenOptions { IncludeStyles = true }) throws a NullReferenceException in the internal style/theme resolution layer when parsing certain valid SJS files (~4 MB). The identical file parses successfully when IncludeStyles = false, confirming the file itself is not corrupt.
Environment
- Library: GrapeCity.Documents.Excel (7.2.3)
- Target framework: .NET (10)
Steps to Reproduce
- Obtain or construct an SJS file containing a custom theme or named style with a null/empty sub-object (font, fill, or border entry).
- Buffer the file into a MemoryStream.
- Call workbook.FromSjsJson(stream, new SjsOpenOptions { IncludeStyles = true }).
- Observe NullReferenceException.
- Reset stream position and retry with IncludeStyles = false — call succeeds.
Code
using var sjsMemoryStream = new MemoryStream();
await responseStream.CopyToAsync(sjsMemoryStream);
sjsMemoryStream.Position = 0;
var workbook = new GrapeCity.Documents.Excel.Workbook();
workbook.FromSjsJson(sjsMemoryStream, new SjsOpenOptions { IncludeStyles = true });
// ^^^ throws NullReferenceException
Stack Trace
System.NullReferenceException
at GrapeCity.Documents.Excel.afw.a(dew a)
at GrapeCity.Documents.Excel.afj.d(dbl a)
at GrapeCity.Documents.Excel.afi.b(dbl a)
at GrapeCity.Documents.Excel.adu.xf(Stream a)
at GrapeCity.Documents.Excel.aeh.x(zf a, aei b, String c)
at GrapeCity.Documents.Excel.aeh.a(bxo a, Stream b, SjsOpenOptions c, List`1 d, Boolean e)
at GrapeCity.Documents.Excel.Workbook.ba(Stream a, SjsOpenOptions b, Boolean c)
at GrapeCity.Documents.Excel.Workbook.FromSjsJson(Stream stream, SjsOpenOptions openOptions)
Is this a bug from the library?

