Open-XML-SDK icon indicating copy to clipboard operation
Open-XML-SDK copied to clipboard

Bug in class DocumentFormat.OpenXml.Office2019.Drawing.Chart.BooleanFalse

Open skrabbe001 opened this issue 1 year ago • 1 comments

The class DocumentFormat.OpenXml.Office2019.Drawing.Chart.BooleanFalse creates xml different from that created by PowerPoint

Observed behavior
When using the SDK, it generates xml that include the namespace as a prefix of the attribute val:

<c16r3:dispNaAsBlank c16r3:val="1" />

I'd assume this is the correct xml, but ...

Expected behavior
Here is the xml the PowerPoint application creates:

<c16r3:dispNaAsBlank val="1" />

It may be a bug in PowerPoint.

Context
Here is the context in which the class BooleanFalse is used to generate xml:

using C = DocumentFormat.OpenXml.Drawing.Charts;
using C16R3 = DocumentFormat.OpenXml.Office2019.Drawing.Chart;

// c:chart - c:extLst
var extLst = new C.ExtensionList();
chart.Append(extLst);

// c:chart - c:extLst - c:ext
var ext = new C.Extension() { Uri = "{56B9EC1D-385E-4148-901F-78D8002777C0}" };
ext.AddNamespaceDeclaration("c16r3", "http://schemas.microsoft.com/office/drawing/2017/03/chart");
extLst.Append(ext);

// c:chart - c:extLst - c:ext - c16r3:dataDisplayOptions16
var dataDisplayOptions16 = new C16R3.DataDisplayOptions16();
ext.Append(dataDisplayOptions16);

// c:chart - c:extLst - c:ext - c16r3:dataDisplayOptions16 - c16r3:dispNaAsBlank
var dispNaAsBlank = new C16R3.BooleanFalse() { Val = true };
dataDisplayOptions16.Append(dispNaAsBlank);

Notes
What is your opinion on this issue? Is it a bug in PowerPoint or the SDK? Or god forbid, did I make a mistake?

Desktop Information:

  • Windows 10
  • Microsoft® PowerPoint® for Microsoft 365 MSO (Version 2404 Build 16.0.17531.20190) 64-bit
  • .NET 8.0
  • DocumentFormat.OpenXml Version: 3.0.1

skrabbe001 avatar Jun 27 '24 00:06 skrabbe001

Hi @skrabbe001,

The prefix here is redundant and PowerPoint doesn't have an issue with it, so there is no problem here. I would point out however that instead of C.Extension and C.ExtensionList you should use the feature extension list classes C.ChartExtension and C.ChartExtensionList, but that won't affect the C16R3.BooleanFalse element.

mikeebowen avatar Oct 16 '24 21:10 mikeebowen