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

Free Support Forum - aspose.com

Range.CopyValue not working

Hi,

I want to perform the equivalent of selecting a range, copying then pasting values only over the same range (to get rid of the formulae). In code, it appears easy enough as shown below. Looking at earlier forum entries, the problem appears to be fixed in an earlier version but it’s definitely not working for me. Anyone have advice?

Dim SourceRange As Range = wsAnalysis.Cells.CreateRange(“A1”, “Q20”)


Dim DestRange As Range = wsAnalysis.Cells.CreateRange(“A1”, “Q20”)

DestRange.CopyValue(SourceRange)

Hi,


Could you give us your template file here, we want to check the issue with your file using the latest version/fix v7.0.0.x.

Thank you.

It fails on the simplest case, attached. I open the workbook, set the ranges, copyvalue but the resulting spreadsheet still has the formulas, not the values.

Thanks for checking it out.

Hi,


Thanks for the sample file.

I think for your need, you may try the following sample code, it will suit your needs.

Sample code:
Workbook workbook = new Workbook(“e:\test2\AsposeTest.xlsx”);
Worksheet worksheet = workbook.Worksheets[0];

Range rangeSource = worksheet.Cells.CreateRange(“A1:B3”);
DataTable dt = rangeSource.ExportDataTable();
worksheet.Cells.ImportDataTable(dt, false, rangeSource.FirstRow,rangeSource.FirstColumn,false);
workbook.Save(“e:\test2\outAsposeTest.xlsx”);

Thank you.