Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EPPlus C# x axis type "Text axis"

I am using EPPlus for creating excel with charts. I am struggling now for 2 days to set the x axis type to "text axis" and not "automatically select...". Can somebody help me how to achieve this?

enter image description here

Thanks in advance

like image 501
opitzh Avatar asked Feb 20 '26 07:02

opitzh


1 Answers

Already solved by myself. For everyone who is interested in, following code did the trick:

var chartXml = chart.ChartXml;
var nsm = new XmlNamespaceManager(chartXml.NameTable);
var nsuri = chartXml.DocumentElement.NamespaceURI;

nsm.AddNamespace("c", nsuri);
var textNode = chartXml.SelectSingleNode("c:chartSpace/c:chart/c:plotArea/c:catAx/c:auto/@val", nsm);
if (textNode != null)
    textNode.Value = "0";
like image 198
opitzh Avatar answered Feb 22 '26 21:02

opitzh