I have a program which retrieves data from a SQL server. I want to write this data to an excel sheet and draw graphs using this data.
As of now I wrote the output of my program in csv format, so after I run the program it creates an excel file.
But how can I make my program open an excel sheet, write data to it, generate the graphs.
Basically my output should be an excel file with data and graphs in it.
Any kind of help is appreciated.
Thanks.
Thanks a lot. That was helpful.
Now I have another problem. ....
I could open an excel application, create a new workbook and write data, (Strings and integers) to it. But I wanted to know how I could draw graphs with this data.
I recorded a macro in excel and I have the VB code to do what I want, but please tell me how I should write this VB code in C++
Thanks.
Thanks for your reply, but I am not using MFC's to automate excel. I wrote the Automation code in straight C++ with help from Microsoft Knowledgebase. Can you please guide me on how to draw charts with this.....
I could not find any help in the MS knowledgebase.
Appreciate your help.
I'm attaching a bare bones ( sphaghetti code without comments )example of creating an xy chart based on the example of automation without using the type library on MSDN.
I created anexcel file d:\junk.xls that had x data in a1-a7 and
y data in b1-b7. You will have to do so too if you try this program.
I first tried to use the chart wizard but eventually gave up and created the plot directly.
Last edited by Tom Frohman; November 18th, 2003 at 10:06 AM.
Verere testudinem! (Fear the turtle)
Once you can accept the universe as matter expanding into nothing that is something, wearing stripes with plaid comes easy. -Albert Einstein
Thankyou very much. That was a great help I could build bar and pie charts for my data with your help. But where do I get more information about the code. Which is the right place to read about what each statement is doing.
Each time I do something in Automation the first thing I do is record a VBA macro and then translate it into C++.
I look up the functions that VBA used and the VBA help to get descriptions of the functions and the constants needed. The object inspector of the VBA editor (F2) is also a valuable resource. You can look up the classes and their members.
To find the methods and the arguments specifically for C, I look in the excel9.olb type library using OLEView.
Verere testudinem! (Fear the turtle)
Once you can accept the universe as matter expanding into nothing that is something, wearing stripes with plaid comes easy. -Albert Einstein
That was helpful. I figured that out by looking at your code, but I thought may be there was a fast rule to do this.
I have another question, I tried recording macros in VB, but it does not seem to record all the things I do. Like for example, when I recorded a macro for drawing the graphs, I set the values to be seen on the top of the bar, but I could not see the code for that in the macro.
Originally posted by gurupot
That was helpful. I figured that out by looking at your code, but I thought may be there was a fast rule to do this.
I have another question, I tried recording macros in VB, but it does not seem to record all the things I do. Like for example, when I recorded a macro for drawing the graphs, I set the values to be seen on the top of the bar, but I could not see the code for that in the macro.
Yes, I've seen that happen with macros. I don't know a way around it.
Verere testudinem! (Fear the turtle)
Once you can accept the universe as matter expanding into nothing that is something, wearing stripes with plaid comes easy. -Albert Einstein
I appreciate your help earlier.
I could successfully write data and graphs to excel, but when I try to save it, its giving me an errror. The strange thing is, it worked first and after a few days it showed me this error. Here is my code, please let me know if you can help.
//Get the active workbook
IDispatch *pXlActiveWorkBook;
{
VARIANT result;
VariantInit(&result);
AutoWrap(DISPATCH_PROPERTYGET, &result, pXlApp, L"ActiveWorkbook", 0);
pXlActiveWorkBook = result.pdispVal;
}
Hello, i want to ask if anybody knows the way to use in C++ the DISPATCH_METHOD with AUTOWRAP for the function "ChartWizard" with it's possible to put the tittle in a excel's chart.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.