hi everybody,
I was trying to read a certain range from column in excel into an array in c# then to write it back in another column(as a matter of a simple trial), where the column is written into textbox3, the start of the range is written in texbox1 & textbox2 respectively.
I’ve searched and read about it a bit and here is the code that i came up with :

May I suggest EPPlus?

It's a c# open source project for reading and writting excel files. It's quite simple to use and have a good documentation. The only setback, as far I'm concerned untill now, is that it only accepts xlsx(excel 2007 or later).

sorry for the inconvenience but i forget to embed the code and when tried to edit the post all i got is that I have to use the code button though i 'm already using it.

the problem was that when I get the range that I want I cast it as i found previously on a code example like this:
System.Array myvalues = (System.Array)oRng.Cells.Value2;

where oRng is defined like this : Excel.Range oRng; and contains the selected part in the column in Excel.
then i made a function to convert this array into string that where i got an exception while running the program.
so I was having some questions regarding the System.array class and its instance myvalues
as why was it a 2-D array ?(as i see in several codes through the web)? and when dealing with it they alway use a foe loop that starts from 1 not from 0 as i thought.

Did you check the EPPlus library?

not yet I would give it a try.
but i'm also concerned to know what is the exception that happen as the code i use is very simple,anyway thanks so much for your reply

I get it, I don't know the cause for your error, but take a look at a piece of my code using excel interop, maybe it can help you:

Excel.Worksheet sheet = (Excel.Worksheet) sheets.get_Item( i + 1 );

Excel.Range usedRange = sheet.UsedRange;
Excel.Range columns = usedRange.Columns;

for ( int c=0; c < columns.Count; c++ )
{
    Excel.Range cell = (Excel.Range) usedRange.get_Item( 1, c + 1 );
    if ( cell.Value2 != null )
    {
        // ... do what you need
    }
}

Hi, i just joined. I am trying to learn C# the fastest way possible.Currently i am using Zet Excel platform. Any suggestions that can help me ? I need to boost my coding

commented: That Zet sure seems to be spammed a lot. Maybe it's not the way. Try a new post on how to solve. +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.