This is the second of three postings that show how to 1) capture RSSBus
service data in Excel, 2) update the data when the worksheet is opened,
and 3) update the data when cell values change.
In order to run the examples, you will have to download the
zip file as explained in Part 1.
Update data on open:
Instead of returning CSV data as was shown Part 1, we can have
RSSBus return an IQY (internet query) file that contains data import
directives. Excel will execute the
directives every time the worksheet is opened, or every time you click “Refresh Data” in the Excel Data
menu.
|
|
CSV formatter
|
IQY files
|
|
|
URL param
|
@format=csv
|
@xls
|
|
|
Excel contains
|
Actual CSV data
|
Query that fetches data
|
|
|
Data freshness
|
Data in Excel does not change after initial load
|
Data updates on parameter change, and Refresh Data
|
|
|
Parameters
|
From URL parameters, or RSSBus service definition
|
From Excel pop-ups, or cells in worksheet
|
|
To have RSSBus return an IQY file,
use the @xls format parameter on any RSSBus call (this has
the same effect as selecting “Excel” under “show feed” in the RSSBus Admin
Console):
http://localhost:1110/FileList1.rsb?@xls
RSSBus will return a file called RSSBusfeed.iqy
that you can save or open.
When you click the URL and choose open, the browser will start Excel, which then opens the
IQY file and executes the commands inside.
They tell Excel to go back to the same script, but this time request the
output in HTML format using the @html parameter. The data is returned in an HTML table
that Excel can recognize, parse and display.
Call the URL again but this time save the IQY file. Double click on the IQY file, and Excel will
fetch the data as before. Open the IQY file with
Notepad and look at the data fetch commands inside. You will see the call-back to the same URL
with the HTML formatter.
Getting Excel to prompt for RSSBus input parameters:
Look at the service definition FileList1.rsb
below, it includes an rsb:info directive
that provides a default value for the path input
parameter to the fileListDir operation:
<rsb:info title="FileList1" description="Feed with default
path">
<input name="path" desc="Directory to list" default="." />
</rsb:info>
<rsb:call op="fileListDir" output="out">
<rsb:push title="[rss:title |
def('untitled item')]">
[out.*]
</rsb:push>
</rsb:call>
If we make the path parameter
required, like this (see FileList2.rsb):
<rsb:info title="FileList2" description="Feed with required
path">
<input name="path" desc="Directory to list" default="." required="true" />
</rsb:info>
...
RSSBus will add a directive to the IQY file to have the
browser prompt for the value for path just before
executing the data fetch. Try this URL:
http://localhost:1110/FileList2.rsb?@xls
If you select ‘open’ in response to the browser open-or-save
pop-up, Excel will start and prompt for the value for path. Type . (a single
period) and hit return. Excel will
complete the call to RSSBus and display the returned data.
Click URL again, but
this time save the IQY file, and open it with notepad. Note the directive that tells Excel to prompt
for the path parameter:
WEB
1
http://127.0.0.1:1110/FileList2.rsb@html
path=["path","Directory
to list"]
...
As an exercise, try adding support for the mask
parameter of the fileListDir operation, by adding a new line for mask
to the info directive of FileList2.rsb. When
Excel prompts for a value for a mask, try * or *.rsb.
In Part 3 we will use cells in the spreadsheet as an input form to the service.
To learn more about RSSBus, read the RSSBus Feed
Server Quick Start Guide. To learn more about IQY files, read XL97: How to Create Web Query
(.iqy) Files.