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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:38:17+00:00 2026-06-12T07:38:17+00:00

I have a excell file with 10 sheets with headers in row 1. I’m

  • 0

I have a excell file with 10 sheets with headers in row 1.
I’m using this bit of code to get a range of those headers. That part works fine.

 string  lastColumn      = worksheet.Cells.SpecialCells(XlCellType.xlCellTypeLastCell).Address[Type.Missing].Substring(1, 1);
            Range   amountRange     = worksheet.Range["A1", string.Format("{0}1", lastColumn)];

The thing is I’ getting a new sheet with the same headers, but I have to add one dinamically. I have to read it from a DB.

So if I change the code to this, I get just the last column. No sweat.

string  lastColumn      = worksheet.Cells.SpecialCells(XlCellType.xlCellTypeLastCell).Address[Type.Missing].Substring(1, 1);
                    Range   amountRange     = worksheet.Range[string.Format("{0}1", lastColumn)];

But what I want is to get the last column plus one and I’m struggling with it.
My first thought was lastColumn + 1, but it does not work.
Any ideas.
Rui Martins?

  • 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-12T07:38:18+00:00Added an answer on June 12, 2026 at 7:38 am

    I solved it myself.

    After getting the column name of the last column, I converted it to a number, added 1 and then converted back into a column name.

    That easy.

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

Sidebar

Related Questions

I have the this code that will create excel file and work sheet then
Hello I have this code where i create an xlsx file and i need
I have an excel file that I need to make some changes. I need
I have an Excel file that I need to import into a (new) Oracle
I have an excel file that I want to embed in my C# assembly.
I have an Excel file that gets external data from database table. I need
I have a excel file which contains 5 sheets in it. The 1st sheet
I have a strange problem: I have a CSV file that I read correctly
i have a code that works on all files in folder and analyise it
I currently have an excel file (.htm) that I use as a template for

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.