Knowledge points to use
Read and write excel in the Windows operating system;
Closes the EXE process with the specified name, opening the EXE process with the specified name;
Make the generated EXE compatible with each system in Windows;
SOURCE Download Link
Http://pan.baidu.com/share/home?uk=369664793&view=share#category/type=0
Description
The Microsoft Office COM Class Library is used to read Excel data. Core source code in the Excel.cpp file, the core function is HRESULT AutoWrap (int autotype, VARIANT *pvresult, IDispatch *pdisp, lpolestr ptname, int cargs ...). ); The external interface is cstring** Getexceldata (string &fileaddress), the input is the Excel file pathname, and the output is a two-dimensional array that corresponds to the string data for each lattice point in the Excel file.
The Excel file is written in the basicexcel based on the COM library implementation, with the reference link: http://blog.csdn.net/augusdi/article/details/13295735.
After running IcMatchTool.exe shutdown, observe that the process is not closed in Task Manager, and do not delve into the cause, just take a new process to close the process.
To close the EXE process with the specified name, refer to link: http://blog.csdn.net/caroline_wendy/article/details/29382347
Software
Software description
both 1.iclibrary.xls and Input.xls need to add an end manually in the last line;
2.IcLibrary is a component library file, input is required to match the component files;
3. After clicking the "Match" button, select Input.xls in the pop-up file selection box;
4. The close.exe in the file cannot be deleted.
5.yes.xls is the component found in the library, No.xls is not found in the components;
6. If you need to match the component file Input.xls large, the program needs to run for a long time, waiting for a "match complete" pop-up window.
Core source
voidCexcelacessdlg::onmath () {//Open Library file stringLibraryfileaddress ("D:\\icmanage\\iclibrary.xls"); CString**getlibdata =Getexceldata (libraryfileaddress); //row_nummultimap<string,int>Libmap; intLibrownum =row_num; for(inti =1; i<librownum;i++) { stringTMP (getlibdata[i][0]. GetBuffer ()); Libmap.insert (Pair<string,int>(tmp,i)); getlibdata[i][0]. ReleaseBuffer (); } //Open the file you want to match_tchar strfilefilter[] ="Excel File (*.xlsx;*.xls) |*.xlsx;*.xls| text file (*.txt) |*.txt| All Files (*. *) |*.*| |"; CFileDialog Dlg (True,null, NULL, Ofn_hidereadonly,strfilefilter); //Modify the default open pathdlg.m_ofn.lpstrinitialdir=_t ("D:\\icmanage"); if(Dlg.domodal () = =IDOK) {M_file=Dlg.getfilename (); PathName=Dlg.getpathname (); UpdateData (FALSE); } stringmathfileaddress (Pathname.getbuffer ()); CString**getmathdata =Getexceldata (mathfileaddress); Pathname.releasebuffer (); intMathrownum =row_num; //Create Yes.xls and No.xls files for outputBasicexcel Eyes,eno; Basicexcelworksheet*sheetyes,*Sheetno; Charbufyes[ $],bufno[ $]; CString Yesname,noname; stringYesaddress ("D:\\icmanage\\yes.xls"); stringNoaddress ("D:\\icmanage\\no.xls"); Yesname.format ("%s", Yesaddress.c_str ()); Noname.format ("%s", Noaddress.c_str ()); intK; for(k=0; K<yesname.getlength (); k++) Bufyes[k]=Yesname.getat (k); BUFYES[K]=0; for(k=0; K<noname.getlength (); k++) Bufno[k]=Noname.getat (k); BUFNO[K]=0; Eyes.load (Bufyes); Eno.load (BUFNO); Eyes.new (1); Eno.new (1); R1=0; R2=0; Sheetyes= Eyes.getworksheet ("Sheet1"); Sheetno= Eno.getworksheet ("Sheet1"); stringTmp_yes,tmp_no; for(intj =0;j<3; j + +) { stringS (getlibdata[0][j]. GetBuffer ()); if(j==2) Tmp_yes.append ("Total"); Tmp_yes.append (s); Tmp_yes.append (" "); Tmp_no.append (s); Tmp_no.append (" "); } tmp_no.append (" /"); Tmp_yes.append ("Quantity Required"); Tmp_yes.append (" /"); CString newcstring; Newcstring.format ("%s", Tmp_no.c_str ()); Sheetflag=0; Fenxi (NEWCSTRING,SHEETNO); Sheetflag=1; Newcstring.format ("%s", Tmp_yes.c_str ()); Fenxi (Newcstring,sheetyes); //Matchmultimap<string,int>:: Iterator mapiter; for(inti =1; i<mathrownum;i++) { stringTMP1 (getmathdata[i][0]. GetBuffer ()); //mapiter = Libmap.find (TMP1);Mapiter =findnew (Libmap.begin (), Libmap.end (), TMP1); if(Mapiter = = Libmap.end ())//didn't find { stringtmp; for(intj =0;j<3; j + +) { strings (getmathdata[i][j]. GetBuffer ()); Tmp.append (s); if(j<2) Tmp.append (" "); GETMATHDATA[I][J]. ReleaseBuffer (); }//Tmp.append ("n");CString newcstring; Newcstring.format ("%s", Tmp.c_str ()); Sheetflag=0; Fenxi (NEWCSTRING,SHEETNO); } Else//Find { intpos = (*mapiter). Second; stringtmp; intJ; for(j =0;j<3; j + +) { strings (getlibdata[pos][j]. GetBuffer ()); Tmp.append (s);//if (j<2)Tmp.append (" "); GETLIBDATA[POS][J]. ReleaseBuffer (); } strings (getmathdata[i][j]. GetBuffer ()); Tmp.append (s); GETMATHDATA[I][J]. ReleaseBuffer ();//Tmp.append ("n");CString newcstring; Newcstring.format ("%s", Tmp.c_str ()); Sheetflag=1; Fenxi (Newcstring,sheetyes); } getmathdata[i][0]. ReleaseBuffer (); } for(intI=0; i<librownum; i++) {delete[] getlibdata[i]; } delete[] Getlibdata; for(intI=0; i<mathrownum; i++) {delete[] getmathdata[i]; } delete[] Getmathdata; Eyes.saveas (Bufyes); Eno.saveas (BUFNO); AfxMessageBox ("Match complete!");
Open an EXE process ShellExecute (NULL,"Open","D:\\icmanage\\close.exe", NULL, NULL, SW_SHOWNORMAL); DestroyWindow (); Afxpostquitmessage (0); Exit (0);}
Electronic Component Management System