Link to home
Start Free TrialLog in
Avatar of liufeng
liufeng

asked on

To access .XLS by MFC

How can I create and access the .xls(MicrosoftExcel) file
by MFC?
Thank you very much.
Avatar of gspk
gspk

Use OleAutomation ...
ASKER CERTIFIED SOLUTION
Avatar of Tommy Hui
Tommy Hui

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I'm late a little because I had to check some idea.
If you don't like OleAutomation ( I'm not familiar  with it :-( ) you can choose another way to solve your task. I mean using ODBC. I used it once to solve a similar task. I don't know a 'beautiful' way to create .xls file by means ODBC so I used the following (as far as I recall):
1) I kept a dummy file created by MS Excel and made it's copies whenewer they were necessary.
2) I used CDatabase::ExecuteSQL to make necessary worksheets in the new dummy files.
3) After that I used CRecordset to work with new worksheets.  

MFC doesn't have means to create .xls files but it sure has means to access them. ;-)

I hope it will be usefull.