B
bjoern.bendler
Hello,
i try a Excel search in C#.
public Excel.Application excelApp = new Excel.ApplicationClass();
public Excel.Worksheet excelWorksheet;
void Button1Click(object sender, System.EventArgs e)
{
Excel.Application excelApp = new Excel.ApplicationClass();
string workbookPath = this.textBox1.Text;
Excel.Workbook excelWorkbook =
excelApp.Workbooks.Open(workbookPath,
0, false, 5, "", "", false, Excel.XlPlatform.xlWindows, "",
true, false, 0, true, false, false);
Excel.Sheets excelSheets = excelWorkbook.Worksheets;
string currentSheet = "Tabelle1";
excelWorksheet =
(Excel.Worksheet)excelSheets.get_Item(currentSheet);
}
void Button2Click(object sender, System.EventArgs e)
{
excelWorksheet.Cells.Find("a","",
Excel.XlFindLookIn.xlValues,Excel.XlLookAt.xlWhole,
Excel.XlSearchOrder.xlByRows,Excel.XlSearchDirection.xlNext,
false,null,false);
}
It based on an xls that looks:
a
b
c
d
e
f
g
h
i
Open then Document works fine. But everytime i push the search Button i
get this error:
"Exception System.Runtime.InteropServices.COMException was thrown in
debuggee:
Typkonflikt. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH"
Please help. I found some entries in this group but nothing works...
thanx
Björn
i try a Excel search in C#.
public Excel.Application excelApp = new Excel.ApplicationClass();
public Excel.Worksheet excelWorksheet;
void Button1Click(object sender, System.EventArgs e)
{
Excel.Application excelApp = new Excel.ApplicationClass();
string workbookPath = this.textBox1.Text;
Excel.Workbook excelWorkbook =
excelApp.Workbooks.Open(workbookPath,
0, false, 5, "", "", false, Excel.XlPlatform.xlWindows, "",
true, false, 0, true, false, false);
Excel.Sheets excelSheets = excelWorkbook.Worksheets;
string currentSheet = "Tabelle1";
excelWorksheet =
(Excel.Worksheet)excelSheets.get_Item(currentSheet);
}
void Button2Click(object sender, System.EventArgs e)
{
excelWorksheet.Cells.Find("a","",
Excel.XlFindLookIn.xlValues,Excel.XlLookAt.xlWhole,
Excel.XlSearchOrder.xlByRows,Excel.XlSearchDirection.xlNext,
false,null,false);
}
It based on an xls that looks:
a
b
c
d
e
f
g
h
i
Open then Document works fine. But everytime i push the search Button i
get this error:
"Exception System.Runtime.InteropServices.COMException was thrown in
debuggee:
Typkonflikt. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH"
Please help. I found some entries in this group but nothing works...
thanx
Björn