[WinForm]
***Updated with Excel spreadsheet (Template.zip) and a simple Project (ReadExcelMap.zip) attachment.
Reference: https://docs.telerik.com/devtools/winforms/knowledge-base/import-data-from-excel
Question: How to get the Cell background color while importing from Excel spreadsheet?
E.g. The spreadsheet below with value and background color.
Import Spreadsheet:
XlsxFormatProvider formatProvider = new XlsxFormatProvider();
Workbook workbook = formatProvider.Import(File.ReadAllBytes(@"C:\temp\Template.xlsx"));
var worksheet = workbook.Sheets[0] as Worksheet;
var table = new DataTable();
CellSelection selection = worksheet.Cells[3, 25];
ICellValue value = selection.GetValue().Value;
CellValueFormat format = selection.GetFormat().Value;
CellValueFormatResult formatResult = format.GetFormatResult(value);
string result = formatResult.InfosText;
I could not find the relevant functions. Attempted the following but not working:
IFill f = selection.GetFill().Value; ThemableColor c = selection.GetForeColor().Value;