????? ??????? MFC ????? Excel 2000 ??? Excel 2002 ?????? ??? ???? ?? ???? ?? Excel 2000 ??? Excel 2002

?????? ????????? ?????? ?????????
???? ???????: 186122 - ??? ???????? ???? ????? ????? ??? ???????.
????? ???? | ?? ????

?? ??? ??????

??????

???? ??? ??????? ????? ????? Microsoft Excel ????? ?? ???? multi-cell ??? ????.

??????? ????

?????? ????? ?? ???? multi-cell ???? ??????? ??????? ?????? ??? ?????, ??? ???? ??????? ?????? ????? GetValue ?????? ???? ?????? ????? ??? VARIANT. ???? ?? SAFEARRAY ???????? ??? VARIANT ???? ?? ?????? ?? GetValue. ??? ?????? ??? SAFEARRAY ????? ?????? ??? ??????? ???????? GetElement. ???? ??? ??????? ??????? ??????? ?? ??? ????? ?????? ??? ?? ?? ????? ???????? ???????.

??????? ????? Microsoft Excel 2000 ? 2002

?????? ????? ???????? ???????? ?? ??? ??????? wrappers ????? ???? ?? ??????? ?? ????? ?????? Excel 97 (8.olb Excel). ?? ????? ???? ???? ????? ??? ???????? ???????? ??? ???? ??????? ?????? wrappers ??? Excel 2000 (Excel9.olb) ?? Excel 2002 (Excel.olb). ?????? ??? ??????? ?????? ??? ??????? ????? ???????? ???????? ??????? ?? ??? ??????? ?? Microsoft Excel 2000 ?? ????? ????? 2002 ???? ??? ??? ??????? ????? ?????? ?? "????? ??????? ?? Microsoft:
224925INFO: ???? ????? ??? ?????? ?? Office ?? ????? ????

??????? ??????? ?????? ???????

  1. ?? Microsoft Excel? ?? ?????? ???? ????. ????? ??????? A1:C8 ???????? ???? ?? ????? ?????? ?????. ??? ?????? ?? "c:\test.xls" ?? ????? Microsoft Excel.
  2. ???? ??????? ?? 1 ??? 12 ?? ??????? ??????? ?? Microsoft Knowledge Base ??? ????? ????? ????? ?????? IDispatch ?????? ? ????? ????? ??? ?? ????? ????? Excel8.olb:
    178749????? ????? ??????? ??????? ??????? MFC ?????? ?????
  3. ?? ???? ????? AutoProjectDlg.cpp ??? ????? ??????:
          #include "excel8.h"
    					
  4. ?? ?????? ???????? ???????? ??????? ??? CAutoProjectDlg::OnRun() ?? ??? AutoProjectDlg.cpp:

    ??? ?????

          // OLE Variant for Optional.
          COleVariant VOptional((long)DISP_E_PARAMNOTFOUND, VT_ERROR);
    
          _Application objApp;
          _Workbook objBook;
          Workbooks objBooks;
          Worksheets objSheets;
          _Worksheet objSheet;
          Range objRange;
          VARIANT ret;
    
          // Instantiate Excel and open an existing workbook.
          objApp.CreateDispatch("Excel.Application");
          objBooks = objApp.GetWorkbooks();
          objBook = objBooks.Open("C:\\Test.xls",
                    VOptional, VOptional, VOptional, VOptional,
                    VOptional, VOptional, VOptional, VOptional,
                    VOptional, VOptional, VOptional, VOptional);
          objSheets = objBook.GetWorksheets();
          objSheet = objSheets.GetItem(COleVariant((short)1));
    
          //Get the range object for which you wish to retrieve the
          //data and then retrieve the data (as a variant array, ret).
          objRange = objSheet.GetRange(COleVariant("A1"), COleVariant("C8"));
          ret = objRange.GetValue();
    
          //Create the SAFEARRAY from the VARIANT ret.
          COleSafeArray sa(ret);
    
          //Determine the array's dimensions.
          long lNumRows;
          long lNumCols;
          sa.GetUBound(1, &lNumRows);
          sa.GetUBound(2, &lNumCols);
    
          //Display the elements in the SAFEARRAY.
          long index[2];
          VARIANT val;
          int r, c;
          TRACE("Contents of SafeArray\n");
          TRACE("=====================\n\t");
          for(c=1;c<=lNumCols;c++)
          {
             TRACE("\t\tCol %d", c);
          }
          TRACE("\n");
          for(r=1;r<=lNumRows;r++)
          {
             TRACE("Row %d", r);
             for(c=1;c<=lNumCols;c++)
             {
                index[0]=r;
                index[1]=c;
                sa.GetElement(index, &val);
                switch(val.vt)
                {
                case VT_R8:
                   {
                      TRACE("\t\t%1.2f", val.dblVal);
                      break;
                   }
                case VT_BSTR:
                   {
                      TRACE("\t\t%s",(CString)val.bstrVal);
                      break;
                   }
    
                case VT_EMPTY:
                   {
                      TRACE("\t\t<empty>");
                      break;
                   }
                }
             }
             TRACE("\n");
          }
    
          //Close the workbook without saving changes
          //and quit Microsoft Excel.
          objBook.Close(COleVariant((short)FALSE), VOptional, VOptional);
          objApp.Quit();
    					
  5. ????? ??????? ?? ??????.
  6. ???? ??? ?????. ??? ??? ????? ?? ??????? A1:C8 ?? ?????? ?????.

?????

?????? ??? ??????? ?????? ??? ????? Microsoft Excel ???????? MFC ???? ??? ????? ???????? ??????? ?????? ?? "????? ??????? ?? Microsoft:
186120????? ??????? MFC ????? Excel ?? ????? ???? ?? ????
184663????? ????? ????? ???? ??? Microsoft Excel ?? MFC
179706????? ??????? MFC ??? ????? Excel "?" ?????/????? ???? ????
178781HOWTO: ????? ??????? MFC ? ????? ???? ??? Excel
178783HOWTO: ??????? MFC ?????? ????? Microsoft Excel
167668????? ????? SafeArray ????? ?? VARIANT *

???????

???? ???????: 186122 - ????? ??? ??????: 04/????/1428 - ??????: 5.1
????? ???
  • Microsoft Excel 2000 Standard Edition
  • Microsoft Visual C++ 5.0 Enterprise Edition
  • Microsoft Visual C++ 6.0 Enterprise Edition
  • Microsoft Visual C++ 5.0 Professional Edition
  • Microsoft Visual C++ 6.0 Professional Edition
  • Microsoft Visual C++, 32-bit Learning Edition 6.0
  • Microsoft Excel 2002 Standard Edition
  • Microsoft Excel 97 Standard Edition
????? ??????: 
kbmt kbprogramming kbfunctions kbautomation kbhowto kbinterop KB186122 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????186122

????? ???????

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com