VC++ and MSExcel 2003 sheets handling

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: May 2009
Posts: 3
Reputation: pferian is an unknown quantity at this point 
Solved Threads: 0
pferian pferian is offline Offline
Newbie Poster

VC++ and MSExcel 2003 sheets handling

 
0
  #1
May 20th, 2009
Hy, I have to develop an application usign Visual C++ 2008 that should handle (open, change cells and save) some Excel 2003 sheets. I am using .NET Framework 3.5 and the COM reference Interop.Excel.1.5.
Does anyboby knows how to code this?
Thanks.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,266
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: VC++ and MSExcel 2003 sheets handling

 
0
  #2
May 20th, 2009
Read the manual.
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,472
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1477
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: VC++ and MSExcel 2003 sheets handling

 
0
  #3
May 20th, 2009
Here is one way to do it , I think, without the complications of COM. The GUI interface is probably not what you want but you can extract the ideas that document presents.
Last edited by Ancient Dragon; May 20th, 2009 at 9:05 am. Reason: add link
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 2,902
Reputation: niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute 
Solved Threads: 302
Moderator
Featured Poster
niek_e's Avatar
niek_e niek_e is offline Offline
Cenosillicaphobiac

Re: VC++ and MSExcel 2003 sheets handling

 
0
  #4
May 20th, 2009
Originally Posted by Ancient Dragon View Post
Here is one way to do it without the complications of COM.
Where?

At OP:
You might want to use CSV-files from excel. The CSV files can easily be opened and edited with C++ because they are plain text, so no need for COM
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,472
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1477
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: VC++ and MSExcel 2003 sheets handling

 
0
  #5
May 20th, 2009
Originally Posted by niek_e View Post
Where?
Oops! link added.
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 3
Reputation: pferian is an unknown quantity at this point 
Solved Threads: 0
pferian pferian is offline Offline
Newbie Poster

Re: VC++ and MSExcel 2003 sheets handling

 
0
  #6
May 20th, 2009
I found the way myself. This is the code that works:

private: System::Void button7_Click(System::Object^ sender, System::EventArgs^ e)
{
String^ XlsFile = String::Format("Z:\\Documenti\\Lavoro\\Fatture\\2009\\Fattura_02_AEM_marzo_09.xls");
String^ XlsSheet = String::Format("Milano, {0}/{1}/{2}",
dateTimePicker1->Value.Day.ToString(),
dateTimePicker1->Value.Month.ToString(),
dateTimePicker1->Value.Year.ToString());

Excel::Application^ oXLApp;
Excel::Workbook^ oXLWBook;
//Excel::Sheets^ oXLSheet;
//Excel::Worksheet^ oXLWSheet;

Excel::Range^ rng;

//starts Excel application
oXLApp = (gcnew Excel::Application());
oXLApp->Visible = true;
//opens the workbook of the file "XlsFile"
oXLWBook = oXLApp->Workbooks->Open(XlsFile, 0, false, 5, "", "",
true,Excel::XlPlatform::xlWindows, "\t", true, false, 0, false, true, true);
//updates the range of sheet1, cell D4
rng = oXLApp->Range::get("D4","D4");
rng->Value2 = XlsSheet;

}
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC