Open-XML-SDK
Open-XML-SDK copied to clipboard
An exception occurred while getting the layoutid attribute of the series instance in the chart
Before submitting an issue, please fill this out
Is this a:
- [x] Issue with the OpenXml library
- DocumentFormat.OpenXml.Office2016.Drawing.ChartDrawing
- [x] Question on library usage
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.
@RafaelLxf I'll run through your repo, thanks for reporting this.
@RafaelLxf
Yes you're right, the enum is missing some chart types. We'll get this updated and you'll see a PR soon.
Thanks for bringing this to our attention!
@RafaelLxf
take a look at #1195. that should fix the issue with the Chart enums. You can test by cloning that branch and building and using the assembly as your target reference in your project.
@tomjebo After I updated DocumentFormat.OpenXml
to 2.18.0 version, the test demo can work well. Thank you.