Skip to content

Query String API

Marcin Warpechowski edited this page Jun 8, 2021 · 9 revisions

To instruct frame assets entry point to boot into a specific state directly upon loading, you can use the Query String API. The amount of commands is not as rich as in the JavaScript API, however, it has a benefit - you can get Spreadsheet Viewer to render a specific sheet of a workbook without relying on asynchronous communication. We use this API in testing.


Query String API Reference

All parameters in Query String API are optional because the SV frame can be driven without them using the JavaScript API.

There are only a handful supported URL query string parameters, all of which are listed below:

Parameter Description
workbookUrl optionally, a URL to a workbook file. It must be an HTTP or HTTPS URL. Note: Data URL nor ArrayBuffer are not supported in the Query String API, however, they are supported in JavaScript API and Web Messaging API.
licenseKey optionally, a string representing Spreadsheet Viewer license key. Default value: empty string (meaning: unlicensed)
sheet optionally, a number, starting from 0, representing the index of the sheet within the document that will be open after the file loads. Default value: 0
themeStylesheet optionally, a string representing the name of the built-in theme (color scheme) which can be either light or dark. Default value: dark
fileName optionally, a string representing a file name of the current workbook. If the file name is not provided and workbookUrl is an HTTP(S) URL, the app considers the last segment of the URL as the file name (after the last /). Otherwise, if the file name cannot be determined, the app will show "Unnamed file" as the file name.
svId optionally, a string to be used as the unique identifier of the Spreadsheet Viewer instance. If unset, a random string will be created automatically before sending the first [[callback message
flags optionally and recommend to use it carefully. Flags enable experimental features, each flag should be separated by coma ,. Current available flags: charts, fullPage, moreformats. Extensive description is below.

Example URL: http://localhost:8080/spreadsheet-viewer/sv/index.html?licenseKey=demo&workbookUrl=/cypress/fixtures/tab-names.xlsx&sheet=1&themeStylesheet=dark&fileName=new-file-name.xlsx

Example URL with feature flags: http://localhost:8080/spreadsheet-viewer/sv/index.html?licenseKey=demo&workbookUrl=/cypress/fixtures/tab-names.xlsx&sheet=1&themeStylesheet=dark&fileName=new-file-name.xlsx&flags=charts

Feature flags

Feature flags (called also experimental flags) enable experimental features which out of the box were turned off. Please to use it carefully and with fully knowledge what it's enabled.

As default all flags are turned off.

How to enable?

  • To enable one please use Query String API parameter ?flags=FLAG_NAME.
  • In the case of using more than one flags it's require to separate it by coma char (,), for instance ?flags=FLAG_NAME,FLAG_NAME_2,FLAG_NAME_3.
  • Any other way to define array param in query string is not acceptable as design (f/i. ?flags[]=FLAG_NAME).

Supported feature flags:

Flag Name Description
charts Enable parsing and displaying charts. Current version of chart feature is far from ideal and marked as experimental.
fullPage Enables full page mode - only the grid will be displayed, without any UI around it (like the tab bar).
moreformats Enables experimental support for more workbook formats, other than xlsx and xltx. The following additional filename extensions will be enabled for parsing: .xls, .xla, .xlt, .xlsm, .xltm, .xlam, .xlsb, .ods, .numbers.