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

Free Support Forum - aspose.com

Copy one sheet from the source workbook to destination workbook

Hello Aspose,
I want to copy the worksheet from source workbook to destination workbook using Aspose c#. The problem is that the source workbook sheet has the formulas in it and want to copy only the data without formulas to the destination workbook. Please help me out with example.

Thanks in Advance


You may try to to use Worksheet.Cells.RemoveFormulas() method for your source worksheet in the source workbook before copying it to destination workbook. This will replace underlying formulas with calculated values in the cells. See the following sample code for your reference:
Sample code:

            //Instantiate a Workbook object that represents the your source Excel file
            Workbook _workbook = new Workbook("e:\test2\Sample.xlsx");
            //your destination workbook.
            Workbook workbook = new Workbook();
            Clear existing worksheet(s) and add a new sheet named "Report" to it.
             //Remove formulas by calculated results in your source sheet e.g. named "Report" which is to be copied to other workbook.
            //Get your source sheet in the source workbook
            Worksheet worksheet = _workbook.Worksheets["Report"];
            //Copy from source to destination
            //Save your destination file.

Hope, this helps a bit.

Thank you, I will try that.

Hey, it worked thank you very much.

You are welcome.