Importing from Excel 2007
Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt
-
LanceCarey
- Posts: 4
- Joined: Mon Jan 10, 2011 10:04 am
Importing from Excel 2007
I am trying to import data from Excel 2007 (.xlsx) in a program. Is there a way to only import only the first three columns (or a certain range) in command mode?
-
EViews Glenn
- EViews Developer
- Posts: 2682
- Joined: Wed Oct 15, 2008 9:17 am
Re: Importing from Excel 2007
From the documentation for wfopen. The syntax for reading Excel and Lotus files is:
wfopen(options) source_description [table_description] [variables_description]
The following table_description elements may be used when reading Excel and Lotus data:
"range = arg", where arg is a range of cells to read from the Excel workbook, following the standard Excel format [worksheet!][topleft_cell[:bottomright_cell]].
If the worksheet name contains spaces, it should be placed in single quotes. If the worksheet name is omitted, the cell range is assumed to refer to the currently active sheet. If only a top left cell is provided, a bottom right cell will be chosen automatically to cover the range of non-empty cells adjacent to the specified top left cell. If only a sheet name is provided, the first set of non-empty cells in the top left corner of the chosen worksheet will be selected automatically. As an alternative to specifying an explicit range, a name which has been defined inside the excel workbook to refer to a range or cell may be used to specify the cells to read.
The same syntax should work for import and xlsx files.
wfopen(options) source_description [table_description] [variables_description]
The following table_description elements may be used when reading Excel and Lotus data:
"range = arg", where arg is a range of cells to read from the Excel workbook, following the standard Excel format [worksheet!][topleft_cell[:bottomright_cell]].
If the worksheet name contains spaces, it should be placed in single quotes. If the worksheet name is omitted, the cell range is assumed to refer to the currently active sheet. If only a top left cell is provided, a bottom right cell will be chosen automatically to cover the range of non-empty cells adjacent to the specified top left cell. If only a sheet name is provided, the first set of non-empty cells in the top left corner of the chosen worksheet will be selected automatically. As an alternative to specifying an explicit range, a name which has been defined inside the excel workbook to refer to a range or cell may be used to specify the cells to read.
The same syntax should work for import and xlsx files.
Re: Importing from Excel 2007
Hi,
I have an question related to importing Excel files (2007) with worksheet names containing spaces.
Placing the name in single quotes works fine in the command box. However in a program file the single quotes start a comment section directly after range='...
import... .xlsx range='CUP N'!$B$19:$AZ$166 colhead=4 na="#N/A" @freq Q 1995Q1 @smpl @all
When I rename the worksheet omitting the space, the code works fine. However, renaming all my worksheets is not really an option.
Is there something I can do? or maybe a workaround. I'm using Eviews 9.
Thanks in advance and Merry Chrismas.
I have an question related to importing Excel files (2007) with worksheet names containing spaces.
Placing the name in single quotes works fine in the command box. However in a program file the single quotes start a comment section directly after range='...
import... .xlsx range='CUP N'!$B$19:$AZ$166 colhead=4 na="#N/A" @freq Q 1995Q1 @smpl @all
When I rename the worksheet omitting the space, the code works fine. However, renaming all my worksheets is not really an option.
Is there something I can do? or maybe a workaround. I'm using Eviews 9.
Thanks in advance and Merry Chrismas.
-
EViews Steve
- EViews Developer
- Posts: 844
- Joined: Tue Sep 16, 2008 3:00 pm
- Location: Irvine, CA
Re: Importing from Excel 2007
Use double-quotes around the page name:
If you perform the import using our import wizard (File/Import/Import from file...), the captured command will use double quotes in the final output. If you're not seeing this properly from the captured command, I believe there was a fix recently made to resolve sheetnames with spaces in them. Update your copy of EViews 9 to the latest version.
Steve
Code: Select all
import... .xlsx range="CUP N"!$B$19:$AZ$166 colhead=4 na="#N/A" @freq Q 1995Q1 @smpl @allSteve
Who is online
Users browsing this forum: No registered users and 2 guests
