Formula lost with Worksheet.Copy()


#1

I'm using Aspose.Excel v3.6.3 and I'm seeing formulas missing in a worksheet that has been copied from another worksheet. One of the specific formulas is:

=IF(OR($B$9="",$B$9=0),"",ROUND(B49/$B$9,-3)/1000+IF(B49<>0,C52-(SUM(C50:C51)+ROUND(B49/$B$9,-3)/1000),0))

I don't have any control over these formulas so I need for them to be copied correctly. Other formulas do get copied correctly as you will see in my sample. The code that I'm using is as follows and I'm providing the solution including sample .xls workbooks with formulas that aren't working (2 that aren't and 2 that are working).

Thanks!

Excel template = new Excel();
Excel dest = new Excel();
template.Open(AppDomain.CurrentDomain.BaseDirectory + "..\\..\\files\\template.xls");
dest.Open(AppDomain.CurrentDomain.BaseDirectory + "..\\..\\files\\dest.xls");

Worksheets sheets = dest.Worksheets;
int j = sheets.Add();
sheets[j].Copy(template.Worksheets[0]);
dest.Save(AppDomain.CurrentDomain.BaseDirectory + "..\\..\\output\\output.xls");


#2

Please try this attached fix.