question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

OpenXmlValidator not validating boolean values

See original GitHub issue

Before submitting an issue, please fill this out

Is this a:

  • Issue with the OpenXml library
  • Question on library usage

If you have answered that this is a question, please ask it on StackOverflow instead of here. This issue tracker is meant to track product issues while StackOverflow excels at answering questions

---------------- Remove this line and above before posting ----------------

Description

This looks like a regression. Values of type boolean, but with values 0 or 1 in the OpenXML document fail to validate.

Information

  • .NET Target: .NET Core 3.1
  • DocumentFormat.OpenXml Version: 2.12.0

This problem doesn’t exist in 2.11.3, hence it looks like a regression between 2.11.3 and 2.12.0.

Repro

var version = typeof(SpreadsheetDocument).Assembly.GetName().Version.ToString();
Console.WriteLine(version);
using var package = SpreadsheetDocument.Open("test.xlsx", isEditable: false);
var validator = new OpenXmlValidator();
var errors = validator.Validate(package);

if (errors.Any())
{
    Console.WriteLine("This file should validate.");
    Console.WriteLine();
    foreach (var e in errors)
    {
        Console.WriteLine($"Part {e.Part.Uri}, Path {e.Path.XPath}: {e.Description}");
    }
}
else
    Console.WriteLine("No validation errors");

Test file: test.xlsx

Observed

OpenXmlValidator.Validate() produces errors.

2.12.0.0 This file should validate.

Part /xl/worksheets/sheet1.xml, Path /x:worksheet[1]/x:sheetData[1]/x:row[5]/x:c[3]: Cell contents have invalid value ‘0’ for type ‘Boolean’. Part /xl/worksheets/sheet1.xml, Path /x:worksheet[1]/x:sheetData[1]/x:row[4]/x:c[3]: Cell contents have invalid value ‘0’ for type ‘Boolean’. Part /xl/worksheets/sheet1.xml, Path /x:worksheet[1]/x:sheetData[1]/x:row[3]/x:c[3]: Cell contents have invalid value ‘1’ for type ‘Boolean’.

Expected

OpenXmlValidator.Validate() should not produce errors.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
igiturcommented, Feb 26, 2021
1reaction
twsouthwickcommented, Feb 26, 2021

Thanks! How about we get a fix for that and we’ll iterate until you have a clean test suite?

Read more comments on GitHub >

github_iconTop Results From Across the Web

OpenXmlValidator not validating boolean values · Issue #887
This looks like a regression. Values of type boolean, but with values 0 or 1 in the OpenXML document fail to validate. Information...
Read more >
How to validate type 'java.lang.Boolean' in Spring boot
I had a similar issue with form validation of a Boolean value, where I technically only wanted the client to pass either true...
Read more >
How to validate the presence of a boolean field in a Rails ...
A subtle bug happens when validating the presence of boolean fields in Rails. Here's how to find it before it hits production.
Read more >
OOXML Validator
A VS Code extension for validating Office Open XML files. Installation ... If no value is set or the value is not valid,...
Read more >
DocumentFormat.OpenXml 2.20.0
The Open XML SDK provides tools for working with Office Word, Excel, and PowerPoint documents. It supports scenarios such as:
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found