Click here to Skip to main content
15,905,558 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionWord automation Pin
great_tommy18-Aug-06 3:31
great_tommy18-Aug-06 3:31 
AnswerRe: Word automation Pin
Rage18-Aug-06 3:38
professionalRage18-Aug-06 3:38 
GeneralRe: Word automation [modified] Pin
great_tommy18-Aug-06 3:50
great_tommy18-Aug-06 3:50 
GeneralRe: Word automation Pin
David Crow18-Aug-06 6:36
David Crow18-Aug-06 6:36 
QuestionHow Pin
nhoc_conxauxi18-Aug-06 2:58
nhoc_conxauxi18-Aug-06 2:58 
AnswerRe: How Pin
Hamid_RT18-Aug-06 19:35
Hamid_RT18-Aug-06 19:35 
QuestionHow to cut file Pin
nhoc_conxauxi18-Aug-06 2:49
nhoc_conxauxi18-Aug-06 2:49 
Questionhow can i read excel sheet using visual c++ MFC Pin
kamlesh987318-Aug-06 2:18
kamlesh987318-Aug-06 2:18 
Hi,
plz tell me. how can i read excel sheet using visual c++ MFC.
i have write following code but it reads only three rows.
void CReadExcelDlg::OnButton1()
{
CDatabase database;
CString sSql;
CString sItem1, sItem2,sItem3;
CString sDriver;
CString sDsn;
CString sFile = "ReadExcel.xls"; // the file name. Could also be something like C:\\Sheets\\WhatDoIKnow.xls

// Clear the contents of the listbox
m_ctrlList.ResetContent();
sDriver = GetExcelDriver();
if( sDriver.IsEmpty() )
{
// Blast! We didn´t find that driver!
AfxMessageBox("No Excel ODBC driver found");
return;
}

sDsn.Format("ODBC;DRIVER={%s};DSN='';DBQ=%s",sDriver,sFile);

TRY
{

database.Open(NULL,false,false,sDsn);
CRecordset recset( &database );
sSql = "SELECT field_1, field_2 "
"FROM demo_table "
"ORDER BY field_1";
recset.Open(CRecordset::forwardOnly,sSql,CRecordset::readOnly);
while( !recset.IsEOF() )
{
// Read the result line
recset.GetFieldValue("field_1",sItem1);
recset.GetFieldValue("field_2",sItem2);
// recset.GetFieldValue("field_3",sItem3);
// Insert result into the list
m_ctrlList.AddString( sItem1 + " --> "+ sItem2 );

// Skip to the next resultline
recset.MoveNext();
}

// Close the database
database.Close();

}
CATCH(CDBException, e)
{
// A database exception occured. Pop out the details...
AfxMessageBox("Database error: "+e->m_strError);
}
END_CATCH;
}
////plz help me
AnswerRe: how can i read excel sheet using visual c++ MFC Pin
_AnsHUMAN_ 18-Aug-06 2:43
_AnsHUMAN_ 18-Aug-06 2:43 
QuestionRe: how can i read excel sheet using visual c++ MFC Pin
David Crow18-Aug-06 3:02
David Crow18-Aug-06 3:02 
AnswerRe: how can i read excel sheet using visual c++ MFC Pin
Hamid_RT18-Aug-06 3:04
Hamid_RT18-Aug-06 3:04 
GeneralRe: how can i read excel sheet using visual c++ MFC Pin
David Crow18-Aug-06 3:11
David Crow18-Aug-06 3:11 
GeneralRe: how can i read excel sheet using visual c++ MFC Pin
Hamid_RT18-Aug-06 7:07
Hamid_RT18-Aug-06 7:07 
AnswerRe: how can i read excel sheet using visual c++ MFC Pin
Waldermort18-Aug-06 3:56
Waldermort18-Aug-06 3:56 
QuestionSetItemText() Problem Pin
Kiran Pinjala18-Aug-06 1:58
Kiran Pinjala18-Aug-06 1:58 
AnswerRe: SetItemText() Problem Pin
Rage18-Aug-06 2:25
professionalRage18-Aug-06 2:25 
GeneralRe: SetItemText() Problem Pin
Maximilien18-Aug-06 2:30
Maximilien18-Aug-06 2:30 
GeneralRe: SetItemText() Problem Pin
Rage18-Aug-06 3:33
professionalRage18-Aug-06 3:33 
GeneralRe: SetItemText() Problem Pin
Hamid_RT18-Aug-06 3:00
Hamid_RT18-Aug-06 3:00 
QuestionRe: SetItemText() Problem Pin
David Crow18-Aug-06 3:16
David Crow18-Aug-06 3:16 
QuestionRe: SetItemText() Problem Pin
prasad_som18-Aug-06 3:19
prasad_som18-Aug-06 3:19 
AnswerRe: SetItemText() Problem Pin
Kiran Pinjala18-Aug-06 3:26
Kiran Pinjala18-Aug-06 3:26 
QuestionOnCancel Pin
SandhyaSri18-Aug-06 1:35
SandhyaSri18-Aug-06 1:35 
AnswerRe: OnCancel Pin
Cedric Moonen18-Aug-06 1:48
Cedric Moonen18-Aug-06 1:48 
GeneralRe: OnCancel Pin
SandhyaSri18-Aug-06 1:57
SandhyaSri18-Aug-06 1:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.