# Advanced &sheets;

## Series

When constructing a spreadsheet you often need to include a series of values, such as 10, 11, 12..., in a row or column. There are several ways you can do this in &sheets;.

For a simple short series such as 5, 6, 7, 8... the Drag and Copy method is the simplest. Enter the starting value into the starting cell and the next value of the series into an adjacent cell. Then select both cells and move the mouse pointer so that it is over the small square at the bottom right corner; the cursor will change to a diagonal double headed arrow. Then hold the left mouse button down while you drag the cells down or across as needed.

The step size is calculated as the difference between the two starting values that you have entered. For example if you enter `4` into cell A1 and `3.5` into A2 then select both cells and Drag and Copy them down, the step size will be the value in A2 minus the value in A1, -0.5 in this case so you will get the series 4, 3.5, 3, 2.5, 2...

The Drag and Copy method will even cope with series where the step value is not a constant value but is itself a series. So that if you start with 1, 3, 4, 6 Drag and Copy will extend it to 1, 3, 4, 6, 7, 9, 10, 12..., the step value in this example being the series 2, 1, 2, 1...

&sheets; also recognizes some special series such as the days of the week. Try entering `Friday` into a cell (note the capitalization) then Drag and Copy it down. To see what special series are available, and perhaps create your own, select Tools Custom Lists...

If you select a cell and choose Series... from the Insert menu you will see the Series dialog box. This is useful for creating series that are too long to be conveniently constructed using the Drag and Copy method, or for creating geometric series such as 1, 1.5, 2.25, 3.375... where the step value, 1.5 in this case, is used as a multiplier.

If the type of series that you want is too complicated for any of the previous methods, consider using a formula and Drag and Copying that. For example to create a series with the values 2, 4, 16, 256... enter `2` into A1, `=A1*A1` into A2, and Drag and Copy cell A2 down.

## Formulae

### Built in Functions

&sheets; has a huge range of built in mathematical and other functions that can be used in a formula cell. They can be seen and accessed by selecting a cell then choosing Function... from the Insert menu. This brings up the Function dialog box.

Select the function you want to use from the listbox at the left of the dialog box. The Help tab page will then display a description, the return type, Syntax, Parameters, and Examples for this function. In addition this page provides often links to Related Functions. Then press the button with the down arrow key symbol on it to paste it into the text edit box at the bottom of the dialog.

The Parameters tab page will then be displayed to let you enter the parameter(s) for the function you have just chosen. If you want to enter an actual value for a parameter, just type it into the appropriate text box in the Parameters page. To enter a cell reference rather than a value, left click on the appropriate text box in the Parameters page; then left click on the target cell in the spreadsheet.

Instead of using the Parameters page, cell references such as `B6` can be entered by typing them directly into the edit box at the bottom of the Function dialog. If a function has more than one parameter separate them with a semi-colon (;).

Pressing the OK button will insert the function into the current cell and close the Function dialog.

You can of course do without the Function dialog and simply type the complete expression into the main text entry box in the Cell Editor tool options. Function names are not case sensitive. Do not forget that all expressions must start with an = symbol.

### Logical Comparisons

Logical functions such as IF(), AND(), OR() take parameters which have the logical (boolean) values True or False. This type of value can be produced by other logical functions such as ISEVEN() or by the comparison of values in spreadsheet cells using the comparison expressions given in the following table.

Expression | Description | Example
== | Is equal to | `A2==B3` is True if the value in A2 is equal to the value in B3
!= | Is not equal to | `A2!=B3` is True if the value in A2 is not equal to the value in B3
<> | Is not equal to | Same as `A2!=B3`
< | Is less than | `A2<B3` is True if the value in A2 is less than the value in B3
<= | Is less than or equal to | `A2<=B3` is True if the value in A2 is less than or equal to the value in B3
> | Is greater than | `A2>B3` is True if the value in A2 is greater than the value in B3
>= | Is greater than or equal to | `A2>=B3` is True if the value A2 is greater than or equal to the value in B3

Thus if you enter `=IF(B3>B1;"BIGGER";"")` into a cell it will display BIGGER if the value in B3 is greater than that in B1, otherwise the cell will show nothing.

### Absolute Cell References

If a formula contains a cell reference that reference will normally be changed when the cell is copied to another part of the worksheet. To prevent this behavior put a $ symbol before the column letter, row number or both.

- If A1 contains the formula `=D5` then on copying the cell to B2 it will become `=E6` (the normal behavior).

- If A1 contains the formula `=$D5` then on copying the cell to B2 it will become `=D6` (column letter not changed).

- If A1 contains the formula `=D$5` then on copying the cell to B2 it will become `=E5` (row number not changed).

- If A1 contains the formula `=$D$5` then on copying the cell to B2 it will remain as `=D5` (neither the column letter nor the row number are changed).

When you are entering or editing a cell reference in a formula the shortcut key F4 can be used to step through these four possibilities.

Named cells can be used in a similar way to include a unchanging cell reference in a formula.

## Arithmetic using Special Paste

Sometimes you may want to add a single value to a number of cells, or subtract a value from them, or multiply or divide them all by a single value. The Special Paste... option lets you do this quickly and easily.

First, enter the modifier value into any spare cell on your spreadsheet and Copy it. Then select the area of cells you want to change, choose Special Paste... from the Edit or the context menu and select Addition, Subtraction, Multiplication or Division from the Operation section of the dialog box.

You can also apply different modifier values to different rows or columns of the target area by copying an area containing the wanted modifiers before selecting the target area and doing Special Paste... For example, if you enter `5` into cell A1, `10` into B1, select both cells and do a Copy then Special Paste... Addition into cells A10 to D15, 5 will be added to A10:A15 and C10:C15, and 10 to B10:B15 and D10:D15.

Note that a modifier value can be a formula as well as a simple numeric value. If it is a formula then &sheets; will adjust the cell references as for a normal Paste operation.

## Array Formulas

&sheets; allows you to use formulas whose result is a matrix or a range of values. Normally, only the first value is displayed in a cell. If you would like to display the entire matrix, simply use &Ctrl;&Alt;&Enter; when editing a formula, and it will be converted into an array formula, occupying neighboring cells as needed.

Cells that are a part of an array formula are locked for editing.

## Goal Seeking

&sheets; can be used to solve algebraic expressions such as x + x^2 = 4 or For what value of x does x + x squared equal 4 ?

For this example you could enter `=A2+A2*A2` into A1 then either try different values in A2 until the result in A1 is as close as you wish to 4 or, preferably, use &sheets;'s Goal Seek... feature which automatically adjusts the value in one cell to try to make the value in another cell as close as possible to a target value.

It is invoked by selecting Goal Seek... from the Data menu. This brings up a dialog box in which you should enter the reference of the target value cell (`A1` in this case) into the Set cell: box, the target value itself (`4`) into the To value: box and the reference of the cell that is to be changed (`A2`) into the By changing cell: box. Note that you need to have entered some initial value into the cell that is to be changed before starting Goal Seek.

Pressing the OK button will start the calculation. When it finishes and if it has found a solution press the OK button to accept the result or Cancel to keep the original value.

## Pivot Tables

&sheets; can be used to construct pivot tables using the data of the current table.

This feature can be invoked by selecting Pivot... from the Data menu. Below is an example of pivot table generation.

Supposing we have the following data.

Initial table

We want to create a pivot table of our choice and requirement. So we choose Data Pivot... .

The dialog box that will appear allows user to select the source of data. The data can be taken from the current worksheet or from an external source like a database or ODS file.

Choosing the data source

Here is the dialog box which allows the user to customize the pivot table. The column labels in the source data are converted to labels which serve as the working fields. The labels can be dragged and dropped into one of three areas (Rows, Columns or Values) to generate the pivot table. You can reset your choices using Reset DnD button.

Pivot table customization dialog

In our example, `Name` is dragged to Rows, `Category` to Columns, `Score` to Values. User defined functions like sum, average, max, min, count, &etc; can be selected from the Select Option list.

The Add Filter button can be used to open filter dialog box to filter the desired data. Using this box you can define multiple filters based on the column label and the relationship between them (And or Or). This would allow extreme freedom to customize the output.

Pivot table filtering dialog

Total Rows and Total Columns: checking these allow automatic totalling of corresponding rows and columns in the pivot table.

## Using more than one Worksheet

When you start a new, empty, document with &sheets; it will create a number of blank worksheets. The number of sheets it creates is determined by the selected template.

Insert Sheet will add another sheet to the document.

You can also switch between worksheets by using the &Ctrl;PgDown to move to the next sheet, &Ctrl;PgUp to move to the previous one.

Worksheets are given the default names of Sheet1, Sheet2... You can give a sheet a different name by right clicking on the tab and selecting Rename Sheet...

To remove a sheet from the document use the Remove Sheet option in the context menu that pops up when you right click on the tab for the sheet you want to remove.

Other entries in the Format Sheet submenu allow you to show or hide a sheet in much the same way as rows and columns can be hidden.

If you want a formula in one sheet to refer to a cell in another sheet, the cell reference must start with the sheet name followed by an exclamation mark (!). For example if you enter `=Sheet2!A2` into a cell in Sheet 1, that cell will take the value from A2 of Sheet2. Note that sheet names are case sensitive.

### Consolidating Data

You may have constructed a document containing several worksheets containing similar data but for, say, different months of the year, and wish to have summary sheet containing the consolidated (⪚, sum or average) values of the corresponding data items in the other sheets.

This task can be made slightly easier by using the Consolidate... item from the Data menu.

Selecting this option brings up the Consolidate dialog box.

For each of the source sheets, enter a reference to the desired data area in the Reference: box. Press Add to transfer it to the Entered references: box. The reference should include the name of the sheet containing the source data, such as `January!A1:A10`, and can be entered automatically by selecting the area in the appropriate sheet.

After entering the references for all of the source data sheets select the cell in the target sheet where you want the top left corner of the consolidated results to appear. Then choose the appropriate function from the Function: combo box and press the OK button.

If you click the Details >> in the dialog and check the Copy data box the values resulting from the consolidation will be placed into the target cells rather than the formulae to calculate them.

## Inserting a Chart

You can insert a chart into a sheet to give a graphical view of your data.

First enable Add Shape docker using the Settings Dockers menu item.

Then select the area of cells containing the data and choose Chart in the Add Shape. Drag the cursor across the sheet while holding the left mouse button down to define the area where you want the chart to appear, there is no need to be too accurate at this stage as the chart size can easily be changed at any time. When you release the mouse button a Chart Options dialog box will appear.

The data area is already prefilled with the selected cell range. Select the first row and column as labels, check Data set in rows and click the OK button. The Dialog will vanish and you will see the chart embedded into the worksheet.

Now select Chart Editing Tool from the Tools docker and edit the chart properties like chart type, labels and axis in the Chart editing.

Screenshot of embedded chart

To move, resize or even delete the embedded chart switch to the Basic shape manipulation tool and click anywhere within the chart area. It should now appear with a green border and with a small yellow square at each corner and in the middle of each edge.

If you move the cursor over any of the squares it should change to a double headed arrow. You can resize the chart by dragging one of these squares with the left mouse button pressed. To delete the chart right click on one of the squares and select Delete.

To move the chart move the cursor into the chart. The cursor should then change to a cross, press the left mouse button and you will be able to drag the chart to where you want it to be.

To restore the chart to its normal appearance simply click anywhere outside of the chart area.

To change the format of the chart itself left click twice within the chart area. The chart Chart editing should appear in the docker. You can then use these tools to change the chart.

## Inserting External Data

You can insert data from a text file or from the clipboard into a worksheet by first selecting the cell where you want the top left item of the inserted data to appear, then choosing From Text File... or From Clipboard... from the Insert External Data sub menu.

In both cases &sheets; will assume that the data is in CSV form and will open a dialog box allowing you to control how the data is extracted from the file or clipboard and placed into the worksheet cells.

If support for it has been included in your system, &sheets; can also insert data from a SQL database into a worksheet. This is done by using the Insert External Data From Database... option.

## Link Cells

A spreadsheet cell can be linked to an action so that left clicking on the cell will, for example, open your browser. To make a cell act in this way select it and choose Insert Link... . This will bring up the Insert Link dialog box, which lets you choose between four types of link:

- An Internet link cell will try to open your default browser at the &URL; entered in the Internet address: text box of the Insert Link dialog when it is clicked. This could be, for example, `http://www.calligra.org`.

- Clicking on a cell containing a Mail link will open your email composer using the address entered in the Email: text box as the To: address. For example `anon@example.com`.

- A File link cell holds the path to a file or folder, as entered into the File location: text box, and will try to open that file or folder with a suitable application when clicked on.

- The Cell type of link cell holds a &sheets; cell reference, entered in the Cell or Named Area text box. Left clicking on this type of link cell causes &sheets;'s focus to move to the target cell.

All four types of link cell need some suitable text to be entered into the Text to display field of the Insert Link dialog. This is the text that appears in the cell.

## Validity Checking

&sheets; can automatically check the validity of entered data against a number of criteria, and pop up a message box if the data is invalid.

To enable this feature, select the cell(s) to be monitored and choose Data Validity... . This will bring up &sheets;'s Validity dialog box which has three tabbed pages.

In the Criteria page select what type of data is to be considered valid from the Allow: combo box list then define the valid range of values by choosing one of the options in the Data: combo box and entering suitable value(s) into one or both of the edit box(es).

When you have done this change to the Error Alert tab. Here you can choose the type of message box (Stop, Warning or Information) that will appear when an invalid value is entered, and define the message box title and message text.

Note that this feature only checks data that you enter into the cell, for a way of checking the results from formulae cells see the Conditional Cell Attributes section of this Handbook.

## Protection

### Document Protection

Protecting the document means that without the password a user cannot add or delete sheets. Document protection does not protect cells.

Select Tools Protect Document... A dialog appears asking you for a password. The Password: strength meter indicates if your password is secure enough. The longer the indicator is, the more secure your password.

The Protect Document dialog

That password will then be required to unprotect the document.

The Unprotect Document dialog

When a document is protected, you may not:

- Rename a sheet

- Insert a sheet

- Remove a sheet

- Hide a sheet

- Show a sheet

- See the sheet properties

- Merge or dissociate cells

### Sheet protection

Protecting a sheet means protecting the contents of all protected cells and objects on a sheet. Individual cells or a selection of cells can be unprotected within a protected sheet, see next section.

To protect a sheet, select Tools Protect Sheet.... A dialog appears asking you for a password. The Password strength meter indicates if your password is secure enough. The longer the indicator is, the more secure will be your password.

That password will then be required to unprotect the sheet.

When a sheet is protected, you may not:

- Insert any object or chart

- Format any cell

- Insert a row or a column

- Edit and change cell content

- Change any content in the sheet

Protecting a sheet is especially useful for preventing accidental erasure of formulae.

### Cell or selected cells protection

Cell protection is active for all cells by default and is effective when you enable sheet protection. So if you keep the default and if you protect the sheet, all cells will be protected.

If you want only certain cells to be protected, this default protection must be turned off for all other cells. For example you might want most cells to accept user input so you will uncheck Protected for those and choose to keep protected cells that should stay unchanged (such as titles). So you need 3 steps in order to protect only some cells: unprotect all the cells, select the cells to protect and protect them and then protect the whole sheet.

To unprotect all the cells:

- Select the entire spreadsheet with the mouse.

- In the menubar, select Format Cell Format....

- In the dialog that appears, go to the Cell Protection tab.

- Check Hide all and uncheck Protected to remove the protection on all cells. The cells are now all unprotected.

To protect a range of selected cells or a selection of non-contiguous cells:

- Highlight the range of cells that are to be protected or use the &Ctrl; key to select non-contiguous cells.

- When all of the desired cells are selected, go to the Format Cell Format... menu.

- In the dialog that appears, go to the Cell Protection tab.

- Click on the box next to Protected then click on OK.

Once the cells are marked for protection, the protection option must be enabled at the sheet level, that means you must protect the entire sheet for the cell to be effectively protected:

- Select Tools Protect Sheet....

- In the dialog that appears, provide a safe password, then confirm it by typing it again. Click on OK.

- Protected cells in a protected sheet cannot be edited without unprotecting the whole sheet, and any sheet changes are disabled. For example, no one can insert rows or columns, change column width, or create embedded charts.

### Hide cell formula

You might want to hide your formulae so other people cannot see them. By default, every cell is protected and not hidden. But it is important to remember that these attributes have no effect unless the sheet itself is protected.

A default cell with a formula

To hide cell formulae, select the appropriate cell or range of cells or non-contiguous cells with &Ctrl; and then choose the Format Cell Format... menu. In the Cell format dialog, click the Cell Protection tab and select Hide formula. After you protect the sheet, the results of the formulae will be visible, but the formulae will not.

You have now to protect the sheet: choose Tools Protect Sheet... to display the Protect Sheet dialog box. Enter a safe password twice to prevent others from unprotecting the sheet.

When Hide formula is enabled and Protected is disabled, the formula is hidden after protecting the sheet but the cell content can be changed.

Hide formula is enabled but the cell is not protected and the sheet is protected

When Hide formula and Protected are enabled, the formula is hidden after protecting the sheet and the cell content cannot be changed.

Hide formula and Protected are enabled in Cell Protection and the sheet is protected

Keep in mind that it is very easy to break the password for a protected sheet so if you are looking for real security, this is not the best solution.

### Hide all in the cell

You can hide both the formula and the content of the cell by choosing Hide all in the Cell Protection tab in the Format Cell Format... menu. In the screenshot below, the cell itself is not protected (Protected is unchecked) thus the cell content can be changed.

Hide all only is enabled (no cell protection) and the sheet is protected

Here the cell itself is protected so it cannot be overwritten.

Hide all and Protected are enabled in Cell Protection and the sheet is protected

## Other Features

### Named Cells and Areas

You can give a name such as `foo` to a cell or to any area of a sheet by selecting the cell or area then selecting Area Name... from the right mouse button menu. This will bring up the Area Name dialog box where you can enter any name you wish.

You can also name a cell or area by selecting it then typing the name into the small text box at the left end of the Formula toolbar, overwriting the cell reference that normally appears here.

If you enter a name that has already been used into this text box &sheets;'s selection will change to show the named cell(s).

The Data Named Areas... option will give you a list of existing names and let you change &sheets;'s focus to any of them or let you remove a name.

Named cells are particularly useful in formulae as an alternative to absolute cell references as the names can be used in place of normal cell references and do not change when the cell containing the formula is copied. When a name is used in this way it should be enclosed in single quotation marks.

For example, if cell A1 has been given the name `fred` then you can enter a formula such as `='fred' + 2` into another cell which would always give the result of adding 2 to the value in A1 no matter where the formula cell was copied to.

Note that cell and area names are treated as being in lowercase.

### Cell Comments

A cell can contain a text comment that can be viewed when working on the spreadsheet but which is not printed and not normally seen.

To add a comment select the cell and choose Comment... from the right mouse button menu or from the Insert menu and type your comment into the resulting Cell Comment dialog box.

To see the comment hover the mouse pointer over the cell. The comment will appear as if it were a Tooltip.

If you check the Show comment indicator box of the Sheet Properties dialog, those cells containing comments will be highlighted by a small red triangle in the top right corner.

To open this dialog, click with the right mouse button onto the sheet tab at the bottom of the main window and select Sheet Properties from the popup menu. Or select it from the Format Sheet menu.

To remove a comment from a cell, select Remove Comment from the right mouse button menu or choose Edit Clear Comment.