Data: Import from File: Excel (XLS, XLSX, XLSM)...
This X-Function supports file re-import. See this topic for details.
Import Excel (XLS, XLSX....) files directly into Origin, without the need for Excel.
Note that prior to Origin 2017, Origin used another Excel X-Function (see impExcel) which launched Excel in the background in order to import XLSX files.
1. fname$="sample.xls"; impMSExcel; // import the file sample.xls
2. impMSExcel fname:="c:\test1.xlsxt%(crlf)c:\test2.xlsx" options.sparklines:=1 options.Mode:=4 options.Headers.LongName:=1 options.Headers.Units:=2;
Please refer to the page for additional option switches when accessing the x-function from script
|
|
|
|
|
---|---|---|---|---|
|
|
Input string |
Filename of the file to be imported. | |
|
|
Input TreeNode |
This is used in the dialog for displaying the file size. The information is detected by Origin automatically. | |
|
|
Input TreeNode |
This is mainly used in the dialog, for tweaking the import options. See more details in Description | |
|
|
Output Range |
This is used to specify the output range. | |
|
|
Output TreeNode |
This is for outputting the header information. It is hidden from the GUI. Users are not advised to use this variable. | |
Repeat Import |
Input int |
|
Specify whether the current import is a reimporting process. It is hidden from the GUI. Use of this variable is not advised. |
This X-Function is used for importing Microsoft Excel files. It doesn't use COM and thus works for .XLS .XLSX and .XLSM files even if Excel is not installed.
impMSExcel -d
in command window.The imported Excel workbook can have more than one sheet. All sheets will be imported into separate Origin worksheets in the target workbook, using the same import settings. See Options Tree Details section for details of import settings
From Origin 2015, re-import one or multiple sheets from Excel to Origin is supported. During Excel re-importing, a link is maintained so that Origin is able to use up-to-date data. To re-import Excel files,
reimport -d
in command window to re-import Excel files.Origin 2016 introduce a <clone> template, which allows you to import Excel workbook(s) into a prepared workbook template or analysis template to batch customize/analyze data in Excel books. See details in Options Tree Details section.
The following example imports an Excel file using factory default options:
The following script command imports an Excel file (c:\test.xls) without opening the dialog:
newbook; string fname$ = system.path.program$ + "Samples\Graphing\Excel Data.xls"; impMSExcel options.cellfmts:=1 options.headers.MainHeaderLines:=1 options.headers.SubHeaderLines:=1 options.headers.LongName:=1; //copy cell format of Excel file while importing
The following script command imports the specified Excel sheets:
newbook; string fname$ = "c:\test.xls"; impMSExcel options.sheet:=1:3:5; //Import the first, the third and the fifth Excel sheets only newbook; impMSExcel options.sheet:=SheetName1:SheetName2; //Import the Excel sheets named SheetName1 and SheetName2