I would like to save tables t1, t2 and t3 in the same excel file but in different worksheets.
How can I modify the following code which save the tables in three different excel files?
for %endvar 1 2 3
t{%endvar}.save(r=A1:L23, t=csv) t{%endvar}
next
Save tables in specific excel worksheets
Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt
-
- EViews Developer
- Posts: 563
- Joined: Thu Apr 25, 2013 7:48 pm
Re: Save tables in specific excel worksheets
Hello,
The table object's save proc doesn't support saving to Excel files, you'll have to use the more general wfsave command instead. Take a look a this thread.
The table object's save proc doesn't support saving to Excel files, you'll have to use the more general wfsave command instead. Take a look a this thread.
Re: Save tables in specific excel worksheets
If I am not mistaken the thread is for time series.
I do not want to export a time series, but a table created in Eviews.
Assume that I have created a table labeled "Tabletobesaved" and I would like to export this table in an excel file called macro.xls and in a sheet labeled worksheet1.
The code below gives me an error
wfsave(type=excelxml, mode=update) macro.xls @keep Tabletobesaved worksheet1
Any suggestion?
I do not want to export a time series, but a table created in Eviews.
Assume that I have created a table labeled "Tabletobesaved" and I would like to export this table in an excel file called macro.xls and in a sheet labeled worksheet1.
The code below gives me an error
wfsave(type=excelxml, mode=update) macro.xls @keep Tabletobesaved worksheet1
Any suggestion?
-
- EViews Developer
- Posts: 563
- Joined: Thu Apr 25, 2013 7:48 pm
Re: Save tables in specific excel worksheets
My apologies, I somehow forgot mid-research that you're working with tables instead of series. Unfortunately, there's no completely automated way to do what you want. Your two basic options are to either (1) save the table in CSV format and open it in Excel, which will discard any formatting, or (2) follow the instructions in this thread for ways to preserve formatting.
-
- EViews Developer
- Posts: 799
- Joined: Tue Sep 16, 2008 3:00 pm
- Location: Irvine, CA
Re: Save tables in specific excel worksheets
I would suggest a different method.
You can use EViews' support for OLE to do a Copy / Paste Special to save the entire contents of your table to an Excel spreadsheet. This only works if your workfile has been saved and your table has a name (not UNTITLED). Copy all the table cells you want, switch to Excel, then right-click a cell and select Paste Special. On the next dialog, select the "Paste link" option and select Text as the type.
This will link the cell contents to the corresponding cells in the EViews table. When the EViews table contents update, the spreadsheet can also be updated.
If you need a more programmatic way to do this, I would do it in two steps. Simply save the table as a CSV file:
Next, open the Excel spreadsheet and click the Data ribbon tab and click "From Text". That will start the text import wizard. Make sure you select "Comma" as a delimiter. Once completed, you'll have a spreadsheet that is linked to the CSV file. Now whenever you update the table in the EViews workfile, you can simply re-save it to the CSV file and then Excel will be able to get the update.
You can use EViews' support for OLE to do a Copy / Paste Special to save the entire contents of your table to an Excel spreadsheet. This only works if your workfile has been saved and your table has a name (not UNTITLED). Copy all the table cells you want, switch to Excel, then right-click a cell and select Paste Special. On the next dialog, select the "Paste link" option and select Text as the type.
This will link the cell contents to the corresponding cells in the EViews table. When the EViews table contents update, the spreadsheet can also be updated.
If you need a more programmatic way to do this, I would do it in two steps. Simply save the table as a CSV file:
Code: Select all
table01.save(t=csv) c:\files\table01.csv
Next, open the Excel spreadsheet and click the Data ribbon tab and click "From Text". That will start the text import wizard. Make sure you select "Comma" as a delimiter. Once completed, you'll have a spreadsheet that is linked to the CSV file. Now whenever you update the table in the EViews workfile, you can simply re-save it to the CSV file and then Excel will be able to get the update.
Re: Save tables in specific excel worksheets
but this does not allow me to create many worksheets.
I would like to save tables t1, t2, t3 ... t100, in the same excel file but in different worksheets automatically.
I would like to save tables t1, t2, t3 ... t100, in the same excel file but in different worksheets automatically.
-
- EViews Developer
- Posts: 799
- Joined: Tue Sep 16, 2008 3:00 pm
- Location: Irvine, CA
Re: Save tables in specific excel worksheets
Yes, you can't programmatically create a single excel file with multiple sheets, each one from a different EViews table. But you can manually create one and then link each worksheet to the source CSV file to allow for easy updating.
When EViews writes a CSV file, that's simply a comma delimited text file. Microsoft Excel tends to take ownership of that file extension to say it's an Excel file type, but really it's just a simple text file. And there isn't a way to write a single CSV file that contains multiple pages of data.
Also, when EViews write an XLS or XLSX file, we re-create the entire file each time. I don't believe we ever open an existing file, add data, then save the changes. So currently there isn't a way to do what you're asking.
There are ways to write VBA script in Excel to join multiple CSV files together into a single Excel spreadsheet with multiple pages. Here's a link that talks about how to do just that.
When EViews writes a CSV file, that's simply a comma delimited text file. Microsoft Excel tends to take ownership of that file extension to say it's an Excel file type, but really it's just a simple text file. And there isn't a way to write a single CSV file that contains multiple pages of data.
Also, when EViews write an XLS or XLSX file, we re-create the entire file each time. I don't believe we ever open an existing file, add data, then save the changes. So currently there isn't a way to do what you're asking.
There are ways to write VBA script in Excel to join multiple CSV files together into a single Excel spreadsheet with multiple pages. Here's a link that talks about how to do just that.
Re: Save tables in specific excel worksheets
It would be useful if the Eviews team could create a piece of programme, which allows to export n tables in n different sheets of the same excel file, such as
for %table 1 2 3
filename.save(r=x:y, t=xls, sheet{%table}) c:\files\table
next
for %table 1 2 3
filename.save(r=x:y, t=xls, sheet{%table}) c:\files\table
next
Who is online
Users browsing this forum: No registered users and 53 guests