Free Support Forum - aspose.com

Copying a column

My company is reviewing your product for use with one of our client projects. We like the feature set but have run up against a wall with one of our excel tasks the client requested.

We are loading up a template file (it contains a summary worksheet, and one ‘record’ worksheet).

We duplicate the record worksheet for each record then remove the template which works fine.
What we need to do next in either the summary or record worksheet is copy a column, including all formatting and formulas (but adjusted for position as it occurs in excel) and add it back into the same worksheet at a new location.

From the documentation I can’t get a firm grip on how to do this. Any ideas?

Copying a column is not supported yet. We will add this feature in the future release. Now you can use Cell.Copy method to copy them cell by cell.

Is there an example of using the cell.copy (or possibly copy range?) to copy in this way in the documentation or somewhere you can point me to?

I have a spreadsheet which has a month summary column and then columns for each day that I’m going to need to duplicate. Also, when I duplicate it does it correct the formulas for their new positions or do I need to rewrite them?

You can use Cell.Copy method or Range.Copy method.

Cell cell1 = excel.Worksheet[0].Cells[“A1”];
Cell cell2 = excel.Worksheet[1].Cells[“A1”];
cell2.Copy(cell.1);

Range range1 = excel.Worksheet[0].Cells.CreateRange(0, 0, 10, 1);
Range range2 = excel.Worksheet[0].Cells.CreateRange(0, 0, 10, 1);
range2.Copy(range1);

The formula should be corrected while copying.