Posted 4 December 2024, 6:55 am EST - Updated 4 December 2024, 6:57 am EST
In our application, we dynamically generate three columns by shifting the last column to the right to create space for these new columns. After that, we copy the format and formulas from the shifted column to the newly generated columns. However, for some rows, the formulas are copied correctly, while for others, they are not. Specifically, we observed that after row 86, the formulas in the newly generated columns reference incorrect cells.
Below is the code we used for Insert and Copying
For Insert
sheet.Range[7, 9, 80,3].Insert(InsertShiftDirection.Right);
Copy Formula and format
for (var i = 0; i < 3; i++)
{
sheet.Range[7, 12, 80, 1].Copy(sheet.Range[7, 9 + (i)], PasteType.Default);
}
NOTE: For more details, you can refer to the formula in column J of the attached original_sheet.xlsx.
After dynamically generating the column, you can refer to the formula in column J. However, after row 86 in AfterGenerate.xlsx, the reference changes to column G.
this issue is replicating on **gc **spread and FarpointOrignal_Sheet.zipAfterGenerate.zip