using Excel = Microsoft.Office.Interop.Excel;
namespace program
{
private void cmdOpen_Click(object sender, System.EventArgs e)
{
FileSystem.FileOpen(1, inputfile, OpenMode.Input, (OpenAccess)(-1), (OpenShare)(-1), -1); // 1 : excel file
Excel.Application MyXl;
MyXl = new Excel.ApplicationClass();
MyXl.Visible = true;
Excel.Workbook xlWorkbook = MyXl.Workbooks.Open(inputfile, 0, false, 5, "", "", false, Excel.XlPlatform.xlWindows, "", true, false, 0, true, false, false);
Excel.Worksheet xlWorksheet = (Excel.Worksheet)xlWorkbook.Worksheets;
Variables();
}
public void Variables()
{
int i;
object ws;
int j;
ws = MyXl.xlWorksheet("sheet1");
do
{
inputs[i] = ws.Cells[5, input_startcol+i];
}while(inputs[i]!="");
}
Error:
1.The name 'MyXl' does not exist in the current context
2.'object' does not contain definition for 'Cells'