We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Appending string in Excel formula


I am having following requirement.

Suppose in Cell A1, I am having Value as 10.

Now I want to append string "Total Number of Days" + Cell A1 value in other Cell.

In normal excel file , we can write formula like

="Total Number of Days"&A1

But for the above thing, how to do using C#.

I used below code, its not working

string str="\"Total Number of Days\"";

workSheet.Cells[3,1].Formula="="+ str + "A$1";

Please any one can help out.

Hi Jack,

Thank you for contacting Aspose support.

You can achieve your requirement either using Excel formula or simply concatenating the strings before setting it to the cell value. Both approaches are demonstrated below for your reference.


var book = new Workbook();
var cells = book.Worksheets[0].Cells;
cells[“A2”].Formula = “=CONCATENATE(“Total Number of Days”,” “,A1)”;
cells[“A3”].PutValue("Total Number of Days " + cells[“A1”].Value);
book.Save(“D:/temp/output.xlsx”, SaveFormat.Xlsx);

Please feel free to write back in case you have further questions or concerns.