SpreadSheet can be initialized in 2 ways:
And can be used in 2 modes (regardless of the type of initialization):
Please note, before initializing you must adjust SpreadSheet Configuration.
To perform basic initialization of SpreadSheet, you should make the only action - include the related file on the page:
<script src="../codebase/spreadsheet.php"></script>
At this point, if you run the page, Spreadsheet will be initialized in the fullscreen mode.
Available parameters:
<script src="../codebase/spreadsheet.php?sheet=2&key=key2&parent=box"></script>
<div id="box" style="width: 800px; height: 400px; background-color:white;"></div>
The following instructions describe how to perform advanced initialization of Spreadsheet:
Step 1. Include the related files.
<script src="codebase/spreadsheet.php?load=js"></script>
<link rel="stylesheet" href="codebase/dhtmlx_core.css">
<link rel="stylesheet" href="codebase/dhtmlxspreadsheet.css">
<link rel="stylesheet" href="codebase/dhtmlxgrid_wp.css">
Step 2. Create a dhtmlxSpreadSheet instance.
dhx_sh = new dhtmlxSpreadSheet({
load: "../codebase/php/data.php",
save: "../codebase/php/data.php",
parent: "gridobj",
icons_path: "../codebase/imgs/icons/"
});
Available parameters are the same as in case of basic initialization except for the 'key' parameter. It's specified in the load() method.
Step 3. Load Spreadsheet.
dhx_sh.load(sheet, key);
where:
To activate the read-only mode, you should specify some key for a sheet in the database. Where to find this key?
During the configuration, Spreadsheet automatically creates several tables in the specified database, one of the tables is called 'sheet'. If you open this table, you'll find out that it contains 5 columns, one of which is the key column. So, to specify the key for a sheet, you should set some value in this column.
From now on, users will be able to modify data only if the key specified in the database and the key, specified in the key parameter during the initialization, match. In all other cases the read-only mode is activated (it will be activated even if you don't specify the key parameter at all).
Which initialization variant to prefer?
Surely the basic way is easier than the advanced one, but it has one imperfection which consists in the usage of the load and save parameters: you can't set compound URLs for them. For example, your load a file which is placed at http://someurl/data.php?test=1.
In the script it will look like this:
<script src="./codebase/spreadsheet.php?sheet=1&load=someurl/data.php?test=1"></script>
As a result, your browser will be confused by this text. How should it understand test? Is it the parameter of the load() function or an individual parameter passed to URL? Therefore, to prevent such a problem you must use the advanced way.
IE troubleshooting
In order to present the styles in Internet Explorer correctly, you must specify DOCTYPE of the document for your page.
<!DOCTYPE html>
Back to top