Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7398549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T03:53:00+00:00 2026-05-29T03:53:00+00:00

I have some operation that requires to iterate through 3000 excel cell. Problem is

  • 0

I have some operation that requires to iterate through 3000 excel cell. Problem is that this my code seems pretty bad on performances. I done a little investigation with Stopwatch class to see where do I lose time. My operation lasts for 24 seconds, and just one line of code there consumes 17 seconds. I’m using this code is my class return cell name from cell reference.

public string GetCellName(Range cell)
        {
            string name = "";
            try
            {
                name = cell.Name.Name;
            }
            catch { }
            return name;
        }

It seems really odd to me that this simple code consumes this much time. There are some other parts that should taken longer, for example little for loop with 6-8 elements.
I tried to write this method this way:

public string GetCellName(Range cell)
        {
            if (cell.Name == null) return "";
            else if (cell.Name.Name == null) return "";
            else return cell.Name.Name;
        }

But than it throws an exception. Do you have any suggestion on how to retrieve Name of excel cell efficiently?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T03:53:01+00:00Added an answer on May 29, 2026 at 3:53 am

    I found that most efficient way is to minimize communication between COM and .NET API. The way to do that is to use

    range.get_Value(XlRangeValueDataType.xlRangeValueXMLSpreadsheet); 
    

    which returns XML format with all the information. Also is possible to use

    Range.set_Value(XlRangeValueDataType.xlRangeValueXMLSpreadsheet, myStr);
    

    for populating range with some values.

    So you’ll have only one call to COM for getting all values no matter how big your range is, instead calling it once or more for every cell in range. This way you can also format styles to particular cells/range parts, set name for cells/range parts and all the rest.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say you have a business logic method that can perform some operation across
I have bat-file, that make some operations. How to run this file from Delphi
I have some code using Lucene that leaves the default conjunction operator as OR,
I have a somewhat expensive server-side operation that produces an image and some associated
I have some C# unit tests that perform some float/double operations and I would
I have a php that makes some maintenance operations in my web and I
I have a page where when some operation goes wrong i want to start
How can I have SQL repeat some set-based operation an arbitrary number of times
I have some Java code which performs bitwise operations on a BitSet. I have
I have some web forms that I'm bringing over with AJAX, and as I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.