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

Free Support Forum - aspose.com

Copy Sheets between workbooks

Hi Team,

We are facing issues with copying of sheets between workbooks. Request you to please help.

We have requirement to copy all sheets from one workbook to another. The sheets have various shapes like button, dropdown etc and a number of named ranges. The problem we are facing is the shapes are not getting copied properly. It is getting misplaced or overlapped at some places. Also the named ranges are losing the values.

I am using the following codes to copy sheets. please suggest is this the right way

Private Sub CopySheets()
''Copy the sheets from tmpWorkBook File to the new file
For index As Integer = 0 To SheetListCol.Count - 1
If Not (SheetListCol.Item(index).ToString() = “Index”) Then
Dim cpOptions As New Aspose.Cells.CopyOptions
cpOptions.CopyNames = True
cpOptions.CopyInvalidFormulasAsValues = True
Dim copySheet As Aspose.Cells.Worksheet = tmpWorkBook.Worksheets.Add(SheetListCol.Item(index).ToString())
copySheet.Copy(newWorkBook.Worksheets(SheetListCol.Item(index).ToString()), cpOptions)
If copySheet.IsProtected Then
copySheet.Unprotect(“XXXX”)
End If
End If
Next
End Sub

Thanks

Anish

Hi,


Please download and try our latest fix/version: Aspose.Cells for .NET v7.5.0.2 if it works fine.

If you still find the issue, I am afraid, we need your template file(s) and complete runnable sample code to reproduce the issue on our end, so we could log it into our database (if we found the issue) to figure it out soon.

Thank you.

Thanks for the reply

We are currently using "Aspose.Cells for .NET v7.5.0.0" in our application. We would like to know if there was any major changes (specifc to copy sheets) in the new release specified by you.

Basically we need a confirmation like all the existing functionalities will work as it is if we migrate to a new version.

The problem is replacing to new version require considerable amount of testing of other functionalities of our existing application which may not be a feasible solution at this time.

Thanks
Anish

Hi,


Well, there are no major changes regarding copy worksheets, we included a few enhancements and fixed a few issues regarding rendering to PDF, rendering charts, pivot tables, reading/writing Excel files etc. And, your existing functionality or features works fine, so you may try the latest fix without any problem.

We need your template file(s) and complete runnable sample code to reproduce the issue on our end, so we could log it into our database (if we found the issue) to figure it out soon.

Thank you.