Beuy
Beuy

Reputation: 111

How to get cell value in excel workbook project using c#?

I have an excel 2010 c# project, how do I get the value from a cell? I've found a lot of solutions for opening an excel file and then getting the value. But in this case the file is part of the soultion?

Upvotes: 0

Views: 5943

Answers (4)

Beuy
Beuy

Reputation: 111

Looks like the following is what I am after:

private void ThisWorkbook_Shutdown(object sender, System.EventArgs e)
{
    Excel.Range show = Globals.Sheet8.Range["A6"];
    MessageBox.Show(show.Text);
}

Credit to http://www.packtpub.com/article/microsoft-office-excel-programming-using-vsto for showing the way

Upvotes: 0

Jens
Jens

Reputation: 3299

If you're working with excel and your file is in the newer xlsx format, you might want to take a look at ExtremeML. It's a great library which can help you read/write excel files without having to use Office automation, thus increasing your program performance.

Upvotes: 2

Gian Santillan
Gian Santillan

Reputation: 773

make a cursor string...

example:

string cusrsor = "d5";
ExcelName.get_range(cursor,cursor).Value2 = "you put here value";

//more codes
//more codes
more codes

if you want to get the cell from this file..
just use the cursor or pointer to put you there...

Upvotes: 0

DGH
DGH

Reputation: 11539

Even though the file is part of your Visual Studio solution, you still have to do the usual file IO routine, e.g. open it, read it, then close it. Making it part of your solution mainly just means the file is packaged with your binaries when you compile, and you can select various options for what to do with the file at compile time.

Upvotes: 0

Related Questions