NullReferenceException in Workbook.FromSjsJson with IncludeStyles = true on

Posted by: srayaprolu on 19 March 2026, 1:50 am EST

  • 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

    1. Obtain or construct an SJS file containing a custom theme or named style with a null/empty sub-object (font, fill, or border entry).
    2. Buffer the file into a MemoryStream.
    3. Call workbook.FromSjsJson(stream, new SjsOpenOptions { IncludeStyles = true }).
    4. Observe NullReferenceException.
    5. 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?

  • Posted 19 March 2026, 6:18 am EST - Updated 19 March 2026, 6:23 am EST

    Hi Chris,

    Thank you for sharing the detailed information.

    We were not able to reproduce the reported NullReferenceException using the provided scenario. However, while testing with a similar SJS JSON (including custom styles/themes), we observed an ArgumentOutOfRangeException during parsing.

    This issue has already been addressed in DsExcel v8.0.2.

    To move forward, we recommend upgrading to the latest version - DsExcel v9.0.3, and re-testing the same file.

    If the issue persists on your end, please help us with the following so we can investigate further:

    1. A minimal reproducible sample (you may modify and share your current setup)
    2. The exact steps used to generate the SJS JSON file (a short screen recording would be helpful)
    3. Your machine/environment details

    This will help us determine whether this is a separate edge case in the style/theme parsing layer.

    Looking forward to your response.

    Kind Regards,

    Chirag

    Attachment: SjsJsonLoadFailure.zip

    File Generation:

  • Posted 19 March 2026, 9:48 am EST - Updated 19 March 2026, 9:58 am EST

    Hi Chirag,

    Thanks for your answer. I am attaching the file i have used, could you see if you can replicate this in GrapeCity.Documents.Excel (7.2.3) and also the latest one. Thanks again!

    link - https://bna-my.sharepoint.com/:x:/p/sr132586/IQBoJAplr8EQSa2HYtuYus2rAW2aoMusFDabpa_-upbWfMA?e=j3GCa8

  • Posted 19 March 2026, 9:49 am EST

    file

  • Posted 19 March 2026, 3:15 pm EST

    Also Chirag, is this the still nuget package link, cause i don’t see latest versions

    https://www.nuget.org/packages/GrapeCity.Documents.Excel

  • Posted 19 March 2026, 11:33 pm EST

    Hi Chris,

    Thank you for sharing the required file.

    However, we were unable to reproduce the reported NullReferenceException with the file using DsExcel v7.2.3. The only issue replicable with the setup is an ArgumentOutOfRangeException during parsing, which is already addressed in DsExcel v8.0.2.

    Please refer to the attached code sample and the screen recording that demonstrates the working of the file with various DsExcel versions.

    Additionally, GrapeCity.Documents.Excel has been discontinued starting with version 7.2.4, and the latest builds are available in Ds.Documents.Excel package. Please refer to the forum case - https://developer.mescius.com/forums/documents-excel/important-update-shift-to-document-solutions-nuget-package-ds-documents-excel for more details.

    In case the issue does not resolve on your end using the latest versions, too, please share the following details with us:

    1. A stripped-down sample application replicating the issue. You can also modify and share the attached sample.
    2. Machine configurations.

    Kind Regards,

    Chirag

  • Posted 19 March 2026, 11:56 pm EST

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels