Basic Excel Problem
Hello all,
I am working on a project and want to load excel libraries into C++ so that I can read/write data into cells.
Code:
#include <iostream>
#include <cmath>
// Office XP Objects (2003)
#import "C:\Program Files\Common Files\Microsoft Shared\OFFICE12\mso.dll"\
rename("DocumentProperties", "DocumentPropertiesXL")\
rename("RGB", "RBGXL")
//Microsoft VBA objects
#import "C:\Program Files\Common Files\Microsoft Shared\VBA\VBA6\VBE6EXT.OLB"
//Excel Application objects
#import "C:\Program Files\Microsoft Office\Office\excel.exe" \
rename("DialogBox", "DialogBoxXL")\
rename("RGB", "RBGXL")\
rename("DocumentProperties", "DocumentPropertiesXL")\
rename("ReplaceText", "ReplaceTextXL")\
rename("CopyFile", "CopyFileXL")\
exclude("IFont", "IPicture") no_dual_interfaces
using namespace std;
When I wrote the above code, I am getting an error
Code:
fatal error C1083: Cannot open type library file: 'c:\program files\microsoft office\office\excel.exe': Error loading type library/DLL.
Can someone please tell me what I am missing here inorder to run the code.
Thanks In Advance.
I think you can add the header:
#include "Excel9.h"
Hi,
After struggling a little bit, now I am able to write a program to access excel spreadsheets using MFC in VS2005. I am able to create the wrapper and able to access excel files, write data into it by specifying a cell number manually.
Also I can search for data in a given range by using Range.Find() function.
Code:
#define vOpt COleVariant((long) DISP_E_PARAMNOTFOUND, VT_ERROR)
..
..
Range range;
..
..
if(range.Find(COleVariant("09/28"), vOpt, vOpt, vOpt, vOpt, (long) 1, vOpt, vOpt))
{
...
}
Can someone please tell me how to get the cell number of that specific cell where the data is located.
Also is there any good tutorial or help file where I can refer to for further questions.
Thanks in advance
-
Gary
Everything is in MSDN
(and Win32 grp http://tinyurl.com/cmhb5g for Win32 COM)
Dozens of samples in C and C++ (official code, from MS...)