Excel Automation - reading from excel

G

Guest

I'm able to write values to an excel workbook from C#.Net code.

Is there a way to read cells/values from excel to C#?

Mansi
 
M

Mark Rae

I'm able to write values to an excel workbook from C#.Net code.

Is there a way to read cells/values from excel to C#?

Er, yeah - it's pretty much the same process... Do exactly what you're doing
now but reverse the line where you write the value i.e.

<ExcelCellValue> = <C#variable>

becomes

<C#variable> = <ExcelCellValue>
 
G

Guest

I try to do the same thing in reverse, but I'm getting a "Specific cast is
not valid" error in Excel.

The following line is generating this error:

// Code before this line creates the excel object, opens up an existing
workbook, and gets a sheet in that workbook

string firstName = (string) m_objSheet.Cells[1,1];

Any ideas???? How do I convert the cell value to string?

Mansi
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top