Home > other >  Read excel cell styling and formatting in C#
Read excel cell styling and formatting in C#

Time:07-12

I have an excel file located on SharePoint. I am reading the excel file in C# using OpenXML. While reading the data, I also need the information of any styles that are been added to the cells.

If there is any cell that has been added a background color to, How can I read it in C# ?

CodePudding user response:

Have a look at this you will find some references about foreground color and background color of cell Nuget Package

I hope it can help you!

CodePudding user response:

That's as simple as following:

using Excel = Microsoft.Office.Interop.Excel;
var cellColor  = sheet.Cells[rowIndex, colIndex].Style.Fill.BackgroundColor;

Other style refer:

https://docs.microsoft.com/en-us/dotnet/api/microsoft.office.tools.excel.workbookbase.styles?view=vsto-2017

  • Related