Skip to content

An exception occurred while getting the layoutid attribute of the series instance in the chart #1141

@TheUnknowName

Description

@TheUnknowName

Before submitting an issue, please fill this out

Is this a:

  • Issue with the OpenXml library
  • DocumentFormat.OpenXml.Office2016.Drawing.ChartDrawing
  • Question on library usage
    image

Description
I'm try get the enumeration value from LayoutId attribute of the chart,but an exception is thrown here。
Because of the 'funnel' is not a available enumeration value in the SeriesLayout type.

Information
the exception code is shown below

            var series = CharSpace.Chart?.PlotArea?.PlotAreaRegion?.GetFirstChild<Series>();
            var seriesLayoutId = series?.LayoutId;

            try
            {
                // an exception is throw herer
                var seriesLayout = seriesLayoutId?.Value;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }

PPT file xml information:

        <cx:series layoutId="funnel" uniqueId="{ADE74266-3349-4984-B193-39D3FBD9289F}">
          <cx:tx>
            <cx:txData>
              <cx:f>Sheet1!$B$1</cx:f>
              <cx:v>系列 1</cx:v>
            </cx:txData>
          </cx:tx>
          <cx:dataLabels>
            <cx:visibility seriesName="0" categoryName="0" value="1" />
          </cx:dataLabels>
          <cx:dataId val="0" />
        </cx:series>
  • .NET Target: net6.0
  • DocumentFormat.OpenXml Version: (ie 2.15.0)

Observed
Exception stack:

System.FormatException
  HResult=0x80131537
  Message=The text value is not a valid enumeration value.
  Source=DocumentFormat.OpenXml
  StackTrace:
   在 DocumentFormat.OpenXml.EnumValue`1.Parse(String input)
   在 DocumentFormat.OpenXml.OpenXmlSimpleValue`1.get_Value()
   在 Cvte.PptxToEnbx.Converters.ElementConverters.ChartsConverter.PlotAreaConverters.CommonChartExtensionSaveInfoConverter.SetSaveInfo(ChartSaveInfo saveInfo) 在 I:\Source\Project\pptx2enbx\Cvte.PptxToEnbx.Converters\ElementConverters\ChartsConverter\PlotAreaConverters\ChartExtensionElementConverters_\CommonChartExtensionSaveInfoConverter.cs 中: 第 43 行

  此异常最初是在此调用堆栈中引发的: 
    DocumentFormat.OpenXml.EnumValue<T>.Parse(string)
    DocumentFormat.OpenXml.OpenXmlSimpleValue<T>.Value.get()
    Cvte.PptxToEnbx.Converters.ElementConverters.ChartsConverter.PlotAreaConverters.CommonChartExtensionSaveInfoConverter.SetSaveInfo(Cvte.Paint.Chart.ChartSaveInfo) (位于 CommonChartExtensionSaveInfoConverter.cs 中)

Test demo : https://github.com/OpenIssues/GettingLayoutidThrowException.git
Expected
When I get the enumeration value dont throw exption.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions