How i can change text color of CellValue in excel, i am able to change forgeround color of Cell but it changes color of all text present inside the cell which i dont want , i want to highlight only particular Text in side the Cell i.e CellValue text.
Example - if a cell contains "Microsoft is great" , i want to only highlight Microsoft not whole cell.
I am using below code to highlight Cell Text as , how it can be done for CellValue ? -
foreach(DocumentFormat.OpenXml.Spreadsheet.Cell currentCell in allCells){Fill fill =newFill(){PatternFill=newPatternFill{PatternType=PatternValues.Solid,ForegroundColor=newForegroundColor(){Rgb="FFFF00"}}};
styleSheet.Fills.AppendChild(fill);//Adding the CellFormat which uses the Fill element CellFormats cellFormats = styleSheet.CellFormats;CellFormat cf =newCellFormat();
cf.FillId= styleSheet.Fills.Count;
cellFormats.AppendChild(cf);
currentCell.StyleIndex= styleSheet.CellFormats.Count;}
I dont see any property of Style in CellValue
CellValue currentCellValue = currentCell.GetFirstChild<CellValue>();if(currentCell.DataType==CellValues.SharedString)// cell has a cell value that is a string, thus, stored else where{
data = doc.WorkbookPart.GetPartsOfType<SharedStringTablePart>().FirstOrDefault().SharedStringTable.ElementAt(int.Parse(currentCellValue.Text)).InnerText;}