Empty, Self-Closing Worksheet Element causing NullReferenceException

I receive quote files from a supplier in Excel 2003 XML format (LoadFormat.SpreadsheetML).

These files often include empty, self-closing Worksheet elements that cause NullReferenceException when loading into ASPOSE Workbook.

CODE:

Workbook workbook = new Workbook("example.xml", new LoadOptions(LoadFormat.SpreadsheetML));

XML Example causes Exception:

<?xml version="1.0" encoding="UTF-8"?>
<?mso-application progid="Excel.Sheet"?>
    <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
        xmlns:fn="http://www.w3.org/2005/xpath-functions"
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
        xmlns:fo="http://www.w3.org/1999/XSL/Format"
        xmlns:str="http://exslt.org/strings"
        xmlns:html="http://www.w3.org/TR/REC-html40"
        xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
        xmlns:x="urn:schemas-microsoft-com:office:excel"
        xmlns:o="urn:schemas-microsoft-com:office:office">
        <Worksheet ss:Name="Sheet1"/>
    </Workbook>

If I edit the file and close the tag, ASPOSE is able to load the file:

<?xml version="1.0" encoding="UTF-8"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
    xmlns:fn="http://www.w3.org/2005/xpath-functions"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:fo="http://www.w3.org/1999/XSL/Format"
    xmlns:str="http://exslt.org/strings"
    xmlns:html="http://www.w3.org/TR/REC-html40"
    xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
    xmlns:x="urn:schemas-microsoft-com:office:excel"
    xmlns:o="urn:schemas-microsoft-com:office:office">
    <Worksheet ss:Name="Sheet1">
    </Worksheet>
</Workbook>

Excel loads either example without error.

I’m requesting that ASPOSE add support for loading SpreadsheetML files that contain empty, self-closing Worksheet elements,

Thank you.

@Bill_Hanson,

Please notice, I am able to reproduce the issue as you mentioned by using the following line of code with the attached file. I found an empty self-closing worksheet element causes “NullReferenceException”. I also attached two files in the archive (I actually pasted your devised xml parts/scripts (one for each file)), “Bk_test.xml” works fine where as “Bk_test1.xml” does not work:
e.g.
Sample code:

Workbook workbook = new Workbook("e:\\test2\\Bk_test1.xml", new LoadOptions(LoadFormat.SpreadsheetML)); //this does not work
//Workbook workbook = new Workbook("e:\\test2\\Bk_test.xml", new LoadOptions(LoadFormat.SpreadsheetML)); //this works

I have logged a ticket with an id “CELLSNET-47833” for your issue. We will look into it soon.

Once we have an update on it, we will let you know.
files1.zip (851 Bytes)

@Bill_Hanson,
This is to inform you that we have fixed your issue now. We will soon provide you the fixed version after performing QA and incorporating other enhancements and fixes.

That’s great news. I’m looking forward to it.

@Bill_Hanson
Please try the latest fix 21.1.2
Aspose.Cells21.1.2 For .Net2_AuthenticodeSigned.Zip (5.5 MB)
Aspose.Cells21.1.2 For .Net4.0.Zip (5.5 MB)
Aspose.Cells21.1.2 For .NetStandard20.Zip (5.5 MB)

Awesome! Works like a charm. Thank you for the fast response.

@Bill_Hanson,

Thanks for your feedback and good to know that your issue is resolved by the new fix/version. Feel free to contact us any time if you need further help or have some other queries or issue, we will be happy to assist you soon.