//VT_R8 int IllusionExcelFile::GetCellInt(long irow, long icolumn) { int num; COleVariant vresult; if (already_preload_ == FALSE) { CRange range; range.AttachDispatch(excel_current_range_.get_Item(COleVariant((long)irow), COleVariant((long)icolumn)).pdispVal, true); vresult = range.get_Value2(); range.ReleaseDispatch(); } else { long read_address[2]; VARIANT val; read_address[0] = irow; read_address[1] = icolumn; ole_safe_array_.GetElement(read_address, &val); vresult = val; } // num = static_cast<int>(vresult.dblVal); return num; }
double IllusionExcelFile::GetCellDouble(long irow, long icolumn) { double rtn_value = 0; COleVariant vresult; //字符串 if (already_preload_ == FALSE) { CRange range; range.AttachDispatch(excel_current_range_.get_Item(COleVariant((long)irow), COleVariant((long)icolumn)).pdispVal, true); vresult = range.get_Value2(); range.ReleaseDispatch(); } //如果数据依据预先加载了 else { long read_address[2]; VARIANT val; read_address[0] = irow; read_address[1] = icolumn; ole_safe_array_.GetElement(read_address, &val); vresult = val; } if (vresult.vt == VT_R8) { rtn_value = vresult.dblVal; } return rtn_value; }
//关闭打开的Excel 文件,默认情况不保存文件 void IllusionExcelFile::CloseExcelFile(BOOL if_save) { //如果已经打开,关闭文件 if (open_excel_file_.IsEmpty() == FALSE) { //如果保存,交给用户控制,让用户自己存,如果自己SAVE,会出现莫名的等待 if (if_save) { ShowInExcel(TRUE); } else { // excel_work_book_.Close(COleVariant(short(FALSE)), COleVariant(open_excel_file_), covOptional); excel_books_.Close(); } //打开文件的名称清空 open_excel_file_.Empty(); } excel_current_range_.ReleaseDispatch(); excel_work_sheet_.ReleaseDispatch(); excel_sheets_.ReleaseDispatch(); excel_work_book_.ReleaseDispatch(); excel_books_.ReleaseDispatch(); }
int mesage_SetPathValue(lua_State* L) { CString type = luaL_typename(L,3); if(type == "string") { CString str = luaL_checkstring(L,3); COleDateTime dt; if(dt.ParseDateTime(str)) { cmessage_arg(L,"mesage_SetPathValue")->SetDatumByPath(luaL_checkstring(L,2),COleVariant(dt)); }else{ cmessage_arg(L,"mesage_SetPathValue")->SetDatumByPath(luaL_checkstring(L,2),COleVariant(str)); } }else if(type == "number") { cmessage_arg(L,"mesage_SetPathValue")->SetDatumByPath(luaL_checkstring(L,2),COleVariant(luaL_checknumber(L,3))); }else if(type == "boolean") { VARIANT var; var.vt = VT_BOOL; var.boolVal = (lua_toboolean(L,3)==1); cmessage_arg(L,"mesage_SetPathValue")->SetDatumByPath(luaL_checkstring(L,2),var); }else if(type == "nil") { VARIANT var; var.vt = VT_NULL; cmessage_arg(L,"mesage_SetPathValue")->SetDatumByPath(luaL_checkstring(L,2),var); }else { throw_L_error(L, "Invalid type of value"); } return 0; }
HRESULT CHtmlCtrl::Navigate(LPCTSTR lpszURL, DWORD dwFlags /*= 0*/, LPCTSTR lpszTargetFrameName /*= NULL*/, LPCTSTR lpszHeaders /*= NULL*/, LPVOID lpvPostData /*= NULL*/, DWORD dwPostDataLen /*= 0*/) { CString strURL(lpszURL); BSTR bstrURL = strURL.AllocSysString(); COleSafeArray vPostData; if (lpvPostData != NULL) { if (dwPostDataLen == 0) dwPostDataLen = lstrlen((LPCTSTR) lpvPostData); vPostData.CreateOneDim(VT_UI1, dwPostDataLen, lpvPostData); } return m_pBrowser->Navigate(bstrURL, COleVariant((long) dwFlags, VT_I4), COleVariant(lpszTargetFrameName, VT_BSTR), vPostData, COleVariant(lpszHeaders, VT_BSTR)); }
void CDownloads_Opinions_WBEvents::RetrieveLinkToUsText(IDispatch *pdDoc) { IHTMLDocument2Ptr spDoc (pdDoc); ASSERT (spDoc != NULL); IHTMLElementCollectionPtr spelForms; spDoc->get_forms (&spelForms); if (spelForms == NULL) return; long cForms = 0; spelForms->get_length (&cForms); for (long i = 0; i < cForms; i++) { IDispatchPtr spdel; spelForms->item (COleVariant (i), COleVariant (i), &spdel); ASSERT (spdel != NULL); IHTMLFormElementPtr spForm (spdel); ASSERT (spForm != NULL); bool bFound; CString str = GetFormInputElementText (spForm, "LINKTOUSTEXT", bFound); if (bFound) _App.View_SpreadHelpDialog_LinkToUsText (str); str = GetFormInputElementText (spForm, "RADIOBUTTON1TEXT", bFound); if (bFound) _App.View_SpreadHelpDialog_RadioButton1Text (str); str = GetFormInputElementText (spForm, "RADIOBUTTON2TEXT", bFound); if (bFound) _App.View_SpreadHelpDialog_RadioButton2Text (str); } }
void IllusionExcelFile::FreezePanes(const TCHAR* cell){ CRange range = excel_work_sheet_.get_Range(COleVariant(cell), COleVariant(cell)); range.Select(); CWindow0 mwin = excel_application_.get_ActiveWindow(); mwin.put_FreezePanes(1); range.ReleaseDispatch(); }
void Cwhu_FaxSettingDlg::Lin_ImportAutoForArr(CString m_FilePath,CStringArray &m_AutoForward) { int Number = 0; //m_DutyArr数组必须足够大// //导入 CApplication app; CWorkbook book; CWorkbooks books; CWorksheet sheet; CWorksheets sheets; CRange range; LPDISPATCH lpDisp; //定义变量// COleVariant covOptional((long) DISP_E_PARAMNOTFOUND,VT_ERROR); if (!app.CreateDispatch(_T("Excel.Application"))) { this->MessageBox(_T("无法创建Excel应用")); } books = app.get_Workbooks(); //打开Excel,其中m_FilePath为Excel表的路径名// lpDisp = books.Open(m_FilePath,covOptional ,covOptional,covOptional,covOptional ,covOptional,covOptional,covOptional ,covOptional,covOptional,covOptional ,covOptional,covOptional,covOptional ,covOptional); book.AttachDispatch(lpDisp); sheets = book.get_Worksheets(); sheet = sheets.get_Item(COleVariant((short)1)); CStringArray m_ContentArr; for (int ItemNum = 2;ItemNum<40;ItemNum++) { for (int ColumNum=1;ColumNum<11;ColumNum++) { CString m_pos = Lin_GetEnglishCharacter(ColumNum); CString m_Itempos; m_Itempos.Format(_T("%d"),ItemNum); CString m_str = m_pos+m_Itempos; range = sheet.get_Range(COleVariant(m_str),COleVariant(m_str)); //获得单元格的内容 COleVariant rValue; rValue = COleVariant(range.get_Value2()); //转换成宽字符// rValue.ChangeType(VT_BSTR); //转换格式,并输出// CString m_content = CString(rValue.bstrVal); if (m_content!=_T("")) { m_AutoForward.Add(m_content); } } } book.put_Saved(TRUE); app.Quit(); }
void CExcelFile::SetCellInt(long irow, long icolumn,int new_int) { COleVariant new_value((long)new_int); CRange start_range = excel_work_sheet_.get_Range(COleVariant(_T("A1")),covOptional); CRange write_range = start_range.get_Offset(COleVariant((long)irow -1),COleVariant((long)icolumn -1) ); write_range.put_Value2(new_value); start_range.ReleaseDispatch(); write_range.ReleaseDispatch(); }
void IllusionExcelFile::SetCelltime(long irow, long icolumn, time_t new_time) { COleVariant new_value((COleDateTime)new_time); CRange start_range = excel_work_sheet_.get_Range(COleVariant("A1"), covOptional); CRange write_range = start_range.get_Offset(COleVariant((long)irow - 1), COleVariant((long)icolumn - 1)); write_range.put_Value2(new_value); start_range.ReleaseDispatch(); write_range.ReleaseDispatch(); }
CString IllusionExcelFile::GetCellString(long irow, long icolumn) { excel_current_range_.AttachDispatch(excel_work_sheet_.get_Cells()); COleVariant vResult; CString str; //字符串 if (already_preload_ == FALSE) { CRange range; range.AttachDispatch(excel_current_range_.get_Item(COleVariant((long)irow), COleVariant((long)icolumn)).pdispVal, true); excel_current_range_.AttachDispatch(excel_work_sheet_.get_Cells()); vResult = range.get_Value2(); range.ReleaseDispatch(); } //如果数据依据预先加载了 else { long read_address[2]; VARIANT val; read_address[0] = irow; read_address[1] = icolumn; ole_safe_array_.GetElement(read_address, &val); vResult = val; } //字符串 if (vResult.vt == VT_BSTR) { str = vResult.bstrVal; } //整数 else if (vResult.vt == VT_INT) { str.Format(_T("%d"), vResult.pintVal); } //8字节的数字 else if (vResult.vt == VT_R8) { str.Format("%0.0f", vResult.dblVal); } //时间格式 else if (vResult.vt == VT_DATE) { SYSTEMTIME st; VariantTimeToSystemTime(vResult.date, &st); CTime tm(st); str = tm.Format("%Y-%m-%d"); } //单元格空的 else if (vResult.vt == VT_EMPTY) { str = ""; } return str; }
BOOL CmyWord::Goto( const CString& strBMark ) { COleVariant varBMark(strBMark); //设置变量 Bookmarks bookmarks = m_wdDoc.GetBookmarks(); if(!bookmarks.Exists((LPCTSTR)strBMark)) { return FALSE; } m_wdSel.GoTo(COleVariant(short(1),VT_BOOL),COleVariant((short)0),COleVariant((short)0),varBMark); return TRUE; }
BOOL IllusionExcelFile::IsCellString(long irow, long icolumn) { CRange range; range.AttachDispatch(excel_current_range_.get_Item(COleVariant((long)irow), COleVariant((long)icolumn)).pdispVal, true); COleVariant vResult = range.get_Value2(); //VT_BSTR标示字符串 if (vResult.vt == VT_BSTR) { return TRUE; } return FALSE; }
///检查一个CELL是否是时间 BOOL IllusionExcelFile::IsCellTime(long iRow, long iColumn) { CRange range; range.AttachDispatch(excel_current_range_.get_Item(COleVariant((long)iRow), COleVariant((long)iColumn)).pdispVal, true); COleVariant vResult = range.get_Value2(); if (vResult.vt == VT_DATE) { return TRUE; } range.ReleaseDispatch(); return FALSE; }
//检查一个CELL是否是数值 BOOL CExcelFile::IsCellInt(long irow, long icolumn) { CRange range; range.AttachDispatch(excel_current_range_.get_Item (COleVariant((long)irow),COleVariant((long)icolumn)).pdispVal, true); COleVariant vResult =range.get_Value2(); //好像一般都是VT_R8 if(vResult.vt == VT_INT || vResult.vt == VT_R8) { return TRUE; } return FALSE; }
void CmyWord::UpdateField(CString strBMark) { COleVariant varBMark_del(strBMark); //设置变量 Bookmarks bookmarks = m_wdDoc.GetBookmarks(); if(!bookmarks.Exists((LPCTSTR)strBMark)) { return; } m_wdSel.GoTo(COleVariant(short(1),VT_BOOL),COleVariant((short)0),COleVariant((short)0),varBMark_del); Fields fields = Fields(m_wdSel.GetFields()); fields.Update(); bookmarks.ReleaseDispatch(); }
void CHtmlView::Navigate2(LPITEMIDLIST pIDL, DWORD dwFlags /* = 0 */, LPCTSTR lpszTargetFrameName /* = NULL */) { ASSERT(m_pBrowserApp != NULL); COleVariant vPIDL(pIDL); COleVariant empty; m_pBrowserApp->Navigate2(vPIDL, COleVariant((long) dwFlags, VT_I4), COleVariant(lpszTargetFrameName, VT_BSTR), empty, empty); }
void CEx24dView::OnClockoleLoad() { if(!m_clock.CreateDispatch("Ex24c.Document")) { AfxMessageBox("Ex24c.Document component not found"); return; } m_clock.SetFigure(0, COleVariant("XII")); m_clock.SetFigure(1, COleVariant("III")); m_clock.SetFigure(2, COleVariant("VI")); m_clock.SetFigure(3, COleVariant("IX")); OnClockoleRefreshtime(); m_clock.ShowWin(); }
//每次删除完一行,原来的第二行就变为了现在的第一行 void IllusionExcelFile::DeleteRow(int iRow) { typedef enum XlDeleteShiftDirection { xlShiftToLeft = -4159, xlShiftUp = -4162 }; excel_current_range_.AttachDispatch(excel_work_sheet_.get_Cells()); excel_current_range_.AttachDispatch(excel_current_range_.get_Item(COleVariant((long)iRow),covOptional).pdispVal); excel_current_range_.AttachDispatch(excel_current_range_.get_EntireRow()); excel_current_range_.Delete(COleVariant((short)xlShiftUp));//原来的第二行就变为了现在的第一行 excel_current_range_.AttachDispatch(excel_work_sheet_.get_Cells()); }
//每次删除完一列,原来的第二列就变为了现在的第一列 void IllusionExcelFile::DeleteColume(int iCol) { typedef enum XlDeleteShiftDirection { xlShiftToLeft = -4159, xlShiftUp = -4162 }; excel_current_range_.AttachDispatch(excel_work_sheet_.get_Cells()); excel_current_range_.AttachDispatch(excel_current_range_.get_Item(covOptional, COleVariant((long)iCol)).pdispVal); excel_current_range_.AttachDispatch(excel_current_range_.get_EntireColumn()); excel_current_range_.Delete(COleVariant((short)xlShiftToLeft));//原来的第二列就变为了现在的第一列 excel_current_range_.AttachDispatch(excel_work_sheet_.get_Cells()); }
BOOL CDlgExportDownloads::ExportDownloads_ToDLInfoListFile(LPCSTR pszFile, DLDS_LIST* pvpDlds, BOOL bAppend) { IXMLDOMDocumentPtr spXML; IXMLDOMNodePtr spNode, spNode2; spXML.CreateInstance (__uuidof (DOMDocument)); if (spXML == NULL) return FALSE; spXML->put_async (FALSE); VARIANT_BOOL bRes = FALSE; if (bAppend) { spXML->load (COleVariant (pszFile), &bRes); if (bRes) { spXML->selectSingleNode (L"FDM_Downloads_Info_List", &spNode); if (spNode == NULL) bRes = FALSE; } } if (bRes == FALSE) { spXML->createNode (COleVariant ((long)NODE_ELEMENT), L"FDM_Downloads_Info_List", NULL, &spNode); spXML->appendChild (spNode, &spNode2); } for (size_t i = 0; i < pvpDlds->size (); i++) { ExportDownload_ToXML (spXML, spNode, pvpDlds->at (i)); } CComBSTR bstr; spXML->get_xml (&bstr); CString str = bstr; str.Replace ("><", ">\n<"); bstr = str; spXML->loadXML (bstr, &bRes); spXML->save (COleVariant (pszFile)); return TRUE; }
void ole_close_excel(const std::wstring &xlsx, CApplication &excel_application, CWorkbooks &books, CWorkbook &book, CWorksheets &sheets) { COleVariant covTrue((short)TRUE), covFalse((short)FALSE); COleVariant covOptional((long)DISP_E_PARAMNOTFOUND, VT_ERROR); book.Close(COleVariant(short(FALSE)),COleVariant(xlsx.c_str()), covOptional); books.Close(); // 释放资源 sheets.ReleaseDispatch(); book.ReleaseDispatch(); books.ReleaseDispatch(); excel_application.Quit(); excel_application.ReleaseDispatch(); }
VARIANT_BOOL vmsXmlHelper::LoadXML(IXMLDOMDocument *pXML, LPCSTR pszXml) { TCHAR tszTmpFile [MAX_PATH]; TCHAR tszTmpPath [MAX_PATH]; GetTempPath (MAX_PATH, tszTmpPath); GetTempFileName (tszTmpPath, _T ("tmp"), 0, tszTmpFile); TCHAR tszTmpFile1 [MAX_PATH]; _tcscpy (tszTmpFile1, tszTmpFile); _tcscpy (tszTmpFile1+_tcslen (tszTmpFile1) - 3, _T ("xml")); DeleteFile (tszTmpFile); HANDLE hFile = CreateFile (tszTmpFile1, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL); if (hFile == INVALID_HANDLE_VALUE) return FALSE; DWORD dw; WriteFile (hFile, pszXml, strlen (pszXml), &dw, NULL); CloseHandle (hFile); VARIANT_BOOL b; pXML->load (COleVariant (tszTmpFile1), &b); DeleteFile (tszTmpFile1); return b; }
// 从串口发送数据 //************************************ // Method: OnSendFromSerialPort // FullName: CUartToUdpSocket::OnSendFromSerialPort // Access: private // Returns: void // Qualifier: // Parameter: unsigned char * TXDATA // Parameter: unsigned int uiCount //************************************ void CUartToUdpSocket::OnSendFromSerialPort(unsigned char* TXDATA, unsigned int uiCount) { // 如果端口未打开则不发送数据 // if(NULL == hCom) // { // return; // } // // OVERLAPPED wol; // wol.Internal=0; // wol.InternalHigh=0; // wol.Offset=0; // wol.OffsetHigh=0; // wol.hEvent=CreateEvent(NULL,TRUE,FALSE,NULL); // // WriteFile(hCom,TXDATA,uiCount,NULL,&wol); if (m_pctrlMSComm1 == NULL) { AfxMessageBox(_T("串口MSCOMM控件指针为空!")); return; } if(m_pctrlMSComm1->get_PortOpen() == FALSE) { return; } CByteArray array; array.RemoveAll(); array.SetSize(uiCount); for(unsigned int i=0; i<uiCount; i++) { array.SetAt(i, TXDATA[i]); } m_pctrlMSComm1->put_Output(COleVariant(array)); // 发送数据 }
void CPrefView::UpdateValue() { CString Buff; int i=m_Grid.GetCol()-1; m_ComboX.GetWindowText(Buff); if (Buff!="") { m_U[GetIndex(Buff,m_pG)]=i; m_pM->m_U[GetIndex(Buff,m_pG)]=i; m_Slider.EnableWindow(TRUE); } i=m_Grid.GetRow()-1; m_ComboY.GetWindowText(Buff); if (Buff!="") { m_U[GetIndex(Buff,m_pG)]=i; m_pM->m_U[GetIndex(Buff,m_pG)]=i; } int pref=m_pM->GetPreferance(m_U); int index=255; m_pG->m_scale->GetIndex(COleVariant((double)pref),index, m_pM); Buff=m_pG->m_scale->GetLex(index); SetDlgItemText(IDC_EDIT_GOD, Buff); m_Slider.SetPos(pref); }
BOOL CSixAxisSensorInfoDlg::OnInitDialog() { CDialog::OnInitDialog(); CString bodyStyle = mFTSensor->GetBodyStyle(); CString family = mFTSensor->GetFamily(); short numChannels = mFTSensor->GetNumChannels(); CString strNumChannels; strNumChannels.Format("%d", numChannels); CString serial = mFTSensor->GetSerial(); // HWND hwnd1 = mLabelSerialNumber.GetSafeHwnd(); // HWND hwnd2 = mLabelBodyStyle.GetSafeHwnd(); // HWND hwnd3 = mLabelFamily.GetSafeHwnd(); // HWND hwnd4 = mLabelNumChannels.GetSafeHwnd(); mLabelSerialNumber.SetWindowText(serial); mLabelBodyStyle.SetWindowText(bodyStyle); mLabelFamily.SetWindowText(family); mLabelNumChannels.SetWindowText(strNumChannels); _Calibrations calibrations = mFTSensor->GetCalibrations(); short N = (short)(calibrations.GetCount()); for (short i=1; i<=N; i++) { _Calibration calibration=calibrations.GetItem(COleVariant(i,VT_I2)); CString part = calibration.GetPartNumber(); mListCalibrations.AddString(part); } mListCalibrations.SetCurSel(mFTWrapper->GetActiveCalibrationIndex() - 1); UpdateCalibrationInfo(); return TRUE; // return TRUE unless you set the focus to a control }
void CSerial::SendAlarm(CString str) { //CString str; str.Format(_T("%s\n"),str); if(this->isOpen) m_mscomm.put_Output(COleVariant(str));//SEND DATA }
// 发送扣费记录 void CDlgAutoRegister::SendConsumeRecord( ConsumeNode& node ) { static const LONG CodePage_GB2312 = 936; // 简体中文 (GB2312) static const LONG WinHttpRequestOption_URLCodePage = 2; CWinHttpRequest HttpRequest(FALSE); try { HttpRequest.Create(); HttpRequest.SetOption(WinHttpRequestOption_URLCodePage, COleVariant(CodePage_GB2312)); HttpRequest.SetTimeouts(5000, 5000, 10000, 1000 * 15); CString strUrlMain = _T("http://"); strUrlMain += CNetBarConfig::GetInstance()->GetMainCenterIP(); strUrlMain.AppendFormat(_T(":%d"), CNetBarConfig::GetInstance()->GetMainCenterPort()); strUrlMain += _T("/netbar/interface/Consume.jsp"); strUrlMain.AppendFormat(_T("?pwd=%s"),_T("netbarneibushiyong")); strUrlMain.AppendFormat(_T("&submitTime=%s"), CIBAHelpper::FormatTime(COleDateTime::GetCurrentTime())); strUrlMain.AppendFormat(_T("&netBarId=%d"),CNetBarConfig::GetInstance()->GetNetBarId()); strUrlMain.AppendFormat(_T("&refNo=%d"), GetRandomRefNo()); strUrlMain.AppendFormat(_T("&serialNo=%d"), CIBAConfig::GetInstance()->GetLocalSerialNo()); strUrlMain.AppendFormat(_T("&memberId=%d"), node.nMemberId); strUrlMain.AppendFormat(_T("&checkinTime=%s"), node.checkInTime); strUrlMain.AppendFormat(_T("&checkoutTime=%s"), node.checkOutTime); strUrlMain.AppendFormat(_T("&classId=%d"), GetRandomClassID()); strUrlMain.AppendFormat(_T("&pcClass=%d"), GetPCClassID()); strUrlMain.AppendFormat(_T("&termId=%s"), GetRandomTermID()); strUrlMain.AppendFormat(_T("&amount=%d"), node.nAmount); strUrlMain.AppendFormat(_T("&timeConsume=%d"), node.nTimeConsume); strUrlMain.Replace(_T(" "), _T("%20")); GXX_TRACE(_T("扣消费记录的请求: %s"), strUrlMain.GetString()); HttpRequest.Open(strUrlMain.GetString()); HttpRequest.Send(); DeRegisterNode deRegNode; deRegNode.OldDeRegisterTime = node.OleCheckOutTime + COleDateTimeSpan(0, 0, 5, 0); // 下机后5分钟退款 deRegNode.nMemberId = node.nMemberId; _tcscpy(deRegNode.idNumber, node.idNumber); _tcscpy(deRegNode.name, node.name); deRegNode.bInvalid = 0; m_cs.Lock(); m_arrDeRegisterNode.push_back(deRegNode); m_cs.Unlock(); GXX_TRACE(_T("Response: %s"), HttpRequest.GetResponseText()); } catch(...) { } }
//按照名称加载Sheet表格,可以提前加载所有的表格内部数据 BOOL IllusionExcelFile::LoadSheet(const char* sheet, BOOL pre_load) { LPDISPATCH lpDis = NULL; excel_current_range_.ReleaseDispatch(); excel_work_sheet_.ReleaseDispatch(); lpDis = excel_sheets_.get_Item(COleVariant(sheet)); if (lpDis) { excel_work_sheet_.AttachDispatch(lpDis, true); excel_current_range_.AttachDispatch(excel_work_sheet_.get_Cells(), true); } else { return FALSE; } // already_preload_ = FALSE; //如果进行预先加载 if (pre_load) { already_preload_ = TRUE; PreLoadSheet(); } return TRUE; }
//按照序号加载Sheet表格,可以提前加载所有的表格内部数据 BOOL IllusionExcelFile::LoadSheet(long table_index, BOOL pre_load) { LPDISPATCH lpDis = NULL; excel_current_range_.ReleaseDispatch(); excel_work_sheet_.ReleaseDispatch(); lpDis = excel_sheets_.get_Item(COleVariant((long)table_index)); if (lpDis) { excel_work_sheet_.AttachDispatch(lpDis, true); excel_current_range_.AttachDispatch(excel_work_sheet_.get_Cells(), true);//选择所有的单元格 //excel_current_range_.AttachDispatch(excel_current_range_.get_Item(_variant_t((long)1), vtMissing).pdispVal, true); } else { return FALSE; } already_preload_ = FALSE; //如果进行预先加载 if (pre_load) { PreLoadSheet(); already_preload_ = TRUE; } return TRUE; }