The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 FileName of loaded Data
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

uidt6047

Germany
4 Posts

Posted - 11/13/2014 :  07:39:32 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin 8.6.0G, Sr1
Operating System: Windows 7

I'm just preparing some generic C-functions for Origin users to support them in doing their data evaluatin by calling batch-mode and combining it with a function like "export_all_graphs".

I would like to know, how I could get the filename+path of a loaded Ascii-File, e.g. imported to Sheet1.
I do know how to get the name of the sheet (in my case it's also the filename), but I don't know how to get the whole path of this file!

It would be also helpful to know which Graphs are in relation to this imported data.

Does anybody have an idea how to solve this problem?

Thanks!

Echo_Chu

China
Posts

Posted - 01/14/2015 :  10:21:14 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Please look at the sample code for getting import file info and finding out the related graphs.


void test_import_file_info() {
	Worksheet wks = Project.ActiveLayer();  // Active worksheet
	WorksheetPage wp = wks.GetPage();  // Workbook of the worksheet
	//vector<string> vs;
	//wp.GetStorageNames(vs);  // Get storage names of workbook
	Tree tr;
	wp.GetBinaryStorage("Files", tr);  // Get the imported file info
	string strFile = tr.File1.Info.FilePath.strVal;  // The imported file name, maybe more than one
	out_str(strFile);
	
	string strBook, strSheet;
	strBook = wp.GetName();  // Get the workbook name
	strSheet = wks.GetName();  // Get the worksheet name
	out_str(strBook);
	out_str(strSheet);
	vector<string> vsGraphs;  // Use to hold the graph names related to the worksheet
	// GraphPage loop
	foreach(GraphPage gp in Project.GraphPages) {  // Loop all graphs in the project
		// GraphLayer loop
		foreach(GraphLayer gl in gp.Layers) {  // Loop all graph layers in the graph
			bool isRelated = false;  // If the graph related to the worksheet
			// DataPlot loop
			foreach(DataPlot dp in gl.DataPlots) {  // Loop all data plots in the graph layer
				DataRange dr;
				dp.GetDataRange(dr);  // Get data range of the data plot
				string strBook1, strSheet1;
				dr.GetBookSheet(strBook1, strSheet1);  // Get workbook and worksheet name of the data range
				// Check if the data plot's workbook and worksheet are identical to 
				// the workbook and worksheet with imported file
				if(0 == strBook1.CompareNoCase(strBook) && 0 == strSheet1.CompareNoCase(strSheet)) {
					vsGraphs.Add(gp.GetName());  // Add graph name
					isRelated = true;  // The graph is related to the worksheet
					break;  // Break out the DataPlot loop
				}
			}
			if(isRelated) {
				break;  // Break out the GraphLayer loop
			}
		}
	}
	for(int i = 0; i < vsGraphs.GetSize(); i++) {
		out_str(vsGraphs[i]);
	}
}

Go to Top of Page

carolsteven

USA
1 Posts

Posted - 01/30/2015 :  04:47:03 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks man (Echo_Chu) for the helpful information.
Go to Top of Page

uidt6047

Germany
4 Posts

Posted - 02/05/2015 :  04:17:18 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
[quote]Originally posted by Echo_Chu
Hi Echo_Chu,

thanks for your helpfull sample code!!
Meanwhile (during christmas holiday!) I found nearly the same solution as you told me
But I called the method wp.GetStorage instead of wp.GetBinaryStorage, as you did. I don't know what's the difference is!?
Go to Top of Page

HelenDonald

USA
1 Posts

Posted - 02/09/2015 :  07:10:16 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks all members for sharing such useful information here.It is helpful.


Go to Top of Page

elizabethwillam

USA
1 Posts

Posted - 02/12/2015 :  07:54:24 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you (Echo_Chu) for the sample code.
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000