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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:20:23+00:00 2026-06-09T16:20:23+00:00

UPDATE1: I am using Excel 2010 and I’ve searched the web and found thousands

  • 0

UPDATE1:

I am using Excel 2010 and I’ve searched the web and found thousands upon thousands of ways to do this via win form, console, etc. But I can’t find a way to do this via DLL. and none of the sample on-line is complete all in bit and pieces.

UPDATE END

I have looked and goggled but did not get the specific what i am looking for, as show below the excel sample sheet.

i’m looking a way to read and store the each cell data in a variable

i have started something like this:

Workbook workbook = open(@"C:\tmp\MyWorkbook.xls");
IWorksheet worksheet = workbook.Worksheets[0];
IRange a1 = worksheet.Cells["A1"];
object rawValue = a1.Value;
string formattedText = a1.Text;
Console.WriteLine("rawValue={0} formattedText={1}", rawValue, formattedText);

Excel sheet

  • 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-09T16:20:25+00:00Added an answer on June 9, 2026 at 4:20 pm

    Your code can work with a couple changes.

    One thing to remember is that Excel worksheets are 1-based, not 0-based (and use Worksheet instead of IWorksheet):

    Worksheet worksheet = workbook.Worksheets[1];
    

    And to get a range, it is easiest to call get_Range() on the worksheet object (and use Range instead of IRange):

    Range a1 = worksheet.get_Range("A1");
    

    With those two lines of code changed, your example will work fine.

    UPDATE

    Here is a “complete” example:

    1. Right-click your project in the solution explorer and click “Add
      Reference”.
    2. Click on the COM tab and sort the list by Component Name. Find “Microsoft Excel 14.0 Object Library” in the list and select it. Click OK.
    3. In the code file where you want this to run, add a using Microsoft.Office.Interop.Excel;
    4. Use this code, which I’ve modified as little as possible from your example:

    var excel = new Microsoft.Office.Interop.Excel.Application();
    Workbook workbook = excel.Workbooks.Open(@"C:\tmp\MyWorkbook.xls");
    Worksheet worksheet = workbook.Worksheets[1];
    Range a1 = worksheet.get_Range("A1");
    object rawValue = a1.Value;
    string formattedText = a1.Text;
    Console.WriteLine("rawValue={0} formattedText={1}", rawValue, formattedText);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the Camera feature in excel 2010. My goal is to have
i am connecting to a mysql database through excel using odbc what does this
I am interested in using C# to manipulate/Automate Excel files. After browsing the web
Using NPOI and attempting to follow a tutorial here: http://www.zachhunter.com/2010/05/npoi-excel-template/ , I'm coming across
We have an application that is built with Excel as the front end using
i am using excel to connect to a mysql database: Dim dpath, atime, rtime,
i am connecting to mysql from excel using odbc. the following illustrates how i
i am adding data from vba excel using adodb into a mysql database everything
Using: Excel 2007. Problem: A spreadsheet contains many columns and rows of data. One
I used the code described here to update an excel sheet using c#. The

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.