dotnet / dotnet/Open-XML-SDK

Element classes do not contain all child element-related properties

Open
#492 18 comments 0 reactions 1 assignee Claimed by @twsouthwick View on GitHub
enhancement schema
Dominant language
C#
Stars
4.6k
Forks
605
PR merge metrics
No merged PRs in 30d

Description

**Description**

The `DocumentFormat.OpenXml.Spreadsheet.Worksheet` class only has properties for 4 out of 38 child elements. For example, there is no property for the only mandatory child element, `x:sheetData`, which is likely among the most frequently referenced elements.

As per the schema, those child elements have to be in a defined order, which, in the absence of SDK support, needs to be ensured by the caller's code. That increases the size and complexity of the code.

**Information**

- .NET Target: all
- DocumentFormat.OpenXml Version: 3cc26570f2964a5d56a5988f9464b2e4b29812c7

**Observed**

The `Worksheet` class defines the following child elements:
```csharp
[ChildElementInfo(typeof(SheetProperties))]
[ChildElementInfo(typeof(SheetDimension))]
[ChildElementInfo(typeof(SheetViews))]
[ChildElementInfo(typeof(SheetFormatProperties))]
[ChildElementInfo(typeof(Columns))]
[ChildElementInfo(typeof(SheetData))]
[ChildElementInfo(typeof(SheetCalculationProperties))]
[ChildElementInfo(typeof(SheetProtection))]
[ChildElementInfo(typeof(ProtectedRanges))]
[ChildElementInfo(typeof(Scenarios))]
[ChildElementInfo(typeof(AutoFilter))]
[ChildElementInfo(typeof(SortState))]
[ChildElementInfo(typeof(DataConsolidate))]
[ChildElementInfo(typeof(CustomSheetViews))]
[ChildElementInfo(typeof(MergeCells))]
[ChildElementInfo(typeof(PhoneticProperties))]
[ChildElementInfo(typeof(ConditionalFormatting))]
[ChildElementInfo(typeof(DataValidations))]
[ChildElementInfo(typeof(Hyperlinks))]
[ChildElementInfo(typeof(PrintOptions))]
[ChildElementInfo(typeof(PageMargins))]
[ChildElementInfo(typeof(PageSetup))]
[ChildElementInfo(typeof(HeaderFooter))]
[ChildElementInfo(typeof(RowBreaks))]
[ChildElementInfo(typeof(ColumnBreaks))]
[ChildElementInfo(typeof(CustomProperties))]
[ChildElementInfo(typeof(CellWatches))]
[ChildElementInfo(typeof(IgnoredErrors))]
[ChildElementInfo(typeof(Drawing))]
[ChildElementInfo(typeof(LegacyDrawing))]
[ChildElementInfo(typeof(LegacyDrawingHeaderFooter))]
[ChildElementInfo(typeof(DrawingHeaderFooter))]
[ChildElementInfo(typeof(Picture))]
[ChildElementInfo(typeof(OleObjects))]
[ChildElementInfo(typeof(Controls))]
[ChildElementInfo(typeof(WebPublishItems))]
[ChildElementInfo(typeof(TableParts))]
[ChildElementInfo(typeof(WorksheetExtensionList))]
```
However, the `Worksheet` class only provides the following properties:
```csharp
///
/// SheetProperties.
/// Represents the following element tag in the schema: x:sheetPr
///
///
/// xmlns:x = http://schemas.openxmlformats.org/spreadsheetml/2006/main
///
public SheetProperties SheetProperties
{
get => GetElement(0);
set => SetElement(0, value);
}

///
/// SheetDimension.
/// Represents the following element tag in the schema: x:dimension
///
///
/// xmlns:x = http://schemas.openxmlformats.org/spreadsheetml/2006/main
///
public SheetDimension SheetDimension
{
get => GetElement(1);
set => SetElement(1, value);
}

///
/// SheetViews.
/// Represents the following element tag in the schema: x:sheetViews
///
///
/// xmlns:x = http://schemas.openxmlformats.org/spreadsheetml/2006/main
///
public SheetViews SheetViews
{
get => GetElement(2);
set => SetElement(2, value);
}

///
/// SheetFormatProperties.
/// Represents the following element tag in the schema: x:sheetFormatPr
///
///
/// xmlns:x = http://schemas.openxmlformats.org/spreadsheetml/2006/main
///
public SheetFormatProperties SheetFormatProperties
{
get => GetElement(3);
set => SetElement(3, value);
}
```

**Expected**

Given that the child elements must be in a defined order, the `Worksheet` class defines properties for all child elements.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.