I am devloping a exe application using C# language.I would like to write a sum formula to a cell called Total, so that user may key in extra information in the excel generated by system and it is automatically reflected in the cellcalled total.
Below is the format of the excel file generated by system
Group1 ItemA Qty1(generated in system)
ItemB Qty2(generated in system)
ItemC Qty3(key in by user)
Total Sum of (Qty1+Qty2+Qty3) .Formula=Sum(C1:C3)
Group2 until group n
I have try with the code
objExcel.Cells[iRow, 3].Formula = "=SUM(C1:C3)";
but it is not working.It only sum the value from cell C1 to C3, but the formula is not written to the cells.
When user updating qty for itemC, it is not reflected in the total cell.
Does anyone has idea on this?
have you tried locking the cells eg. SUM($C$1:$C$3), either than that I've also had little luck with excel programming.
Try the below.
string formula = string.Format("=HYPERLINK(\"#{0}!{1}\", \"{2}\")", worksheet, cellRef, string.Format("Hyperlink number {0}", count));
More information can be found in the following link which I think could be a possible duplicate.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.