| T O P I C R E V I E W |
| milkbou |
Posted - 03/09/2004 : 12:10:21 AM I don't know to how import multiple Excel worksheets by Origin C automatically, can someone tell me or give me some sample codes?
|
| 10 L A T E S T R E P L I E S (Newest First) |
| Gary Lane |
Posted - 03/16/2004 : 11:42:16 AM Hi,
You can:
1. Embed LabTalk commands in Origin C code using the global function LT_execute or better still the GraphLayer::LT_execute function. 2. Use an Origin C Tree to access most plot properties directly in Origin C. See the Programming Guide>Programming in Origin C>Accessing Plot Properties with Trees section of the Origin Programming Help File for two examples. 3. Create a theme using the Origin GUI and then use the Page::ApplyFormat function. See code fragment below:
Page pg = Project.Pages(); pg.ApplyFormat("C:\\Program Files\\OriginLab\\OriginPro8\\themes\\Ticks All In.OTH");
4. Create a plot template (having desired plot properties) using the Origin GUI, create a graph window using the Page::Create function and specifying your plot template as an argument, and then add dataplots to the layer using GraphLayer::AddPlot function.
Or, use any combination of above.
Hope this helps.
Gary OriginLab
Edited by - Gary Lane on 03/16/2004 11:43:24 AM |
| milkbou |
Posted - 03/15/2004 : 9:05:43 PM Hi Easwar, I read the sample codes and did some tests successfully, but I got trouble to modify the line pattern, symbol, shape, color, would you please give me some hints to modify the properties of every data set. I only found SetColor to change the color, and some LabTalk set command to change the symbol, shape, color and size. How can I change those properties by Origin C?
Best Regards
void DrawCDFPlots() { // Declare worksheet page using active page WorksheetPage wksPg = Project.Pages(); // Declare worksheet as layer 0 of worksheet page Worksheet wks = wksPg.Layers(0); // If worksheet is not valid, print error and return if(!wks) { printf("Active window is not a worksheet!\n"); return; } // Create new graph page using DoubleY template GraphPage gpg; gpg.Create("LINESYMB"); GraphLayer gly1 = gpg.Layers(0);
for(int ii=0;ii<125;ii++){ Curve crv1(wks, ii,ii+125); if(!crv1) { printf("Invalid curve object(s)!\n"); return; } int nPlot = gly1.AddPlot(crv1); if(nPlot>=0) gly1.DataPlots(nPlot).SetColor(ii,TRUE); } gly1.Rescale(); } |
| easwar |
Posted - 03/14/2004 : 9:49:29 PM Hi milkbou,
quote:
But I got one problem by using graph template, the count of my columns is not fixed every time, and it means I need to update the data source every time. Do you have any better solution?
You could push the data from Excel into a new Origin worksheet and then call an Origin C function to create customized plots. Origin C has access to Origin graph properties and so can be used to create and customize graphs. You will then need to first write/test your Origin C function in Origin. You could then add it to the System folder in Code Builder so that your function is available in each Origin session. Then you could launch Origin from Excel, send data over to Origin, and call your Origin C function by issuing a "script" command from Excel.
quote:
Besides, I would like to draw cumulative probability for multiple data pairs, but I can only draw one pair in one graph layer. How can I draw the chart?(X1Y1 X2Y2 X3Y3 ....)
I am not sure I understand this. Are you having problems in plotting multiple datasets in one single layer?
Easwar OriginLab.
|
| milkbou |
Posted - 03/14/2004 : 9:05:49 PM Hi Easwar, Thanks for your answer, I've studied the sample code and it works fine. But I got one problem by using graph template, the count of my columns is not fixed every time, and it means I need to update the data source every time. Do you have any better solution? Besides, I would like to draw cumulative probability for multiple data pairs, but I can only draw one pair in one graph layer. How can I draw the chart?(X1Y1 X2Y2 X3Y3 ....)
Thanks! |
| easwar |
Posted - 03/12/2004 : 2:28:05 PM Hi milkbou,
You could do the following: 1> Use Origin directly to first create your own custom Origin project that has worksheets and customized graphs set up exactly the way you want them to look like. 2> Save your custom Origin project(s) - you could optionally clear all the worksheet data before saving the proejct(s) 3> Use Excel as a COM client application and launch Origin (hidden or visible - your choice) from Excel 4> Open one of your custom Origin projects in Origin 5> Push your Excel data into Origin. Your graphs will update - you may need to set up automatic rescaling for the graphs, or just issue commands from Excel to Origin to rescale the graphs 6> Copy your graphs in Origin to the clipboard or export them to a disk file 7> Paste or import the graph from clipboard or file into your Excel worksheet.
You can of course further customize your graphs by issuing commands to Origin, but it may be easier to start with an already customized template in a saved project, so that you don't need to issue too many commands.
To view an example of how this can be done, please take a look at the Automation Server example: "..\Samples\Automation Server\Excel\FFTFiltering.XLS" under the Origin installation folder.
This sample is available in Origin 7.5 product and also in the demo.
The VB macro code in this XLS file launches Origin as a COM Automation Server application, opens a special project in Origin, pushes Excel data into Origin worksheet, and then brings back a graph with results from Origin to Excel. Some computation is also performed by Origin in this example, by making use of the automatic update of column values feature, which in turn calls Origin C code to perform the computing.
Hope this helps.
Easwar OriginLab. |
| milkbou |
Posted - 03/12/2004 : 02:43:54 AM Hi Hajo, In general, MS Excel is a good tool for plotting graphs. But unfortunately, it's hard to plot cumulative probability plot and box plot by Excel, that's why my boss wants me to do this work. My VBA(visual basic application) program can draw hundreds graphs in Excel for engineering data analysis, but graph types are limited. My boss's idea is to view OriginPro 7.5 as a graph server, my program can send data to Origin, then plot and configure(xlabel,ylabel,title,legend,.) graphs in Origin, and then send it back to Excel. At first, I need to know to configure all properties of Origin graph, do you have any suggestion? |
| hajo_old |
Posted - 03/11/2004 : 3:49:35 PM Hi, Lin
I'm far from criticizing your boss, but isn't it a sort of overkill to create graphs in Origin and then go back to Excel and embed them?
Easy graphing can be done quite practicable in Excel with the advantage to have a link to the datasources ...
My suggestion to present the graphs would be to export them to Powerpoint ... Have a look to the function I've provided in the FileExchange: http://www.originlab.com/FileExchange/details.aspx?C=5&cid=4&fid=58 You'll have to know how to import & compile a file in the OriginC Code builder, but the function could be a starting point!
So far Hajo
-- -- Dipl.-Ing. Hans-Joerg Koch Siemens VDO, Regensburg
SVDO_Origin1 is now hajo  |
| Mike |
Posted - 03/11/2004 : 10:13:30 AM If you need some basic instruction in working with Excel data in Origin, you should look over these online Help file resources:
1. Choose Help:Tutorials and read through Tutorial 5, "Working with Excel in Origin"
2. Choose Help:Origin and read through these sections: >> "Working with Excel in Origin", in particular the section "Plotting Workbook Data" >> "Interfacing with Other Applications" > "Sharing Your Graph with Another Application"
This assumes that you are working with Origin 7.5. The same info would be available in Origin 7, but the topics would be organized somewhat differently. I hope this that helps.
Mike Genthner Documentation Specialist OriginLab |
| milkbou |
Posted - 03/10/2004 : 01:18:12 AM Hi Iris, Thanks for your helps! I'm new to OC, my boss ask me to draw plots by Origin and embed the plots in Excel file. I don't know how to start, any documents or books suggest to read? |
| Iris_Bai |
Posted - 03/09/2004 : 06:35:10 AM Hi milkbou,
Maybe the following codes are useful for you.
void ImportFromExcelWksheets(string filePath){ // Declare Excel objects Object oExcel, oExcelWkbks, oExcelWkbk, oExcelWksh, data; // Create an Excel application object and set it as invisible oExcel = CreateObject("excel.application"); oExcel.Visible = false; // Get the workbooks collection of the Excel object oExcelWkbks = oExcel.Workbooks; // Bring up wait cursor waitCursor wCursor; printf("Processing...\n"); // Open the workbook with data to be analyzed oExcelWkbk = oExcelWkbks.Open(filePath); if(oExcelWkbk){ foreach(oExcelWksh in oExcelWkbk.Worksheets){ Worksheet wk; wk.Create(); data = oExcelWksh.UsedRange; int endRow = data.Rows.Count + data.Row - 1; int endCol = data.Columns.Count + data.Column - 1; wk.SetSize(endRow, endCol); //wk.Name(oExcel.Name); string value; for(int i = data.Row - 1; i < endRow ; i ++) for(int j = data.Column - 1; j < endCol; j ++){ value = oExcelWksh.Cells(i + 1, j + 1).Text; if(!value.IsEmpty()) wk.SetCell(i, j, value); } } } oExcel.Quit(); }
void ImportFromExcel(){ // Get file path string filePath; filePath = GetOpenBox( FDLOG_EXCEL ); // Processing if(!filePath.IsEmpty()){ ImportFromExcelWksheets(filePath); } }
Jason
Edited by - Iris_Bai on 03/09/2004 06:40:52 AM |
|
|