Missing mc:Ignorable Attribute in Exported XLSX File

We encountered an issue where our application exports .xlsx files using Aspose.Cells, which are then imported into another system that uses a different third-party library for Excel processing.

The support team of that third-party library identified that the issue lies in the absence of the mc:Ignorable attribute in the exported file. This attribute is necessary to instruct the reader to ignore the xr namespaces present in the document. Without it, their library fails to process the file correctly.

Could you please advise:

  • Is there a setting or property in Aspose.Cells that ensures the mc:Ignorable attribute is included during export?
  • If not, is there a recommended workaround or customization to include this attribute manually?

We’d appreciate any guidance or best practices you can share to ensure compatibility with consumers that require this attribute.

@rm03

To address the issue of the missing mc:Ignorable attribute in the exported .xlsx files using Aspose.Cells, there is currently no direct setting or property in Aspose.Cells that automatically includes this attribute during the export process.

Cause: The absence of the mc:Ignorable attribute can lead to compatibility issues with certain third-party libraries that rely on this attribute for proper functionality.

Solution: You can implement a workaround by manually modifying the generated XML of the .xlsx file after it has been created. Here’s a step-by-step approach:

  1. Export the Workbook: Use Aspose.Cells to export your workbook to an .xlsx file as you normally would.

  2. Open the .xlsx File: Use a library that can manipulate XML files (like System.Xml in .NET) to open the generated .xlsx file, which is essentially a zip archive containing XML files.

  3. Modify the XML: Locate the relevant XML file (usually xl/workbook.xml or xl/worksheets/sheet1.xml) and add the mc:Ignorable attribute to the root element. For example:

    <workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"
              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
              mc:Ignorable="xr">
    
  4. Save the Changes: After modifying the XML, save the changes back to the .xlsx file.

Here’s a minimal code snippet to illustrate how you might modify the XML:

using System.IO;
using System.IO.Compression;
using System.Xml.Linq;

public void AddIgnorableAttribute(string filePath)
{
    using (ZipArchive archive = ZipFile.Open(filePath, ZipArchiveMode.Update))
    {
        var workbookEntry = archive.GetEntry("xl/workbook.xml");
        if (workbookEntry != null)
        {
            using (var stream = workbookEntry.Open())
            {
                XDocument doc = XDocument.Load(stream);
                var root = doc.Root;
                root.SetAttributeValue(XName.Get("Ignorable", "http://schemas.openxmlformats.org/markup-compatibility/2006"), "xr");
                stream.SetLength(0); // Clear the stream
                doc.Save(stream);
            }
        }
    }
}

Next Steps: Implement the above code in your project to ensure that the mc:Ignorable attribute is included in your exported .xlsx files. Test the modified files with the third-party library to confirm compatibility.

If you need further assistance or clarification on any of the steps, please feel free to ask!

@rm03
Could you share a file to show this issue? We will check it ASAP.

Please see attached. The WorkingFile.png was able to parse by the other other 3rd party library.
The NotWorkingFile.png is the xlsx created through Aspose.Cells and throws an error during parsing, because of the missing Ignorable attribute. The parser does not support xr namespaces hence the error.

Let me know if there are other information I can provide.

NotWorkingFile.png (26.9 KB)

WorkingFile.png (28.1 KB)

@rm03
Are you using different version of Aspose.Cells to generate xlsx file?
“mc:Ignorable” attribute must be exported to Sheet.xml in the latest version.
Could you share a not working xlsx file here? We will check why the attribute is missed.

I am using licensed version of Aspose. Cells version 20.5 and 25.7. Can you confirm if these versions should export the mc:Ignorable attribute? Based on my testing, they are not.
The upload functionality here does not allow me to upload the xlsx file.

@rm03
The “mc:Ignorable” attribute was originally added in version v21.1. If you need to output this attribute, please update the version to v21.1 or higher. We strongly recommend that you update to the latest version v25.7, as after years of version iterations, we have not only enhanced existing features and fixed identified issues, but also added many new features.

By testing on the latest version of v25.7 using the following sample code, we can open the sheet1.xml file in the saved file and find the text(mc:Ignorable=“x14ac xr xr2 xr3”). Please refer to the attachment. out_net.zip (201.0 KB)

Workbook wb = new Workbook();
Cell a1 = wb.Worksheets[0].Cells["A1"];
a1.PutValue("test data");
wb.Save(filePath + "out_net.xlsx");

If you still have any questions, please provide us with your sample code and result file, and we will check it soon.

@rm03,

You may zip the XLSX file(s) and attach the zipped archive here.

Hi everyone,
Thank you for all your responses. There were some setup issues from my initial test when I used the version 25.7. After fixing those configuration issues and was able to use the latest version properly, I now see that the mc:Ignorable is indeed already being added. My issue is now resolved. Thank you again.

@rm03
You are welcome! We are glad your issue has been resolved with the latest version 25.7.