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

Free Support Forum - aspose.com

How to copy formula from one cell to a range and get relative references

Hello:

I need to copy a formula from one cell to 11 more columns to the right. I want the references in the formula to be updated just like they are in Excel when you copy one cell to many.

When I try this test code:

cells[row, 3].Formula = ("=Sum(D7:D8)");
cells[row, 4].Formula = cells[row, 3].Formula;
cells[row, 5].Formula = cells[row, 3].Formula;
cells[row, 6].Formula = cells[row, 3].Formula;

However, I get the same formula in each column.

So, can you please tell me the easiest way to copy the formula to multiple columns. (Do I have to manually calculate the range for each cell, or will Aspose create the relative references.)

Thanks,

Mark

Hi,


I think you may try to set SharedFormula (The feature is provided by Aspose.Cells) for your desired range of columns cells. See the topic for your reference:
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/setting-shared-formula.html

Thank you.