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 7921677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:40:34+00:00 2026-06-03T16:40:34+00:00

Hope you can help. I’m looking for a way to build an excel sheet

  • 0

Hope you can help.

I’m looking for a way to build an excel sheet range by just passing in some parameters. My method is as follows:

private void TableCellformatting(int rowStart, int rowEnd, char colStart, char colEnd)
    {
        char temp;
        StringBuilder s = new StringBuilder();
        excelSheetRange = null;
        for (int i = rowStart; i <= rowEnd; i++)
        {
            temp = colStart;
            while (temp <= colEnd)
            {
                if (s.Length > 0)
                    s.Append(", ");
                s.Append(string.Format("{0}{1}", temp.ToString(), i));
                temp++;
            }
        }
        excelSheetRange = excelSheet.get_Range(s.ToString());
        excelSheetRange.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter;
    }

This runs ok until the excelSheet.get_Range part is called. When I pass in the cell numbers manually, I have to do it like this:

get_Range("A1", "A2" etc...)

Any ideas if this is even possible, or if there is another way?

Thanks!

  • 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-06-03T16:40:36+00:00Added an answer on June 3, 2026 at 4:40 pm

    Use worksheet.range property.

    excelSheetRange = excelSheet.Range[excelsheet.Cells[rowstart, colstart], excelsheet.Cells[rowend, colend]];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hope someone can help me out with this problem I am having. I just
Hope you can help. Is there a way to reliably detect when a stored
hope someone can help. just cannot get a new window to open in Firefox
Hope somebody can help me out of this confussion. I made this method: public
hope some can help - my webservice returns an object with certain fields i
hope you can help me with this one… I saw some crazy behavior so
Hope somebody can help me. I am just learning C# and I have a
hope you can help me, again :) i want to build a little webbased
I hope you can help me with my little problem here. I'm just starting
hope someone can help. I have two tables: Users -UserID -UserName UsersType -UserTypeID -UserID

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.