Pamela
Robert

    pamroberts@blueyonder.co.uk

# &sheets; Basics

Like the rest of &kde;, &sheets; is highly configurable, which can cause problems for readers trying to compare the text in a document such as this with what they see on the version of &sheets; running on their desktop. To cut down on some of the possibilities for confusion, it is suggested that when you first start to use &sheets; you set the default options in all pages of the &sheets; configuration dialog (obtained by selecting Settings Configure Sheets...).

## Spreadsheets for Beginners

This section attempts to explain by example what a spreadsheet program such as &sheets; actually does, and why it is such a useful tool in any situation where you have to deal with numbers. If you have already used a spreadsheet program you may wish to skip to the next section.

The first thing to do is to start up &sheets;. You can do this by left clicking on a &sheets; icon if there is one on your desktop or panel, or you can select Office&sheets; from the application launcher.

&sheets; at first run When it has started you will be given the choice of opening a recent document, creating a new document from a template (with templates categories) or opening an existing document . Select the General category on the left and choose the Blank Worksheet template. Then click the Use This Template button.

Looking at &sheets; once it has started up, you will see a sheet of empty rectangular cells arranged in numbered rows and lettered columns. This is where you enter data or formula, text or charts. Screenshot starting1

Now, enter the text and values shown in the first 5 rows of the above screenshot into the same cells of your spreadsheet. Ignore what is in row 7 for the moment. To enter anything into a cell first select the cell by left clicking inside it, then type whatever you want, then press &Enter; or use the arrow keys to move the selection point to another cell.

What we have entered so far could be a simple budget for the next two months, listing how much we think we will be spending for Food, Shelter, Clothing and any Other expenditure. Now select cell B7 (column B, row 7), type in `=B2+B3+B4+B5` and press &Enter;. Because it begins with a = symbol &sheets; sees this as a formula, something it has to calculate, in this case by adding together the values in the 4 cells B2 to B5, and what is shown in the cell B7 is the result of that calculation.

You could enter a similar formula into cell C7, except that in this case it would have to be `=C2+C3+C4+C5`, but there is an easier way which is to Copy cell B7 and Paste it into C7. &sheets; will automatically adjust the cell references from B.. to C.. when the Paste is done.

At this point you may think that &sheets; is doing no more than you could manage with pencil, paper and a calculator, and you could be right, but remember that this is a very small example of a spreadsheet, doing simple calculations on only a few numbers. For any reasonably amount of values or data using a spreadsheet to do the calculations is much quicker and more accurate than doing them manually.

Also, a spreadsheet lets you play the What if? game. Because each formula is automatically recalculated whenever any of the values it refers to are changed, you can quickly see what happens if you alter any of them. Using our example you can see the effect of reducing the amount spent on food in December by just entering a new value into cell C2. If you had a spreadsheet that modelled the greenhouse effect accurately you could perhaps see the effect of a 50 percent reduction in the amount of methane released into the atmosphere.

## Selecting Cells

You can select a single cell or a rectangular area of cells in the spreadsheet. The selected cell(s) are displayed with a thick black border.

### You can select a single cell in one of the following ways

- left click on it

- enter the cell reference (for example `B5`) into the cell reference box at the left end of the Cell Editor tool options and press &Enter;

- use the Go Goto Cell... menu option

You can also steer your way around with the arrow keys. Pressing the &Enter; key will move the current selection one position up, down, left or right depending on the setting in the Interface page of &sheets;'s configuration dialog box.

If you hold the &Shift; key down while using the arrow keys the selection will move to the start or end of the block of occupied cells.

To select an area of contiguous cells drag the mouse cursor across the desired area with the left button held down, or enter the references of the top left and bottom right cells separated by a colon into the Cell Editor cell reference box (for example `B7:C14`) and press &Enter;, or enter these cell references in a similar format into the dialog box brought up by Go Goto Cell....

You can also select an area of cells by selecting the cell in one corner of the wanted area then holding the &Shift; key down while using the left mouse button to select the cell in the opposite corner.

To select non-contiguous cells, click on the first cell you want to select then hold the &Ctrl; key and select the other cells.

To select a complete row or column of cells left click on the row number at the left of the worksheet or on the column letters at the top. To select adjacent rows or columns drag the mouse pointer over the appropriate row numbers or column letters with the left button held down.

To select non-contiguous rows or columns of cells, click on the first row number or column letter then hold the &Ctrl; key and select the other rows or columns of cells.

## Entering Data

Entering data into a cell can be as simple as selecting the cell, typing your data, then pressing &Enter; or moving the selection to another cell with one of the arrow keys. Depending on how you enter the data, &sheets; will interpret it as a number, date, time or text:

- Numbers are entered in the obvious way; `123`, `-123`, `456.7` or in scientific notation `-1.2E-5`.

- Dates should be entered in your System format, as defined in the &systemsettings; in Locale Country/Region & Language Date & Time tab. If, for example, you are using the DD/MM/YYYY form you should enter `30/03/2012` for 30th March 2012. Leading zeroes can be omitted from the day and month fields and only the last one or two digits of the year need to be entered if the date is in the current century, for example `9/1/9` for 9th January 2009.

- Times should also be entered using the System format. For example if you are using a 12 hour clock then enter times in HH:MIN am|pm or HH:MIN:SS am|pm format such as `9:42 am` or `10:30:52 pm`.

- &sheets; defines any input data as text if it cannot recognize the data as being a number, date or time.

By default, &sheets; right justifies numbers, dates and times within a cell and left justifies anything else. This can be a useful guide to whether you have entered a date or time in the correct format. But remember that how items are displayed can be changed by altering the cell format.

The main text entry box in the Cell Editor tool options provides an easy way of editing the contents of a selected cell. Press &Enter; or left click on the green tick mark when you are happy with what you have entered, or click on the red cross to cancel your edits.

### Generic Cell Format

&sheets; uses the Generic cell format as default. As long as this format is used, &sheets; autodetects the actual data type depending on the current cell data. For example if you enter some text into a cell and later enter a number into the same cell, &sheets; automatically interprets the new data as a number. If you want to define the type of data yourself, you can explicitly set it in the cell format. You can change the format back to Generic at any time.

## Copy, Cut and Paste

At first glance, &sheets;'s Cut, Copy and Paste appear to be similar to these functions in other &kde; applications. Having selected a cell or cells, you can choose Copy or Cut from the Edit menu or from the drop down menu you get by holding the right mouse button down on a selected cell. You can also use the shortcuts &Ctrl;C or &Ctrl;X , then move the selection to the target cell and choose Paste or press &Ctrl;V. However there are some subtleties associated with these functions in &sheets; and these are discussed below.

If a cell contains a formula then the formula itself is copied rather than the displayed result, and if the formula contains a reference to another cell, then that reference is changed by the Cut or Copy and Paste operation to point to the cell that is in the same relative position as in the original cell. For example if cell A2 contains the formula `=B3` and is copied to C4, cell C4 will contain `=D5` .

This may seem to be a rather strange way of doing a copy, but 99 percent of the time it is exactly what is wanted (if it is not then see the section about absolute cell references). For example in the simple shopping list shown below, cell D2 should contain `=B2 * C2`, D3 should be `=B3 * C3`, D4 should be `=B4 * C4` and so on. Instead of having to enter a different formula in each cell, you can just enter the first formula into D2 and then copy it into the cells below, letting &sheets; adjust the cell references to suit.

Screenshot copy1

### Copying and Pasting Cell Areas

In the above example D2 can be copied into all three cells D3 to D5 at once by just copying D2 then selecting the complete cell area D3:D5 before doing the paste.

A rectangular area of cells can be cut or copied in one operation by selecting the area before doing the cut or copy. Then select the top left corner cell of the area you want to paste into before doing the paste.

If you cut or copy a rectangular area of cells, say B2:C3, and paste it into a larger area such as A10:D13 the original pattern of cells will be repeated to fill the target area.

&sheets; also provides a Drag and Copy method for copying cells down into other cells immediately below or to the right of the original cell(s). To use this method select the cell(s) to be copied then position the mouse pointer over the small black square at the bottom right corner of the selected cell(s) so the cursor changes to a double headed arrow. Then hold the left mouse button down while you drag the selected cell(s) as far as you wish. Note that cell references in formulae are incremented according to the relative position change. Absolute references are not changed.

### Other Paste Modes

A cell may contain text, a value, or a formula, and may also contain special font, border or background formatting information. &sheets; has special versions of Paste that let you handle these items in different ways.

Edit Special Paste...brings up the Special Paste dialog box. By selecting the appropriate item from the left part of this dialog you can choose to paste Everything, just Text, the cell Format, any Comment in the cell(s) or Everything without border. The items in the right part of this dialog box allow you to do simple arithmetic on an area of cells.

Paste with Insertion... inserts the copied cell(s) into the sheet by moving the cells that would otherwise be overwritten a suitable number of rows of columns down or to the right. It can also be used to insert complete copied row(s) or column(s) into the worksheet.

## Insert and Delete

Use the Del key or Edit Clear Contents to remove the text, value or formula from selected cell(s), row(s) or column(s) without affecting anything else.

To delete everything in the selected cell(s), row(s) or column(s), including comments and special formatting, choose the All option from the Edit Clear menu or from the pop up menu you get when you right click on a selection.

To remove selected row(s) or column(s) completely, use the Delete Rows or Delete Columns options from the right mouse button pop up menu.

If you select a cell or cells and choose Remove Cells... from the right mouse button pop up menu, you can then choose whether other cells in the worksheet will be moved up or to the left to fill in the space left by the cell(s) you have chosen to remove.

If you want to insert new, blank, row(s) or column(s) into the sheet, select row(s) or column(s) where you wish the new row(s) or column(s) to be placed and choose the Insert Rows, Insert Columns option from the right mouse button pop up menu.

You can insert new cells into the worksheet by selecting the area where you want them to appear then choosing the Insert Cells... option from the right mouse button pop up menu. You will then be asked whether the existing cell(s) in the selected area should be moved down or to the right to make room for the new ones.

## Simple Sums

If the first character in a cell is an equals sign (=) &sheets; will take the cell contents to be a formula which is to be calculated. The result of the calculation will be displayed in the cell rather than the formula itself. For example, enter `=2+3` into a cell and it should display 5.

More usefully, a formula can contain references to other cells, so that `=B4+A3` will calculate the sum of the values in cells B4 and A3, and this calculation will be updated whenever cells B4 or A3 are changed.

As well as addition, a formula can make use of the - symbol for subtraction, * for multiplication, and / to perform division. The round bracket symbols ( and ) can also be used as in normal algebra, so you could enter more complex formulae such as `=((B10 + C3) *5 - F11) / 2` .

Cells containing a formula will be marked with a small blue triangle at the bottom left corner if the Show formula indicator check box in the Format Sheet Sheet Properties dialog is checked.

&sheets; also includes a large number of built-in functions for applications such as statistical, trigonometrical and financial calculations. Their use will be examined in more depth in a later section of this manual, but if you are interested at this stage choose Function... from the Insert menu and take a look through the Function dialog box that will be displayed.

For the time being, however, the `SUM` function may be of interest as it calculates the sum of all values in a specified area of cells. For example `=SUM(B4:C10)` calculates the sum of all values in the cell area B4 to C10.

If &sheets; displays #VALUE! when you have entered your formula this usually means that it cannot understand what you have entered, but if the row of symbols ends with a small red arrow this just means that the cell is not wide enough to display the complete result, in which case you should either make the cell(s) wider or change their format so that the result does fit properly.

### Recalculation

If the Automatic recalculation box in the Format Sheet Sheet Properties dialog box is checked, &sheets; will recalculate the values of cells whenever anything that affects them is changed in the sheet.

When Automatic recalculation is not checked for the current sheet, you can instruct &sheets; to perform a recalculation at any time by using the Recalculate Sheet or Recalculate Document option in the Tools menu or their shortcuts &Shift;F9 or F9.

## Sorting Data

In the simple example shown below, the data consist of the names and countries of a number of mountains together with their height above sea level. &sheets; can sort data such as this in different ways.

Screenshot of sorted data

We may want the data sorted so that the names are in alphabetical order. To do this select the area containing the data (A2:C7 in this case) and choose Sort... from the Data menu. This opens the Sort dialog box.

Sorting is done alphanumerically, and the default is case sensitive, numbers coming before uppercase letters which come before lowercase letters, so that cells containing the entries `Cat`, `bar`, `77` and `Bat` would be sorted into the following order: 77 Bat Cat bar.

In the Direction area of this dialog box select to sort in rows or columns. If you check the First row contains column headers or First column contains row headers box data in the first row or column will not be included in the sort operation.

The rows or columns are sorted in the specified order, which can be changed using the Move Up and Move Down buttons. Using the example in the above screenshot, choosing column B as the first key and column C as the second would sort the data by country and, for each country, by height.

Uncheck the option Case Sensitive to get a sort not depending on capitalization and switch the sort order between Ascending and Descending by clicking on the cells in the column Sort Order.

The Details >> extension of the dialog allows you to sort using the order of items in a custom list such as January, February... instead of alphanumerically. The cell format is moved with the cell content, if you select Copy cell formatting (Borders, Colors, Text Style).

## The Status bar Summary Calculator

The left hand end of the Status bar by default shows a summary of the values in the selected cell(s). According to the setting of the Function shown in status bar combo box in the Interface page of &sheets;'s configuration dialog the summary can be:

None

  No summary calculation is performed.

Average

  The value displayed is the average of the values in the selected cells.

Count

  The value displayed is the number of cells containing numeric values.

CountA

  The value displayed is the number of non empty cells.

Max

  The value displayed is the maximum of the values in the selected cells.

Min

  The value displayed is the minimum of the values in the selected cells.

Sum

  The value displayed is the sum of the values in the selected cells.

The method of calculation can also be changed by right clicking on the summary calculation result area of the Status bar and choosing an item from the pop up menu.

## Saving your Work

&sheets; saves the complete document, which may include more than one worksheet, as a single document file.

If you have created a new document, or want to save an existing one under a different name, use File Save As.... This will bring up &kde;'s common Save Document As dialog box. Choose the folder where you want to save the document and enter a suitable file name into the Name text box. &sheets; documents are normally automatically saved with a `.ods` extension, you do not need to add this to the filename but do make sure that the Filter selection is set to OpenDocument SpreadSheet.

To save your document without changing its name, just use File Save.

You can also save a &sheets; document in a foreign format selecting the format from the Filter: combo box.

When you save a modified version of an existing document &sheets; will keep the previous version as a backup file, adding a `~` to the end of the filename.

&sheets; can provide some protection against losing your work because of a computer crash or because you have closed &sheets; without saving the current document. It does this by automatically saving the latest version of the document you are working on every few minutes using a modified file name. The autosaved version is normally removed when you next save your document, so that it will only exist if it is more up to date than the version that was saved manually. When you open a document &sheets; checks to see if an autosaved version exists, and if it finds one it will offer to open that instead.

Autosaved documents are saved with a file name of the form `.yourfilename.autosave` (note the leading period), so that `spread1.ods` would be autosaved as `.spread1.ods.autosave`. The autosave feature is user configurable in the settings dialog.

### Templates

If you are going to be creating a lot of similar documents you can save yourself time and trouble by first creating a template and then using that as the basis for the individual documents.

To do this first create a document containing the common elements, then save it as a template by choosing File Create Template From Document. Doing this opens the Create Template dialog box. Enter a name for your new template into the Name: text box and press OK. The next time you start a new document by choosing File New or when you next start &sheets; the startup dialog window will give you the option of creating the new document from your template.

The Create Template dialog box also lets you choose a different picture to be displayed above the template name in the startup dialog window, and lets you save your templates under different group names, which will appear as different pages in the dialog.

Templates are stored as `.kst` files under `~/.kde/share/apps/tables/templates/`.

## Printing a Spreadsheet

Printing a spreadsheet is basically done by selecting File Print... which brings up &kde;'s common Print dialog box where you can choose, among other options, the printer to be used, the number of copies and whether all or only selected pages are to be printed.

By default &sheets; will print all items in the current worksheet, but you can restrict this by first selecting the area that you want to be printed then choosing Define Print Range from the Format Print Range sub menu.

&sheets; will print as many pages as are necessary to include all items in the current worksheet. You can quickly see how a worksheet will be split into separate pages for printing by checking the View Page Borders box. The boundaries of each printed page will then be marked by colored lines in the worksheet.

For a more detailed view of what is to be sent to the printer, including anything you have asked to be included in the page headers and footers (see below), choose File Print Preview....

To improve the appearance of the printed output , you can change the fonts, colors, borders and sizes of the cells in the worksheet, see the Spreadsheet Formatting section for more details about how to do this.

You can also use the Page Layout dialog box, invoked by selecting Format Page Layout..., to change the orientation of the printed pages, the paper size (this should be suitable for your printer) and the size of the page borders.

The Sheet provides more options. The Print settings section lets you select whether or not to print the grid, comment indicators and formula indicators, objects and charts. The Repetitions on each page section allows you to repeat selected column(s) or row(s) on each printed page. In the section Scaling you can set a scalefactor or the page limits for the print.