excel查找并返回单元格所在位置,问题多多太郁闷了。
void __fastcall TForm1::Button1Click(TObject *Sender){AnsiString efile=ExtractFilePath(Application->ExeName);TVariant tpath=efile+"//格式.xls";ExcelApplication1->Connect();ExcelWorkbook1->ConnectTo(ExcelApplication1->Workbooks->Open((WideString)tpath, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, 0));ExcelWorksheet1->ConnectTo(ExcelWorkbook1->Worksheets->get_Item(TVariant(1)));ExcelWorksheet1->Activate();RangePtr cel1=ExcelWorksheet1->Cells->FindNext(TVariant("牛奶"));cel1->Activate();AnsiString ssss=AnsiString(cel1->get_Address(EmptyParam,EmptyParam,xlR1C1,EmptyParam,EmptyParam));if(ssss.IsEmpty()){Edit1->Text="空";}else{Edit1->Text=ssss;}}
intf != 0 @ d:\program\……\vcl\utilcls.h\2916Press [Y]es to terminate,[N]o to continue and [C]ancel to Debug
'this->get_Item(Index,(LPDISPATCH*)&RHS)':不正确的变量类型。@ d:\program\……\vcl\Excel_2k.h/9908Press [Y]es to terminate,[N]o to continue and [C]ancel to Debug
1、(this->Open(Filename,UpdateLinks,……))Error:800A03EC (-2146827284)@ d:\program\……\vcl\Excel_2k.h/12990Press [Y]es to terminate,[N]o to continue and [C]ancel to Debug2、[C++ Fatal Error]excelldo.cpp[37]:F1004 Internal compiler error at 0xc56de7 with base 0xc10000.错误对应的代码是AnsiString ssss=AnsiString(cel1->get_Address(EmptyParam,EmptyParam,xlR1C1,EmptyParam,EmptyParam));实在头疼,不知道该怎么入手解决了,就剩这么多分了,分不多请见谅啊,多谢!!!!
Private Sub Worksheet_Activate() Dim testcell As Range Set testcell = Worksheets.Item(1).Cells.Find("test") Cells(testcell.Row + 1, testcell.Column) = "lgs"End Sub