Last post Aug 24, 2009 08:23 AM by deshjyoti
Aug 21, 2009 03:58 PM|Apples|LINK
I'm create an excel spreadsheet dynamically using Excel Interop.
I have two cells in a single column.
The first cell contains this formula: "=(F1+G1)"
I would like to set the formula for the second cell to be the same as the first cell, but have F2 and G2 instead of F1 and G1. This needs to be dynamic.
Here's what I have now:
Excel.Range rngCurrentCell = (Excel.Range)ws.Cells[row,col];
Excel.Range rngPrevRow = (Excel.Range)ws.Cells[row - 1, col];
rngCurrentCell.Formula = rngPrevRow.Formula;
I thought the code above would work, but that just sets the second cell to have the formula: "=(F1+G1"
Aug 24, 2009 08:23 AM|deshjyoti|LINK
In the Excel, if you drag the a formula, then automatically increment happens for the cell.
If you cut and paste the same formula to some other cell then it works.