how to quickly copy columns using epplus?

Sep 2, 2011 at 3:43 AM
Edited Sep 2, 2011 at 5:02 AM

Hi,
I want to move columns (eg. from column H --> column B) and each column has many cells.
my current method is to copy cell by cell:
new_sheet.cells[i,new_col].value=old_sheet.cells[i,old_col];
or .copy method


But it acts far too slow
Is there any solution much quicker? like copy an entire column to another sheet?

Coordinator
Sep 20, 2011 at 8:48 PM

Hi,

You can use the Range.Copy method, but it will still be slow.

The problem is that when you copy cells by column the internal index will have to sort for every cell with the current desigen. So the best approch is to load a cell from Left to right, up to down.

A workaround, if you know the number of columns to be created is to make sure the cells are created before you start to copying.

You can do something like this (the address is just an example)...

Worksheet.Cells["A1:Q1000"].Value=null;
Not very pretty, but should make the copy faster.
Jan