Exporting to existing excel file

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt

trainee
Posts: 38
Joined: Fri Jun 13, 2014 12:59 pm

Exporting to existing excel file

Postby trainee » Fri Jul 21, 2017 5:54 am

Is there a way to export data from E-views workfile to an existing excel spreadsheet?

Thanks.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13294
Joined: Tue Sep 16, 2008 5:38 pm

Re: Exporting to existing excel file

Postby EViews Gareth » Fri Jul 21, 2017 6:12 am

Follow us on Twitter @IHSEViews

trainee
Posts: 38
Joined: Fri Jun 13, 2014 12:59 pm

Re: Exporting to existing excel file

Postby trainee » Fri Jul 21, 2017 7:30 am

I tried the following code. It didn't populate anything.

wfsave(type=excel, mode=update) test.xls range="Sheet1!a1" byrow @keep au_gdpr

Thanks.

EViews Steve
EViews Developer
Posts: 788
Joined: Tue Sep 16, 2008 3:00 pm
Location: Irvine, CA

Re: Exporting to existing excel file

Postby EViews Steve » Mon Jul 24, 2017 8:56 am

Works for me...

Keep in mind that if you have the Excel file open in Excel at the time you run the WFSAVE command, EViews is forced to ask Excel to make the changes via COM since Excel has the file locked. Which means the changes are made to the open file in memory, at which point you'll have to manually save the file in Excel in order to keep the changes. If the file is not open, EViews can make the changes directly to the saved file.

Steve

trainee
Posts: 38
Joined: Fri Jun 13, 2014 12:59 pm

Re: Exporting to existing excel file

Postby trainee » Mon Jul 24, 2017 10:12 am

No I don't have the file open. Also, I have a feeling that the "write" command is now obsolete. Is that true? If yes, what do you suggest we use?

EViews Steve
EViews Developer
Posts: 788
Joined: Tue Sep 16, 2008 3:00 pm
Location: Irvine, CA

Re: Exporting to existing excel file

Postby EViews Steve » Mon Jul 24, 2017 10:17 am

We mention on the write help page that you should use pagesave when not saving in transposed form. But WFSAVE will work just fine for that too.

If you're still having trouble, for now, just try saving your workfile page to a new excel spreadsheet file, but leave the range argument out, like this:

Code: Select all

wfsave(type=excel, mode=update) test_new.xls byrow @keep au_gdpr

and see if you can see your data. Once confirmed, manually your data in the spreadsheet to be anything else, save and close the spreadsheet, then re-run the exact same WFSAVE command to see if the spreadsheet is restored.

trainee
Posts: 38
Joined: Fri Jun 13, 2014 12:59 pm

Re: Exporting to existing excel file

Postby trainee » Mon Jul 24, 2017 11:52 am

Still no luck. However, seems to work for my colleague here. Even the write function is not working for me. So strange.

EViews Steve
EViews Developer
Posts: 788
Joined: Tue Sep 16, 2008 3:00 pm
Location: Irvine, CA

Re: Exporting to existing excel file

Postby EViews Steve » Mon Jul 24, 2017 12:21 pm

Did the new file get created? Did it fail on the first or the second WFSAVE call? Please provide more details on what worked and what didn't.

Also make sure you are using the latest version of your EViews software.

trainee
Posts: 38
Joined: Fri Jun 13, 2014 12:59 pm

Re: Exporting to existing excel file

Postby trainee » Mon Jul 24, 2017 12:24 pm

Figured out what the problem was. My path was pointing to the wrong folder. Sorry for the trouble.

trainee
Posts: 38
Joined: Fri Jun 13, 2014 12:59 pm

Re: Exporting to existing excel file

Postby trainee » Mon Jul 24, 2017 1:50 pm

Another question - I'm trying to use wfsave to save data in different tabs of an excel spreadsheet. But I can't seem to do that in one go. Instead e-views will close the excel file and open it again every time which takes a lot of time. Is there a way around this? Thanks so much.

Using the following code:

for %country {%countries}

wfsave(type=excel, mode=update) test.xls range= %country!a1 byrow @keep wt_gmfm_{%country}_t wt_gmfm_{%country}_t1 wt_stem_{%country}_t wt_stem_{%country}_t1 wt_bbg_{%country}_t wt_bbg_{%country}_t gmfm_{%country}_{%c}tc gmfm_{%country}_{%e}t1c stem_{%country}_{%c}tc stem_{%country}_{%e}t1c bbg_{%country}_{%c}tc bbg_{%country}_{%e}t1c

next

EViews Steve
EViews Developer
Posts: 788
Joined: Tue Sep 16, 2008 3:00 pm
Location: Irvine, CA

Re: Exporting to existing excel file

Postby EViews Steve » Tue Jul 25, 2017 7:12 am

No there isn't a way to do this in one go.

You might look into using the EViews Excel adding from within Excel to import and link data from your workfile to your spreadsheet. That way you can simply ask Excel to refresh all data. It'll probably be faster that way instead of pushing data from EViews sheet by sheet.


Sent from my iPhone using Tapatalk

trainee
Posts: 38
Joined: Fri Jun 13, 2014 12:59 pm

Re: Exporting to existing excel file

Postby trainee » Tue Jul 25, 2017 12:13 pm

Thanks Steve. When one uses the Wfsave function it seems to dump all values in a series. However, I only want to dump non-NA values in the series into excel. For instance, the following code would dump the entire series including all the NAs. Is there something I can do about it? May be assign a sample?

wfsave(type=excel, mode=update) tracking.xls range=weights!a2 @keep wt_gmfm_us_t

Thanks.

EViews Steve
EViews Developer
Posts: 788
Joined: Tue Sep 16, 2008 3:00 pm
Location: Irvine, CA

Re: Exporting to existing excel file

Postby EViews Steve » Tue Jul 25, 2017 12:30 pm

Yes use @smpl to change your sample range on the save.


Sent from my iPhone using Tapatalk

trainee
Posts: 38
Joined: Fri Jun 13, 2014 12:59 pm

Re: Exporting to existing excel file

Postby trainee » Tue Jul 25, 2017 12:52 pm

Can you give me an example? I tried the following but E-views dosen't like it:

wfsave(type=excel, mode=update) tracking.xls range=weights!a2 @keep @smpl 2014Q3 2017Q2 wt_gmfm_us_t

Thanks.

EViews Steve
EViews Developer
Posts: 788
Joined: Tue Sep 16, 2008 3:00 pm
Location: Irvine, CA

Re: Exporting to existing excel file

Postby EViews Steve » Tue Jul 25, 2017 12:57 pm

Follow the order of the arguments as described on the WFSAVE help page.

http://www.eviews.com/help/helpintro.ht ... fsave.html


Sent from my iPhone using Tapatalk


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 19 guests