- Download and install owc11.
- Run AxImp on OWC11.dll, which will have been installed in the microsoft shared\web components directory (ie C:\Program Files\Common Files\microsoft shared\Web Components\11\). AxImp.exe can be found in the Windows SDK (ie, C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\AxImp.exe).
- In Visual Studio project, drag OWC11.dll to a toolbox tab and drop the Excel component on form.
Voila. When it comes deployment time, you’ll need the AxInterop.OWC11.dll.
Some sample code:
Set a specific cell value:
Spreadsheet1.Cells.get_Item(row, col).set_Value(System.Reflection.Missing.Value, "BSXBW2183NN");
Get the string value of a specific cell:
Spreadsheet1.Cells.get_Item(row, col).get_Value(System.Reflection.Missing.Value).ToString()
or
Spreadsheet1.Cells.get_Item(i, 1).Text.ToString();
Set the background color of a row:
Object ob = "#66FF66";
Spreadsheet1.Rows.get_Item(row, System.Reflection.Missing.Value).Font.set_Color(ref ob);
Technorati Tags:
Excel,
.NET