Free Support Forum - aspose.com

Copydata without erase formula

Hello, I use the following code :

var book = new Workbook();

Range targetRange = null;book.Open(@"data.csv", ';');

var sourceRange = book.Worksheets[0].Cells.CreateRange(0, 0, book.Worksheets[0].Cells.MaxDataRow + 1, book.Worksheets[0].Cells.MaxDataColumn + 1);

var targetworkbook = new Workbook();

        </p><p>targetworkbook.Open("template.xlsx");           </p><p>var sheet = targetworkbook.Worksheets[0];

targetRange = sheet.Cells.CreateRange(0, 0, book.Worksheets[0].Cells.MaxDataRow + 1, book.Worksheets[0].Cells.MaxDataColumn + 1);

targetRange.CopyData(sourceRange);

targetworkbook.Save("result.xlsx", SaveFormat.Xlsx);

Is it possible to use the copydata without loosing the formulas in the template ?

Best regards.

Hi,


Could you try using Range.Copy() method instead if it works for you.

Thank you.

Thank you for your help.

I will use the "copy" fonction with options.