Hi
Hi,
Thanks for your posting and considering Aspose.Cells for .NET.
Please look into the following code, it copies your desired formula in first 100 rows of column C.
I have also attached the output.xls file for your reference generated by this code.
Please also see the screenshot.
C#
//Create a workbook
Workbook workbook = new Workbook();
//Acess the first worksheet
Worksheet worksheet = workbook.Worksheets[0];
//Template formula
string templateFormula = “B{r}-A{r}”;
//Copy your desired formula in first 100 cells of column C
for (int i = 0; i < 100; i++)
{
string formula = templateFormula.Replace("{r}", (i + 1 + “”));
worksheet.Cells[“C” + (i + 1 + “”)].Formula = formula;
}
//Save your workbook in xlsx format
workbook.Save(@“F:\Shak-Data-RW\Downloads\output.xlsx”);
Screenshot: