G
gumbystation
I am looking to take data from an excel spreadsheet into a csharp
application to manipulate the data in various ways. Currently, I am
using VS2005 (self-taught C#) and Excel 2000. I have researched into
using the Excel.Application object and have successfully openned a
worksheet in Excel (though hidden from the user).
The problem now comes when trying to get the data off of a spreadsheet.
When I try to create an instance of the worksheet, it fails:
oXL.Sheets["Sheet1"].Activate();
And even if I get that to work, I don't know how to pull the data off
of the spread sheet. I understand that I will need to get the range,
which I can do. Anyways, here is what I have so far:
oXL = new Excel.Application();
oWB = (Excel._Workbook)(oXL.Workbooks.Open(@"C:\workbook.xls",
Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing,
Type.Missing));
oXL.Sheets("Sheet1").Activate(); //Doesn't compile
Excel.Worksheets tmpWBs = oXL.Sheets;
Excel.Worksheet tmpWB = tmpWBs["Sheet1"];
tmpWB.Activate();
stringTemp = (string)tmpWB.Cells[1,1];
// Rest of code
Any help is greatly appreciated.
application to manipulate the data in various ways. Currently, I am
using VS2005 (self-taught C#) and Excel 2000. I have researched into
using the Excel.Application object and have successfully openned a
worksheet in Excel (though hidden from the user).
The problem now comes when trying to get the data off of a spreadsheet.
When I try to create an instance of the worksheet, it fails:
oXL.Sheets["Sheet1"].Activate();
And even if I get that to work, I don't know how to pull the data off
of the spread sheet. I understand that I will need to get the range,
which I can do. Anyways, here is what I have so far:
oXL = new Excel.Application();
oWB = (Excel._Workbook)(oXL.Workbooks.Open(@"C:\workbook.xls",
Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing,
Type.Missing));
oXL.Sheets("Sheet1").Activate(); //Doesn't compile
Excel.Worksheets tmpWBs = oXL.Sheets;
Excel.Worksheet tmpWB = tmpWBs["Sheet1"];
tmpWB.Activate();
stringTemp = (string)tmpWB.Cells[1,1];
// Rest of code
Any help is greatly appreciated.