Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

How to read Excel file & save data in array...........

student491student491 Posts: 6Member
hello,

I opened the excel file by using workbook.open() method...
Now i want to read the data from the excel file.. & save it into
array.

help out .. how to do this.
Then i want to pass that array through SetSourceData() method & want to draw cunztomized chart...

(I am using Excel 2007, C# 2005, COM)

Thx... :)

Comments

  • vmmlogvmmlog Posts: 3Member
    Hi,

    you can read the data in the excel as follows:

    Excel.Workbook wb = Excel.Workbooks.Open(...);
    Excel.Worksheet sh = (Excel.Worksheet) wb.Sheets(1);
    Excel.Range rng = sh.get_Range("A1","A1");

    Then the value in the range can be accessed using

    rng.Value2.ToString();

    Values from multiple cells can be read by looping.


    : hello,
    :
    : I opened the excel file by using workbook.open() method...
    : Now i want to read the data from the excel file.. & save it into
    : array.
    :
    : help out .. how to do this.
    : Then i want to pass that array through SetSourceData() method & want
    : to draw cunztomized chart...
    :
    : (I am using Excel 2007, C# 2005, COM)
    :
    : Thx... :)
    :
    :

    with regards,
    vmmlog
  • filipkfilipk Posts: 9Member
    Easiest and fastest way to work with Excel files in C# is to use some 3rd party component. Try using GemBox [link=http://www.gemboxsoftware.com/GBSpreadsheet.htm]Excel component for .NET[/link] which is free for use and/or testing if you have smaller files (limit is 150 rows).

    Here is a list of reasons why it's [link=http://www.gemboxsoftware.com/Excel-Automation.htm]better to use GemBox component then Excel Automation or Excel Interop[/link].

    Filip
    GemBox.Spreadsheet - [link=http://www.gemboxsoftware.com/]easiest way to read and write Excel files in .NET[/link]
  • DataDinkDataDink Posts: 135Member
    hrm - ten bucks says filip works for GemBox
Sign In or Register to comment.