Worksheet.get_Range() is slow

O

Oleg Ogurok

Hi all,

I'm creating a rather large XLS file (1000 complex sheets) using C#/interop
automation. It currently takes about 3 hours to process DB data and generate
the output into XLS. I've run nprof, a free .NET profiler, on my application
and noticed that the majority of time is spent on get_Range() calls.


Excel.Range rng2 = (Excel.Range)sheet.get_Range("C5", Missing.Value);

Since most of the time I only need to edit one cell at a time, I'm looking
for a method that works faster at returning a cell. Excel.Worksheet object
has a Cells property with an indexer, e.g. to get cell C5 I can do this:


Excel.Range allCells = sheet.Cells;

Excel.Range rng = (Excel.Range)allCells[5, "C"];


However, the call to the indexer of Cells take even longer (about twice as
long) than getRange() does:
Is there any way to optimize cell access? Thanks.



-Oleg.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top