Quantcast
Channel: ClosedXML - The easy way to OpenXML
Viewing all articles
Browse latest Browse all 1877

New Post: Copying ranges with formulas using absolute references

$
0
0
Hi

I have a template file that is populated from my database. So I insert a new row for each record of my DB and in this new rows I need to copy the formulas of the previous rows, some of these formulas have absolute references for example

=IF($D$33,U10/(1-W10),0)

and I would expect that on the next row the copied formula should be

=IF($D$33,U11/(1-W11),0)

but instead I'm getting

=IF($D$32,U11/(1-W11),0)
=IF($D$31,U12/(1-W12),0)


My code looks somethin like this
int prevRowNo = currentRowNo - 1;
var prevRow = oSheet.Row(prevRowNo);
prevRow.InsertRowsBelow(1);
               
//var currentRange = oSheet.Range("A" + setIdx.ToString(), "AZ" + setIdx.ToString());     
var PrevRange = oSheet.Range("$A$" + prevRowNo.ToString() + ":$AZ$" + prevRowNo.ToString());
oSheet.Cell(CurrentRowNo, "A").Value = PrevRange;
I don't know if I'm doing something wrong,

Thanks

Viewing all articles
Browse latest Browse all 1877

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>