I have the following:
using (ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet worksheet = workbook.ActiveSheet;
worksheet[1, 1].Text = "Products";
worksheet[1, 2].Text = "Rate";
worksheet[1, 3].Text = "Quantity";
worksheet[2, 1].Text = "Item1";
worksheet[2, 2].Number = 200;
worksheet[2, 3].Number = 2.25646;
worksheet[3, 1].Text = "Item2";
worksheet[3, 2].Number = 200;
worksheet[3, 3].Number = 2.564654;
application.EnableIncrementalFormula = true;
worksheet.Columns[2].Formula = $"=ROUND(C1, 2)";
string savePath = $"c:\\Test\\TestRound.xlsx";
workbook.SaveAs(savePath);
}
As you can see, I'm attempting to round column C but I get a circular reference error with my code above. I'd like to round as opposed to adding a number format since formats don't change the underlying value. Is there a way to do what i'm trying to do in the above? Thanks!