EXCEL로 내보내기

3287 단어

  
  
  
  
_RecordsetPtr m_pRs; _ConnectionPtr m_pConn; try { CoInitialize(NULL); m_pConn.CreateInstance(__uuidof(Connection)); m_pRs.CreateInstance(__uuidof(Recordset)); // m_pConn -> CursorLocation = adUseServer; // adUseClient;adUseNone // ACCESS m_pConn -> Open(L " Provider=Microsoft.Jet.OLEDB.4.0;Data Source=test.mdb;Persist Security Info=False " , L "" ,L "" ,adOpenUnspecified); m_pRs -> PutRefActiveConnection(m_pConn); m_pRs -> Open( " select * into [Excel 5.0;HDR=YES;DATABASE=c://test.xls].[sheet1] from users " ,_variant_t((IDispatch * )m_pConn, true ),adOpenDynamic,adLockOptimistic,adCmdUnknown); m_pRs = NULL; m_pConn = NULL; CoUninitialize(); } catch (_com_error & e) { AfxMessageBox(e.Description()); }

좋은 웹페이지 즐겨찾기