How to read Excel file & save data in array........... - Programmers Heaven

Howdy, Stranger!

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

Categories

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.