Range.Copy(Range) - 1 Issue and 1 Question


#1

Hello, I am quite confused with Range.Copy(). First, I understand that there are two major versions of the method in the APIs. Version 1 copies a selected range that is not entirely row or column based. Version 2 copies a selected range that is row or column based. So I will refer to the different APIs by Version 1 and Version 2 in this posting.

Issues
1. I cannot get Version 2 of this API to work. Specifically, what I try to do is create a Range, and copy it to other Ranges that I create. This causes my CPU utilization to jump to 100%, until I kill the w3wp process. Obviously something is wrong here. I have traced through my debugger, and have indeed confirmed that on a call to your API your method doesn’t return, and CPU utilization goes to 100%.

Questions
1. What exactly is Version 1 of Range.Copy() supposed to be guaranteed to copy? I have noticed that merged cells for example don’t get copied. What by your definition therefore do you not intend to support for copying purposes? This will help me better understand what I should or shouldn’t put into a template, and when to contact you for support purposes.

Thanks
Shan Plourde


#2

Hi Shan,

I optimized the method in the latest hotfix. Please download it and have a try.


#3

Hi Laurence, the 100% CPU utilisation issue is resolved. Thank you very much for the timely update.

The only remaining item in my post is the question below:

1. What exactly is Version 1 of Range.Copy() supposed to be guaranteed to copy? I have noticed that merged cells for example don’t get copied. What by your definition therefore do you not intend to support for copying purposes? This will help me better understand what I should or shouldn’t put into a template, and when to contact you for support purposes.

You see, when I use Cells.CreateRange(int, int, bool) to create 2 ranges, then copy one range to the other, I am assuming that all formatting should be copied 100% intact. For example, I have merged cells, certain columns in the worksheet are set to a certain width, and so on.

So my question really is what do you supposed to support for copying ranges that were created with Cells.CreateRange(int, int, bool)? If you are supposed to support also copying the cell widths, and merged cells, then this is definitely not the case - it is not happening.

Let me know if this question is clear or not.

Thanks
Shan Plourde


#4

Hi Shan,

Because the created range may contains part of a merged cell, to avoid conflicts, I didn’t add support to merged cells. I will check this issue and will add this feature to Aspose.Excel. So in future release, if you create a range with a full merged cell, it will be copied. If it’s a partial merged cell, it will not be copied.

And now copying column width is also not supported. I will check this issue and add it if possible.

Now I am also work on some other features, so you have to wait for about one week for this feature.


#5

Hi Laurence,
I understand your thoughts about this. I would recommend that you design your basic Excel manipulation APIs after how Microsoft Excel itself supports basic tasks through its user interface. For example, model your copying of entire rows or columns after how Excel actually does it.

This will make the API more clear for new developers building applications with it - they will be able to use Microsoft Excel to see how a copy and paste behaves, and can then expect that that would be the same case with your APIs - where that is possible. It will also help make your libraries more clear as there are many subtleties of your APIs that are not documented such as this. It therefore becomes a matter of trial and error or guessing at times how something should behave - not a big deal because it’s not tremendously time consuming, but things to consider anyways.

Thanks again,
Shan Plourde


#6

Hi Shan,

Thanks for your suggestion. That’s very helpful.

Actually, we design our APIs after how MS Excel does it. We will shape APIs to make it consistent. If there is variance, we will add it to our documentation.