How to open an Excel file ? (from windows forms) I'm using Visual C++ express edition

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hello:
Im using Visual C++ express edition and my project requires to open an Excel file [in order to read and write data from/to some cells]. I have experience in C++, however Im not sure if the Excel file to be opened would be called a "Child" process (due to be running in the "background", while the main program and interface to the user is a Windows Form).
Firstly, My project starts with a Windows form which includes a button. A FileDialog is opened after clicking such button. (By the way, I found an example that opens a FileDialog -after clicking a button- and tries to open graphic files. Eventhough I was able to open the FileDialog and handle the FileOk event, I couldnt open the graphic files selected. Im not sure if the problem is located in the "fileStream" section)...returning to my project,a FileDialog is needed in order to open the Excel file required.
Could you please give me an example about how to open an Excel file (by using a FileDialog)? I would really appreciate it if you could include code lines to illustrate such procedure. Both the Excell application and the Windows form must be on the screen (the user must be able to select either window).
Secondly (and one step further), Im aware about how to read an write to Excel cells in Visual Basic (for example Cells(I, J).Value = 100); Do you know how to read/write Excel cells in Visual C++? Could you also include an example? Moreover, Is it possible to include instructions to Activate certain sheets in the Excell file in Visual C++ (again, in Visual Basic I know how to activate sheet1 of a Excell file, that is "Worksheets("Sheet1").Activate"....how could I instruct that in Visual C++?)
I would really, really appreciate your answers and examples (to either of my questions, or both). Thank you in advance.
Regards,

View the full article
 
Back
Top