epplus excel download conditional formatting compatibility issues excel 2013
Hi All,
i downloading excel sheet in application and created dropdown based search in excel using EPPLUS in my MVC application excel sheet working fine excel 2016 version but its not working in excel 2013
I am using EPPLUS Version=4.5.3.2
i am getting error like
Removed Feature: Conditional formatting from /xl/worksheets/sheet1.xml part
after excel can able to open but it showing repaired excel also not working conditional formatting what i have applied below is my code
var currentWorksheet = ExcelPkg.Workbook.Worksheets.First();
currentWorksheet.Workbook.CalcMode = ExcelCalcMode.Automatic;
int row = numberofrows;
int col = numberofcolumns;
string startCell = "B3";
foreach (var item in parts)
{
string statement = "=$C$" + FormsCount + " = " + "\"" + "" + item.RarityName + "\"";
AddConditionRange(currentWorksheet, row, col, 2, StartCoumn, statement, item.RarityName);
}
ExcelPkg.SaveAs(stream);
private void AddConditionRange(ExcelWorksheet currentWorksheet, int row, int col, int startCol, int startRow, string statement, string color)
{
string addressRange = "";
for (int i = startRow; i <= startRow + row - 1; i++)
{
for (int j = startCol; j <= startCol + col - 1; j++)
{
// ExcelAddress _formatRangeAddress = new ExcelAddress("$A$" + i);
//ExcelAddress _formatRangeAddress = new ExcelAddress(i, j, 0, 0);
string val = currentWorksheet.Cells[i, j].Value.ToString();
if (currentWorksheet.Cells[i, j].Value.ToString().Contains(color))
{
string startColStr = "";
startColStr = GetAlpFromNum(j, ref startColStr);
// f.Address.Address = f.Address.Address + "," + "$" + startColStr + "$" + i;
addressRange = addressRange + "," + "$" + startColStr + "$" + i;
}
}
}
string address= addressRange.TrimStart(',');
OfficeOpenXml.ConditionalFormatting.Contracts.IExcelConditionalFormattingExpression f = currentWorksheet.ConditionalFormatting.AddExpression(new ExcelAddress(address));
f.Style.Fill.BackgroundColor.Color = Color.Gray;
f.Style.Font.Color.Color = System.Drawing.Color.Green;
f.Formula = statement;
}