Copy A Worksheet

Dec 4, 2012 at 11:32 PM

Is there an ExtremeML method for copying an existing worksheet withing a workbook?

I'm thinking of the situation where I use a Workbook as a template. Within the workbook are a couple of worksheets which are also to be used as templates. I would create several copies of the worksheet within the workbook and then populate them with data.

I know there is a non-ExtremeML solution ( but I wanted to remain within the ExtremeML framework as I think it's really simplified my development process so far (Thanks Tim Coulter)

Dec 5, 2012 at 6:09 AM

Hi Mike,

The short answer to your question is "no" (although it would probably be possible for you to build some code around ExtremeML that implements this functionality specifically for your needs).

The reason it has not been included out-of-the-box is that this is actually a potentially complex operation that could easily break, depending on a range of conditions that might be present in the original workbook. For example, if your workbook contains references between worksheets, the operation is more intricate than if the worksheets are completely independent. This scenario is not addressed in the blog post that you mentioned. The goal with ExtremeML has always been to expose functionality that is robust enough to cope with any workbook, but this operation would require some quite major engineering to ensure that it accommodates all circumstances.

Nonetheless, if your own data scenario is quite simple, you could apply the tutorial technique in a project that uses ExtremeML. Keep in mind that ExtremeML wraps the OpenXML SDK, so all of its underlying objects and functionality are still there and available to you.

Sorry, I don't have a code sample, but you would essentially be applying the same technique as in the blog post. I recommend that you test it thoroughly against a selection of your own workbooks to make sure it properly handles any peculiarities of your use case.

Good luck,