import_files
Description
This function is called from the OC code and is for user import mutiple files with the specified filter.
Syntax
int import_files(const StringArray& stDataFileName, LPCSTR strPageName, int nIndexLayer, TreeNode& trFilter = NULL)
Parameters
- stDataFileName
- full path of data files.
- strPageName
- target book name.
- nIndexLayer
- index of sheet on book.
- trFilter
- filter tree loaded by load_import_filter function.
- If NULL, will auto detect suitable filter, if find multiple suitable filter will popup a box to choose one.
Return
0 = success, -1 = failed, -2 = find function error.
Examples
Before compile this example please run run.LoadOC(Originlab\FileImport.c, 16); in Command Window to load all depentence source files.
#include <..\Originlab\FileImport.h>
void import_files_with_specify_filter_ex()
{
Page pg = Project.Pages(); // Active Page
// Get page book name
string strPageName = pg.GetName();
// Get page active layer index
int nIndexLayer = pg.Layers().GetIndex();
// Get Origin sample folder
string strPath = GetAppPath(TRUE) + "Samples\\Import and Export\\";
// List all file names need to imported
StringArray saFileNames;
saFileNames.Add(strPath + "pCLAMP\\93310C08.DAT");
saFileNames.Add(strPath + "pCLAMP\\93310C10.DAT");
saFileNames.Add(strPath + "pCLAMP\\93311C01.DAT");
// specify .oif filter name, location see the setting of nLocation below.
string strFilterName = "pCLAMP";
// import filter tree
// about filter settings, refer to imppClamp xfunction tree variable "options"
Tree trFilter;
int nLocation = 1; // Origin exe folder, more options see the document of load_import_filter function.
int nRet;
nRet = load_import_filter(strFilterName, saFileNames[0], strPageName, nLocation, trFilter);
if ( 0 == nRet )
out_str("Success to load import filter!");
else
out_str("Failed to load import filter!\nPlease check strFilterName and nLocation if assigned correctly");
if ( 0 == nRet )
{
nRet = import_files(saFileNames, strPageName, nIndexLayer, trFilter);
if ( 0 == nRet )
out_str("Success to import!");
else
out_str("Failed to import!");
}
}
Remark
See Also
load_import_filter
header to Include
FileImport.h
Reference
|