1

Charts created by EPplus in C# is not displaying in LibreOffice and OpenOffice, but they are displayed properly in Microsoft office.

There is one workaround, if i open the excel file in microsoft office and then save it again that file charts are visible properly on Libreoffice and OpenOffice.

Charts displayed in Microsoft office as shown in below picture: open in Microsoft excel viewer

Charts displayed in LibreOffice and OpenOffice as shown in below picture. OpenOffice image

Is there any property that i need to set while saving the charts using EPPlus so that it can be viewed in OpenOffice.

Rahul Singh
  • 65
  • 1
  • 4

1 Answers1

1

I had this problem too and had to do compare the generated files with saved files and look through the source code to find out how to do it:

For a line chart:

ExcelLineChartSerie serie = (ExcelLineChartSerie)chart.Series.Add(...);
serie.Marker = eMarkerStyle.None;
serie.LineColor = Color.FromArgb( 0x00, 0x45, 0x86 );

For a bar chart:

ExcelChartSerie serie = chart.Series.Add(...);
serie.Fill.Style = eFillStyle.SolidFill;
serie.Fill.Color = Color.FromArgb( 0x00, 0x45, 0x86 );

I haven't used other charts yet so there may be some other fields to be initialized.

Update:

I saw that my charts also had no axes and had to find out how to convince libreoffice to draw them:

chart.XAxis.Border.Fill.Style = eFillStyle.SolidFill;
chart.XAxis.Border.Fill.Color = Color.FromArgb( 0x00, 0x00, 0x00 );
chart.YAxis.Border.Fill.Style = eFillStyle.SolidFill;
chart.YAxis.Border.Fill.Color = Color.FromArgb( 0x00, 0x00, 0x00 );
Martin
  • 361
  • 1
  • 3
  • 7
  • thanks for you reply, but what i understood is if you are using EPPlus then you have to explicitly set the style and color to each graph then only it works in libre office. – Rahul Singh Aug 25 '21 at 04:13