ClosedXML / ClosedXML

ClosedXML is a .NET library for reading, manipulating and writing Excel 2007+ (.xlsx, .xlsm) files. It aims to provide an intuitive and user-friendly interface to dealing with the underlying OpenXML API.
MIT License
4.79k stars 837 forks source link

How to copy shape to another sheet #1308

Open juliep10 opened 5 years ago

juliep10 commented 5 years ago

Read and complete the full issue template

Do you want to request a feature or report a bug?

If you are logging a possible bug or feature request, please test with the latest development build first.

Version of ClosedXML

e.g. 0.94.2

What is the current behavior?

Its not copying the shape from one sheet to another sheet in same workbook.

What is the expected behavior or new feature?

Want to copy the sheet same as it's including shape to another sheet.

Did this work in previous versions of our tool? Which versions?

No

Reproducibility

This is an important section. Read it carefully. Failure to do so will cause a 'RTFM' comment.

Without a code sample, it is unlikely that your issue will get attention. Don't be lazy. Do the effort and assist the developers to reproduce your problem. Code samples should be [minimal complete and verifiable](https://stackoverflow.com/hel tpl_Org.xlsx Test_copy.xlsx

p/mcve). Sample spreadsheets should be attached whenever applicable. Remove sensitive information.

Code to reproduce problem:

Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'Accessing the tpl_Org worbook which have sheet which contain shape.
    Dim wb = New XLWorkbook("D:\\ExcelReport\\tpl_Org.xlsx")
        Dim ws = wb.Worksheet(1)
'Create new sheet same as first sheet.
        wb.Worksheet(1).CopyTo("Sheet2")
        wb.SaveAs("D:\\ExcelReport\\Test_copy.xlsx")
End Sub
igitur commented 5 years ago

Besides pictures, there's no guarantee that any other shapes will work in ClosedXML yet.

juliep10 commented 5 years ago

Is there any other way using which we can create or copy the sheet to another sheet which is having shape in side it?

igitur commented 5 years ago

It's possible, but difficult, by using OpenXML directly. I don't know how to do it myself, though.

You can try one of the other 3rd party libraries, e.g. EPPlus too. Maybe they have shape support. I don't know.