LibreOffice 7.0 Calc Guide
LibreOffice 7.0 Calc Guide
LibreOffice 7.0 Calc Guide
This document is Copyright © 2020 by the LibreOffice Documentation Team. Contributors are
listed below. You may distribute it and/or modify it under the terms of either the GNU General
Public License (http://www.gnu.org/licenses/gpl.html), version 3 or later, or the Creative
Commons Attribution License (http://creativecommons.org/licenses/by/4.0/), version 4.0 or later.
All trademarks within this guide belong to their legitimate owners.
Contributors
This book is adapted and updated from the LibreOffice 6.4 Calc Guide.
To this edition
Steve Fanning Gordon Bates Kees Kriek
Annie Nguyen Felipe Viggiano Samantha Hamilton
Olivier Hallot Jean Hollis Weber
To previous editions
John A Smith Jean Hollis Weber Martin J Fox
Andrew Pitonyak Simon Brydon Gabriel Godoy
Barbara Duprey Gabriel Godoy Peter Schofield
John A Smith Christian Chenal Laurent Balland-Poirier
Philippe Clément Pierre-Yves Samyn Shelagh Manton
Peter Kupfer Andy Brown Stephen Buck
Iain Roberts Hazel Russman Barbara M. Tobias
Jared Kobos Martin Saffron Dave Barton
Olivier Hallot Cathy Crumbley Kees Kriek
Claire Wood Steve Fanning Zachary Parliman
Gordon Bates Leo Moons Randolph Gamo
Drew Jensen
Feedback
Please direct any comments or suggestions about this document to the Documentation Team’s
mailing list: [email protected].
Note
Everything you send to a mailing list, including your email address and any other
personal information that is written in the message, is publicly archived and cannot
be deleted.
Preface
Who is this book for?
This book is for beginner to advanced users of Calc, the spreadsheet component of LibreOffice.
You may be new to spreadsheet software, or you may be familiar with another program. If you
have never used LibreOffice before, or you want an introduction to all of its components, you
might like to read the Getting Started Guide first. If you have never used spreadsheets before,
you might also like to read a book or find some tutorials about the use of spreadsheets.
Help system
LibreOffice comes with an extensive Help system. This is the first line of support for using
LibreOffice. Windows and Linux users can choose to download and install the offline Help for use
when not connected to the Internet; the offline Help is installed with the program on macOS.
To display the Help system, press F1 or select LibreOffice Help from the Help menu (Figure 1).
If you do not have the offline help installed on your computer and you are connected to the
Internet, your default browser will open the online Help pages on the LibreOffice website.
The Help menu includes links to other LibreOffice information and support facilities.
Note
The following options indicated by a ‡ symbol are only accessible if your computer is
connected to the Internet.
• What’s This? – For quick tips when a toolbar is visible, place the mouse pointer over any
of the icons to see a small box (“tooltip”) with a brief explanation of the icon’s function.
For a more detailed explanation, select Help > What’s This? and hold the pointer over
the icon. In addition, you can choose whether to activate extended tips using Tools >
Options > LibreOffice > General > Extended tips.
Note
The What’s This? facility and extended tips are being improved but in LibreOffice 7.0
this work is incomplete and so they are not fully functional.
• User Guides‡ – Opens your default browser at the English Documentation page of the
LibreOffice website https://documentation.libreoffice.org/en/english-documentation/.
There you will find copies of User Guides and other useful information.
• Show Tip-of-the-Day – Opens a dialog showing a useful bit of information to help
expand your knowledge of LibreOffice.
• Get Help Online‡ – Opens your default browser at the Ask LibreOffice forum of questions
and answers from the LibreOffice community https://ask.libreoffice.org/en/questions/.
• Send Feedback‡ – Opens your default browser at the Feedback page of the LibreOffice
website https://www.libreoffice.org/get-help/feedback/. From there you can report bugs,
suggest new features, and communicate with others in the LibreOffice community.
• Restart in Safe Mode – Opens a dialog where you will have the option to restart
LibreOffice and reset the software to its default settings.
Preface | 9
• Get Involved‡ – Opens your default browser at the Get Involved page of the LibreOffice
website https://www.libreoffice.org/community/get-involved/. There you can find out how
you can help us make LibreOffice even better!
• Donate to LibreOffice‡ – Opens your default browser at the Donation page of the
LibreOffice website https://donate.libreoffice.org/. There you can choose to make a
donation to support LibreOffice.
• License Information – Opens a dialog outlining the licenses under which LibreOffice is
made available.
• Check for Updates‡ – Opens a dialog and checks the LibreOffice website for updates to
your version of the software.
• About LibreOffice – Opens a dialog, which displays information about the version of
LibreOffice and the operating system you are using. This information will often be
requested if you ask the community for help or assistance with the software. A button is
provided to enable you to copy this information to the clipboard so that you can
subsequently paste it into a forum post, an email, or a bug report.
Icons
The LibreOffice community has created icons for several icon sets: Colibre , Breeze, Breeze
Dark, Elementary, Karasa Jaga, Sifr, Sifr Dark, and Sukapura. Each user can select a preferred
set. The icons in this guide have been taken from a variety of LibreOffice installations that use
different sets of icons. The icons for some of the many tools available in LibreOffice may then
differ from the ones used in this guide.
To change the icon set used, go to Tools > Options > LibreOffice > View. Choose from the
drop-down lists under Icon style and Icon size.
Note
The Galaxy, Oxygen, and Tango icon sets are no longer included as part of the
standard installation package. They can be added back by downloading and
installing the following extensions:
https://extensions.libreoffice.org/extensions/galaxy-icon-theme
https://extensions.libreoffice.org/extensions/oxygen-icon-theme
https://extensions.libreoffice.org/en/extensions/show/tango-icon-theme-for-libreoffice
Some of the previously included gallery backgrounds are now only available as an
extension from:
https://extensions.libreoffice.org/extensions/legacy-gallery-backgrounds
Preface | 11
What are all these things called?
The terms used in LibreOffice for most parts of the user interface (the parts of the program you
see and use, in contrast to the behind-the-scenes code that actually makes it work) are the same
as for most other programs.
A dialog is a special type of window. Its purpose is to inform you of something, or request input
from you, or both. It provides controls to use to specify how to carry out an action. The technical
names for common controls are shown in Figure 2. In most cases the technical terms are not
used in this book, but it is useful to know them because the Help and other sources of
information often use them.
In most cases, you can interact only with the dialog (not the document itself) as long as the dialog
remains open. When you close the dialog after use (usually, clicking OK or another button saves
your changes and closes the dialog), then you can again work with your document.
Some dialogs can be left open as you work, so you can switch back and forth between the dialog
and your document. An example of this type is the Find and Replace dialog.
Note
If you want to use LibreOffice features that require Java it is important that the
correct 32 bit or 64 bit edition matches the installed version of LibreOffice.
Preface | 13
What’s new in LibreOffice Calc 7.0?
The LibreOffice 7.0 Release Notes are here:
https://wiki.documentfoundation.org/ReleaseNotes/7.0
A link to this page is also provided on the About LibreOffice dialog, accessed by clicking Help >
About LibreOffice.
Chapter 1
Introduction
Using spreadsheets in LibreOffice
What is Calc?
Calc is the spreadsheet component of LibreOffice. You can enter data (usually numerical) in a
spreadsheet and then manipulate this data to produce certain results.
Alternatively, you can enter data and then use Calc in a ‘What if...’ manner by changing some of
the data and observing the results without having to retype the entire spreadsheet or sheet.
Other features provided by Calc include:
• Functions, which can be used to create formulas to perform complex calculations on
data.
• Database functions to arrange, store, and filter data.
• Data statistics tools, to perform complex data analysis.
• Dynamic charts, including a wide range of 2D and 3D charts.
• Macros for recording and executing repetitive tasks; scripting languages supported
include LibreOffice Basic, Python, BeanShell, and JavaScript.
• Ability to open, edit, and save Microsoft Excel spreadsheets.
• Import and export of spreadsheets in multiple formats, including HTML, CSV, PDF, and
Data Interchange Format.
Note
If you want to use macros written in Microsoft Excel using the VBA macro code in
LibreOffice, you must first edit the code in the LibreOffice Basic IDE editor. For more
information, see Chapter 12, Macros, in this guide or Chapter 13, Getting Started
with Macros, in the Getting Started Guide.
Note
If any part of the Calc window in Figure 3 is not shown, you can display it using the
View menu. For example, View > Status Bar on the Menu bar will toggle (show or
hide) the Status Bar. It is not always necessary to display all of the parts shown; you
can show or hide any of them as desired.
Title bar
The Title bar, located at the top, shows the name of the current spreadsheet. When the
spreadsheet is newly created, its name is Untitled X, where X is a number. When you save a
spreadsheet for the first time, you are prompted to enter a name of your choice.
Menu bar
Under the Title bar is the Menu bar. When you choose one of the menus, a list of options
appears. You can also modify the Menu bar, as explained in Chapter 14, Setting up and
Customizing.
• File – contains commands that apply to the entire document, such as Open, Save,
Wizards, Export as PDF, Print, Digital Signatures, Templates.
• Edit – contains commands for editing the document, such as Undo, Copy, Find and
Replace, Track Changes.
• View – contains commands for modifying how the Calc user interface looks, such as
Toolbars, View Headers, Full Screen, Zoom.
• Insert – contains commands for inserting elements into a spreadsheet, such as Image,
Chart, Text Box, Headers and Footers.
• Format – contains commands for modifying the layout of a spreadsheet, such as Cells,
Page, AutoFormat Styles, Align.
• Styles – contains options for applying and managing styles, such as Heading 1,
Footnote, Manage Styles.
• Sheet – contains commands for inserting and deleting elements and modifying the entire
sheet, such as Delete Rows, Insert Sheet, Rename Sheet, Navigate.
• Data – contains commands for manipulating data in your spreadsheet, such as Define
Range, Sort, AutoFilter, Consolidate, Statistics.
Chapter 1 Introduction | 17
• Tools – contains functions to help check and customize a spreadsheet, for example
Spelling, Share Spreadsheet, Macros, Options.
• Window – contains two commands; New Window and Close Window. Also shows all
open windows in other LibreOffice applications.
• Help – contains links to LibreOffice Help (included with the software), User Guides, and
other miscellaneous functions; for example Restart in Safe Mode, License
Information, Check for Updates, About LibreOffice.
Toolbars
The default setting when Calc opens is for the Standard and Formatting toolbars to be docked at
the top of the workspace (Figure 3).
Calc toolbars can be either docked (fixed in place), or floating, allowing you to move a toolbar to
a more convenient location on your workspace. Docked toolbars can be undocked and moved to
a different docked location or become floating toolbars. Likewise, floating toolbars can be
docked.
You can choose the single-toolbar alternative to the default double toolbar arrangement. It
contains the most-used commands. To activate it, enable View > Toolbars > Standard (Single
Mode) and disable View > Toolbars > Standard and View > Toolbars > Formatting.
For additional information on toolbars, see Chapter 1, Introducing LibreOffice, of the Getting
Started Guide.
The default set of icons (sometimes called buttons) on toolbars provides a wide range of
common commands and functions. You can also remove or add icons to toolbars. See Chapter
14, Setting up and Customizing, for more information.
Placing the mouse cursor over an icon, text box, or menu command displays a small box called a
tooltip that shows the name of the item’s function. To close a tooltip, move away from the
underlying component or press the Esc key.
To see a more detailed explanation of an icon, text box, or menu command, do one of the
following to open extended tips:
• To activate extended tips just once: press Shift+F1.
• To activate extended tips from the Menu bar: go to Help > What’s This? and hover the
mouse pointer over an icon.
• To turn extended tips on or off: go to Tools > Options > LibreOffice > General on the
Menu bar and toggle the Extended tips checkbox.
Note
The What’s This? facility and extended tips are being improved but in LibreOffice 7.0
this work is incomplete and so they are not fully functional.
Formula Bar
The Formula Bar is located at the top of the Calc workspace. It is permanently docked in this
position and cannot be used as a floating toolbar. However, it can be hidden or made visible by
going to View > Formula Bar on the Menu bar.
Note
In a spreadsheet, the term “function” covers much more than just mathematical
functions. See Chapter 7, Using Formulas and Functions, for more information.
Status Bar
The Status Bar at the bottom of the workspace (Figure 5) provides information about the
spreadsheet and convenient ways to quickly change some of its features. Most of the fields are
similar to those in other components of LibreOffice. See Chapter 1, Introducing LibreOffice, in the
Getting Started Guide for more information.
Chapter 1 Introduction | 19
Page style
Shows the page style of the current sheet. To edit the page style, double-click on this field
and the Page Style dialog opens.
Language
Shows current default language as selected at Tools > Options > Language Settings >
Languages.
Insert / overwrite mode
When the user is interacting with a cell in edit mode, this field distinguishes between the
insert and overwrite modes. If the cell being edited is in overwrite mode, the field shows the
text Overwrite. In other cases, the field is blank. You can press the Insert key on the
keyboard, or click on this field, to switch between insert and overwrite modes.
Selection mode
Right-click to open a context menu and select Standard selection, Extending selection,
or Adding selection. You can also double-click the icon to switch to the next selection
mode in sequence. The icon does not change when different selection modes are selected.
See Chapter 1, Introducing LibreOffice, in the Getting Started Guide for more information.
Unsaved changes
The appearance of this icon indicates whether the spreadsheet contains unsaved changes.
When there are unsaved changes, click this icon, use File > Save, click the Save icon on
the Standard toolbar, or press Ctrl+S to save the spreadsheet.
Digital signature
If the document has been digitally signed, an icon shows here. You can click the icon to
view the certificate. See Chapter 6, Printing, Exporting, E-mailing, and Signing for more
information about digital signatures.
Cell or object information
Displays information related to the position of the cursor or the selected element of the
spreadsheet. When a group of cells is selected, the sum of the contents is displayed by
default. Right-click in this field to select other functions, such as the average value,
maximum value, minimum value, or count (number of items selected).
Zoom slider
Drag the zoom slider, click on the slider’s rail, or click the + and – symbols to change the
view magnification.
Zoom percentage
Indicates the magnification level of the document. Right-click on the percentage to open a
list of magnification values from which to choose. Click on the percentage to open the
Zoom & View Layout dialog.
Sidebar
The Sidebar (Figure 6) is a mixture of toolbar and dialog. When opened (View > Sidebar or
Ctrl+F5), it appears on the right side of the window and consists of five decks: Properties, Styles,
Gallery, Navigator, and Functions. Each deck has a corresponding icon on the Tab panel to the
right of the Sidebar, allowing you to switch between them. The decks are described below.
Chapter 1 Introduction | 21
Styles
Enables the user to apply existing styles, modify existing styles, or create new styles. This
deck can also be opened by selecting Styles > Manage Styles on the Menu bar, selecting
View > Styles on the Menu bar, or pressing F11.
Gallery
Enables the user to add images, diagrams, or other objects that are available in the Gallery
themes. This deck can also be opened by selecting View > Gallery on the Menu bar.
Navigator
This deck is similar to the Navigator dialog opened by selecting View > Navigator from the
Menu bar or pressing F5. See “Using the Navigator” on page 39.
Functions
This deck contains a list of Calc’s many functions organized by category. It is a simpler
version of the Function Wizard, which is opened by selecting Insert > Function on the
Menu bar, clicking the Function Wizard icon on the Formula Bar, or pressing Ctrl+F2.
To the right side of the title bar of each open deck is a Close Sidebar Deck button, which closes
the deck to leave only the Tab panel of the Sidebar open. Click any button in the Tab panel to
toggle on / off the display of the associated deck.
To hide the Sidebar, or reveal it if already hidden, click on the left edge Hide/Show button. To
adjust the deck width, drag on the left edge of the Sidebar.
Spreadsheet layout
Individual cells
The main section of the screen displays the cells in the form of a grid, with each cell located at
the intersection of a column and a row.
At the tops of the columns and the left ends of the rows are a series of header boxes containing
letters and numbers. The column headers use alpha characters that start with A and increase to
the right. The row headers use numerical characters that start at 1 and increase down.
These column and row headers form the cell references that appear in the Name Box on the
Formula Bar (Figure 4). If the headers are not visible on the spreadsheet, go to View > Headers
on the Menu bar.
Sheet tabs
A spreadsheet file can contain many individual sheets. At the bottom of the grid of cells in a
spreadsheet are sheet tabs (Figure 3). Each tab represents a sheet in a spreadsheet. Create a
new sheet by clicking on the plus sign to the left of the sheet tabs.
Clicking on a tab enables access to an individual sheet. When a sheet is active, the tab is
highlighted. Select multiple sheets by holding down the Ctrl key while clicking on the sheet tabs.
To change the default name for a sheet (Sheet1, Sheet2, and so on):
1) Right-click on the sheet tab and select Rename Sheet in the context menu. A dialog
opens allowing you to type in a new name for the sheet.
2) Click OK when finished to close the dialog.
To change the color of a sheet tab:
1) Right-click on the sheet tab and select Tab Color in the context menu to open the Tab
Color dialog (Figure 7).
2) Select a color and click OK when finished to apply the color and close the dialog.
Using templates
Calc documents can also be created from templates. For information on how to create and use
templates, see Chapter 4, Using Styles and Templates, in this guide.
Chapter 1 Introduction | 23
Figure 8: Text Import dialog
The options for importing CSV files into a Calc spreadsheet are as follows:
Import
• Character set – specifies the character set to be used in the imported file.
• Language – determines how the number strings are imported. If Language is set to
Default, Calc will use the language associated with the locale selected at Tools >
Options > Language Settings > Languages > Formats. If another language is
selected, that language will determine how numbers are treated.
• From row – specifies which row the import starts with. The initial rows are visible in the
preview window at the bottom of the dialog.
Separator Options
• Fixed width – separates data into columns by a set number of characters. Click on the
ruler that appears in the preview window to set the width.
• Separated by – separates data into columns based on the separator defined here. Select
Other to specify another character used to separate data into columns. This custom
separator must also be contained in the data.
• Merge delimiters – combines consecutive delimiters and removes blank data fields.
• Trim spaces – removes starting and trailing spaces from within fields.
• String delimiter – select a character to delimit text data.
Other options
• Format quoted field as text – when this option is enabled, fields or cells whose values are
entirely within quotes are imported as text.
• Detect special numbers – when this option is enabled, Calc will automatically detect all
number formats, including special number formats such as dates, time, and scientific
notation. The selected language influences how such special numbers are detected,
since different languages and regions many have different conventions for such special
numbers.
Saving spreadsheets
For information on how to save files manually or automatically, see Chapter 1, Introducing
LibreOffice, in the Getting Started Guide. Calc can save spreadsheets in a range of formats and
also export spreadsheets to PDF and XHTML file formats; see Chapter 6 Printing, Exporting,
E-mailing, and Signing, for more information.
Chapter 1 Introduction | 25
Figure 9: The Save As dialog
Each time a file is saved in a format other than ODF format, the Confirm File Format dialog
opens (Figure 10). Click Use [xxx] Format to continue saving in the selected spreadsheet format
or click Use ODF Format to save the spreadsheet in Calc’s default format. If you disable Warn
when not saving in ODF or default format on Tools > Options > Load/Save > General on the
Menu bar, the Confirm File Format dialog will no longer appear. You can also clear the checkbox
Ask when not saving in ODF or default format on the dialog to stop the dialog appearing.
Note
Once you have saved a spreadsheet in another format, all changes you make to the
spreadsheet will now occur only in the format you are using because you have
changed the name and file type of your document. If you want to go back to working
with an *.ods version, you must save the file as an *.ods file.
Tip
To have Calc save documents by default in a file format other than the default ODF
format, go to Tools > Options > Load/Save > General. In the section named
Default File Format and ODF Settings, next to Document type, select Spreadsheet,
then next to Always save as, select your preferred file format, for example one of the
available Microsoft Excel options.
Password protection
To protect a spreadsheet and restrict who can open, read, and make changes to it, you have to
use password protection. Password protection is common to all LibreOffice modules; for more
information, see Chapter 1, Introducing LibreOffice, in the Getting Started Guide.
Cell navigation
When a cell is selected or in focus, the cell borders are emphasized. When a group of cells is
selected, the cell area is colored. The color of the cell border emphasis and the color of a group
of selected cells depends on the operating system being used and how you have set up
LibreOffice.
• Using the mouse – place the mouse pointer over the cell and click the left mouse button.
To move the focus to another cell using the mouse, move the mouse pointer to the cell
and click the left mouse button.
• Using a cell reference – select or delete the existing cell reference in the Name Box on
the Formula Bar (Figure 4 on page 18). Type the reference of the cell you want to move
to and press the Enter key. Cell references are case insensitive. Thus, typing a3 or A3 will
move the focus to cell A3.
• Using the Navigator – go to View > Navigator or press the F5 key to open the Navigator
dialog (Figure 12). Type the cell references into the Column and Row fields and press the
Enter key. You can also use the Navigator deck in the Sidebar.
Chapter 1 Introduction | 27
• Using the Enter key – pressing Enter moves the cell focus down one cell (by default). You
can change the direction of this focus movement as described in the “Customizing the
Enter key” section on page 31.
• Pressing Shift+Enter moves the focus one cell in the opposite direction to that associated
with the Enter key.
• Using the Tab key – pressing Tab moves the cell focus one cell to the right. Pressing
Shift+Tab moves the focus one cell to the left.
• Using the arrow keys – pressing the arrow keys on the keyboard moves the cell focus in
the direction of the arrow pressed.
Sheet navigation
Each sheet in a spreadsheet is independent of the other sheets, though references can be linked
from one sheet to another. There are three ways to navigate between different sheets in a
spreadsheet.
• Using the Navigator – when the Navigator dialog is open (Figure 12), double-clicking on
any of the listed sheets selects the sheet. You can also use the Navigator deck on the
Sidebar.
• Using the keyboard – using key combinations Ctrl+Page Down moves one sheet to the
right and Ctrl+Page Up moves one sheet to the left.
Note
The sheet tab arrows that appear on the left in Figure 13 are only active if there are
more sheet tabs than can be displayed.
Note
When you insert a new sheet into a spreadsheet, Calc automatically uses the next
number in the numeric sequence as a name. Depending on which sheet is open
when you insert a new sheet, your new sheet may not be in numerical order. It is
recommended to rename sheets in a spreadsheet to make them more recognizable.
Keyboard navigation
You can navigate a spreadsheet using the keyboard, by pressing a key or a combination of keys
at the same time. For example, Ctrl+Home moves the focus to cell A1. Table 3 lists the keys and
key combinations you can use for spreadsheet navigation in Calc.
Table 3. Keyboard cell navigation
Keyboard
Cell navigation
shortcut
→/← Moves cell focus right/left one cell.
↑/↓ Moves cell focus up/down one cell.
Chapter 1 Introduction | 29
Keyboard
Cell navigation
shortcut
Ctrl+→ / If focus is on a blank cell, Ctrl+→ moves focus along the current row to the
Ctrl+← first cell on the right that contains data. If there is no cell on the right
containing data, it moves focus along the current row to the last cell at the
right of the sheet.
If focus is on a blank cell, Ctrl+← moves focus along the current row to the
first cell on the left that contains data. If there is no cell on the left
containing data, it moves focus along the current row to the cell in column A
of the sheet.
If focus is on a cell containing data, Ctrl+→ normally moves focus along the
current row to the cell at the right edge of the same data region. However, if
there is a blank cell to the right of the original cell, focus is moved to the cell
at the left edge of the next data region to the right. In this case, if there is no
data region to the right, focus is moved along the current row to the last cell
at the right of the sheet.
If focus is on a cell containing data, Ctrl+← normally moves focus along the
current row to the cell at the left edge of the same data region. However, if
there is a blank cell to the left of the original cell, focus is moved to the cell
at the right edge of the next data region to the left. In this case, if there is no
data region to the left, focus is moved along the current row to the cell in
column A of the sheet.
Ctrl+↑ / If focus is on a blank cell, Ctrl+↑ moves focus up the current column to the
Ctrl+↓ first cell that contains data. If there is no cell above containing data, it
moves focus up the current column to the cell in row 1 of the sheet.
If focus is on a blank cell, Ctrl+↓ moves focus down the current column to
the first cell that contains data. If there is no cell below containing data, it
moves focus down the current column to the last cell at the bottom of the
sheet.
If focus is on a cell containing data, Ctrl+↑ normally moves focus up the
current column to the cell at the top edge of the same data region.
However, if there is a blank cell above the original cell, focus is moved to
the cell at the bottom edge of the next data region above. In this case, if
there is no data region above, focus is moved up the current column to the
cell in row 1 of the sheet.
If focus is on a cell containing data, Ctrl+↓ normally moves focus down the
current column to the cell at the bottom edge of the same data region.
However, if there is a blank cell below the original cell, focus is moved to
the cell at the top edge of the next data region below. In this case, if there is
no data region below, focus is moved down the current column to the
bottom of the sheet.
Ctrl+Home / A detailed description of these shortcuts is given on Page 28.
Ctrl+End
Alt+Page Down / Moves focus one screen to the right/left (if possible).
Alt+Page Up
Ctrl+Page Down / Moves focus to the next sheet to the right/left in sheet tabs if there are more
Ctrl+Page Up sheets in that direction.
Chapter 1 Introduction | 31
3) Click in the cell in the opposite corner of the range of cells.
Tip
Make sure to change back to Standard selection mode or you may find yourself
extending a cell selection unintentionally.
Selecting sheets
You can select either one or multiple sheets in Calc. It can be advantageous to select multiple
sheets, especially when you want to make changes to many sheets at once.
Single sheet
Click on the sheet tab for the sheet you want to select. The tab for the selected sheet becomes
highlighted.
All sheets
Right-click a sheet tab and choose Select All Sheets in the context menu, or select Edit >
Select > Select All Sheets on the Menu bar.
Tip
You can also select sheets using the Select Sheets dialog, accessed by selecting
Edit > Select > Select Sheets on the Menu bar.
Chapter 1 Introduction | 33
Single column or row
Using the Sheet menu:
1) Select a cell, column, or row where you want the new column or row inserted.
2) Go to Sheet on the Menu bar. For columns, select Sheet > Insert Columns and then
select Columns Before or Columns After. For rows, select Sheet > Insert Rows and
then select Rows Above or Rows Below.
Using the context menu:
1) Select a column or row where you want the new column or row inserted.
2) Right-click the column or row header.
3) Select Insert Columns Before / After or Insert Rows Above / Below in the context
menu.
Deleting cells
1) Select the cell or cells you want to delete.
2) Select Sheet > Delete Cells, press Ctrl+-, or right-click on one of the selected cells and
select Delete in the context menu.
3) Select the option you require from the Delete Cells dialog and press the OK button.
Chapter 1 Introduction | 35
Moving and copying sheets
You can move or copy sheets within the same spreadsheet by dragging and dropping or using
the Move/Copy Sheet dialog (Figure 18). To move or copy a sheet into a different spreadsheet,
use the Move/Copy Sheet dialog.
Deleting sheets
To delete a single sheet, right-click on the sheet tab you want to delete and select Delete Sheet
in the context menu, or go to Sheet > Delete Sheet on the Menu bar. Click Yes to confirm the
deletion.
To delete multiple sheets, select the sheets (see “Selecting sheets” on page 33), then right-click
one of the sheet tabs and select Delete Sheet in the context menu, or go to Sheet > Delete
Sheet on the Menu bar. Click Yes to confirm the deletion.
Renaming sheets
By default, the name for each new sheet added is SheetX, where X is the number of the next
sheet to be added. While this works for a spreadsheet with only a few sheets, it can become
difficult to identify sheets when a spreadsheet contains many sheets.
You can rename a sheet using one of the following methods:
• Enter the name in the Name text box when you create the sheet using the Insert Sheet
dialog (Figure 17 on page 35).
• Right-click on a sheet tab and select Rename Sheet in the context menu to replace the
existing name with a different one.
• Select Sheet > Rename Sheet on the Menu bar to access the Rename Sheet dialog.
• Double-click on a sheet tab to open the Rename Sheet dialog.
Note
Sheet names can contain almost any character. Some naming restrictions apply, the
following characters are not allowed in sheet names: colon (:), back slash (\), forward
slash (/), question mark (?), asterisk (*), left square bracket ([), or right square
bracket (]). In addition a single quote (‘) cannot be used as the first or last character
of the name.
Viewing Calc
Changing document view
Use the zoom function to show more or fewer cells in the window when you are working on a
spreadsheet. For more about zoom, see Chapter 1, Introducing LibreOffice, in the Getting
Started Guide.
Chapter 1 Introduction | 37
1) Click on the row header below the rows you want the freeze or click on the column
header to the right of the columns where you want the freeze. To freeze both rows and
columns, select the cell (not a row or column) that is below the row and to the right of the
column that you want to freeze
2) Go to View on the Menu bar and select Freeze Rows and Columns. A heavier line
appears between the rows or columns indicating where the freeze has been placed.
Unfreezing
To unfreeze rows or columns, go to View on the Menu bar and click Freeze Rows and Columns
to toggle it off. The heavier lines indicating freezing will disappear.
Chapter 1 Introduction | 39
Figure 22: Navigator dialog in Calc
The Navigator categorizes and groups spreadsheet objects which you can click on to move
quickly to that object. If an indicator (plus sign or triangle, dependent on computer setup) appears
next to a category, at least one object in this category exists. To open a category and see the list
of items, click on the indicator. When a category is showing the list of objects in it, double-click on
an object to jump directly to that object’s location in the spreadsheet.
To open the Navigator, do one of the following:
• Press the F5 key to open the Navigator dialog.
• Select View > Navigator on the Menu bar to open the Navigator dialog.
• Click the Navigator icon on the Tab panel of the Sidebar to open the Navigator deck.
The Navigator dialog and the Navigator deck of the Sidebar offer equivalent facilities.
The controls and tools available in the Navigator dialog are as follows:
• Column – type a column letter and press the Enter key to reposition the cell cursor to the
specified column in the same row.
• Row – type a row number and press the Enter key to reposition the cell cursor to the
specified row in the same column.
• Data Range – specifies the current data range denoted by the position of the cell cursor.
• Start – moves the cursor to the cell at the beginning of the current data range, which you
can highlight using the Data Range icon.
• End – moves the cursor to the cell at the end of the current data range, which you can
highlight using the Data Range icon.
• Contents – toggles on / off the display of the contents view in the lower part of the
Navigator dialog, to temporarily reduce its size. There is no equivalent control needed on
the Navigator deck of the Sidebar.
• Toggle – toggles the contents view. Only the selected category and its objects are
displayed. Click the icon again to restore all elements for viewing.
• Scenarios – displays all available scenarios. See Chapter 9, Data Analysis, for more
information about scenarios. Double-click a name to apply that scenario and the result is
shown in the sheet. If the Navigator displays scenarios, you can access the following
commands when you right-click a scenario entry:
– Delete – deletes the selected scenario.
– Properties – opens the Edit Scenario dialog, where you can edit the scenario
properties.
Tip
Ranges, scenarios, pictures, and other objects are much easier to find if you have
given them informative names when creating them, instead of keeping the default
Calc names, for example Scenario 1, Image 1, Image 2, Object 1, and so on. These
default names may not correspond to the position of the object in the document.
Chapter 1 Introduction | 41
General
Contains basic information about the current file.
• The text at the top of the dialog displays the file name.
• Change Password – opens a dialog to change the password. It is only active if a
password has been set for the file.
• Type – displays the file type of the current document.
• Location – displays the path and the name of the directory where the file is stored.
• Size – displays the size of the current document in bytes.
• Created – displays the date, time, and author when the file was first saved.
• Modified – displays the date, time, and author when the file was last saved in a
LibreOffice file format.
• Template – displays the template that was used to create the file, if applicable.
• Digitally signed – displays the date and time when the file was last signed as well as the
name of the author who signed the document.
• Digital Signatures – opens the Digital Signatures dialog where you can manage digital
signatures for the current document.
• Last printed – displays the date, time, and user name when the file was last printed.
• Total editing time – displays the amount of time that the file has been open for editing
since the file was created. The editing time is updated when you save the file.
• Revision number – displays the number of times that the file has been saved.
• Apply user data – saves the full name of the user with the file. You can edit the name by
going to Tools > Options > LibreOffice > User Data on the Menu bar.
• Save preview image with this document – saves a thumbnail.png inside the document.
These images may be used by a file manager under certain conditions.
• Reset Properties – resets the editing time to zero, the creation date to the current date
and time, and the version number to 1. The modification and printing dates are also
deleted.
Description
Contains optional editable descriptive information about the spreadsheet.
• Title – enter a title for the spreadsheet.
• Subject – enter a subject for the spreadsheet. You can use a subject to group
documents with similar content.
• Keywords – enter the words that you want to use to index the content of the
spreadsheet. Keywords must be separated by commas. A keyword can contain white
space characters or semicolons.
• Comments – enter comments to help identify the spreadsheet.
Custom Properties
Use this page to assign custom information fields to the spreadsheet. In a new spreadsheet, this
page may be blank. If the new spreadsheet is based on a template, this page may contain fields.
You can change the name, type, and contents of each row. The information in the fields will be
exported as metadata to other file formats.
Click Add Property to add a new custom property. Use the adjacent Remove Property button to
delete a custom property.
Security
Enables two password-protected security options.
• Open file read-only – select to allow this document to be opened only in read-only
mode. This file sharing option protects the document against accidental changes. It is still
possible to edit a copy of the document and save that copy with the same name as the
original.
• Record changes – select to require that all changes be recorded. To protect the
recording state with a password, click Protect and enter a password. This is similar to
Edit > Track Changes > Record on the Menu bar. However, while other users of this
document can apply their changes, they cannot disable change recording without
knowing the password.
• Protect or Unprotect – protects the change recording state with a password. If change
recording is protected for the current document, the button is named Unprotect. Click
Unprotect to disable the protection.
Font
When Embed fonts in the document is selected, any fonts used in the spreadsheet will be
embedded into the document when it is saved. This may be useful if you are creating a PDF of
the spreadsheet and want to control how it will look on other computer systems.
Only embed fonts that are used in documents – If fonts have been defined for the
spreadsheet (for example, in the template), but have not been used, select this option to not
embed them.
Font scripts to embed – You can choose which types of fonts are embedded: Latin, Asian,
Complex. See the Getting Started Guide for more information.
Statistics
Displays statistics for the current file: the number of sheets, cells, pages, and formula groups.
Regular expressions
Support for regular expressions (often known as regex or regexp) is a hidden gem within Calc.
Regular expressions are very powerful and enable users to define complex search patterns for
locating data of interest within a spreadsheet. Some users may find the syntax used to define a
regular expression daunting and inexperienced users may make mistakes. However a small
investment in time to learn the basic concepts and some of the syntax will pay rich dividends in
the future. We recommend that you do not try to memorize the full syntax but just concentrate on
discovering a few aspects that will help you in your everyday work. As you see the benefits of
using regular expressions, you will certainly be motivated to learn more.
A regular expression is a string of characters defining a pattern of text that is to be matched.
More detailed, general background information can be found on Wikipedia at
https://en.wikipedia.org/wiki/Regular_expression.
Regular expressions are widely used in many domains and there are multiple regular expression
processors available. Calc utilises the open source Regular Expressions package from the
International Components for Unicode (ICU), see http://userguide.icu-project.org/strings/regexp
for further details, including a full definition of the syntax for ICU Regular Expressions.
Chapter 1 Introduction | 43
Regular expressions appear in three areas of Calc’s functionality, as follows:
• Searching with the Find and Replace dialog, accessed by selecting Edit > Find and
Replace on the Menu bar, by clicking the Find and Replace icon on the Find toolbar, or
by pressing Ctrl+H. See Chapter 2, Entering, Editing, and Formatting Data for more
information.
• Filtering using the Standard Filter and Advanced Filter dialogs, accessed by selecting
Data > More Filters > Standard Filter and Data > More Filters > Advanced Filter. See
Chapter 2, Entering, Editing, and Formatting Data for more information.
• Functions. Many of Calc’s functions can use regular expressions in search criteria.
However these only operate correctly if the Tools > Options > LibreOffice Calc >
Calculate > Formulas wildcards > Enable regular expressions in formulas option
has been checked. We also recommend that you enable the Tools > Options >
LibreOffice Calc > Calculate > General Calculations > Search criteria = and <> must
apply to whole cells option so that search criteria in formulas must match the whole of
the cell contents. See Chapter 7, Using Formulas and Functions for more information.
To illustrate the use of regular expressions we can use a sales data spreadsheet, the first few
rows of which are shown in Figure 24.
2) Type the text “^Bri.*” into the Find field. The character “^” means match at the
beginning; “.” means match any character; and “*” means match 0 or more times.
3) Type the text “Brigitte” into the Replace field.
4) If necessary, click the icon to expand the Other options area of the dialog.
5) Make sure that the Regular expressions checkbox is checked.
6) Press the Replace All button. Calc updates the spreadsheet data, replacing all
occurrences of “Bridget” and “Brigid” with “Brigitte”.
7) Press the Close button to remove the Find and Replace dialog.
Suppose we want to filter the same spreadsheet (Figure 24) to show only data relating to the
Tennis and Golf categories, from the North and East regions. This is easily achieved using
regular expressions, using the following steps:
1) Click a cell within the sales data.
2) Select Data > More Filters > Standard Filter on the Menu bar. Calc opens the Standard
Filter dialog (Figure 26).
Chapter 1 Introduction | 45
Figure 26: Using regular expressions on the Standard Filter
dialog
3) Select Category from the first drop-down menu in the Field name column.
4) Select = from the first drop-down menu in the Condition column.
5) Type “Tennis|Golf” in the first text box in the Value column.
6) Select Region from the second drop-down menu in the Field name column.
7) Select = from the second drop-down menu in the Condition column.
8) Type “North|East” in the second text box in the Value column.
9) If necessary, click the icon to expand the Options area of the dialog.
10) Make sure that the Regular expressions checkbox is checked.
11) Press the OK button and Calc updates the data displayed in accordance with the
specified filter criteria.
The data shown in Figure 27 can be used to show a simple example of a function call that
incorporates a regular expression. Suppose we wanted to calculate the revenue from the sale of
pencils, pencil cases, and pens. This can be achieved by entering the following formula into an
empty cell =SUMIFS(C2:C6, A2:A6, "^pen.*"), where the regular expression matches the
name of any product that starts with the characters “pen”. Alternatively we could calculate the
revenue from the sale of books and notebooks using the formula =SUMIFS(C2:C6, A2:A6,
".*book$"), where the regular expression matches the name of any product that ends with the
characters “book”.
Tip
The online help describes many more regular expressions and their uses.
Note
If interoperability with Microsoft Excel is important for your spreadsheet, then you
may not be able to fully utilize Calc’s regular expression facilities because Excel
does not provide equivalent facilities. Hence, when you export a Calc spreadsheet to
Excel format, information relating to regular expressions will not be usable within
Excel. In this case you can use the less powerful wildcards facility provided by Calc
because spreadsheets that utilize wildcards can be exported to Excel format without
loss of data. See Chapter 7, Using Formulas and Functions for more information
about wildcards.
There are numerous websites that include examples of regular expressions and these provide an
endless source of inspiration and ideas to help improve your data analysis skills.
Additional information about regular expressions in Calc can be found in the Help system and on
The Document Foundation’s wiki starting at https://wiki.documentfoundation.org/Documentation/
HowTo/Calc/Regular_Expressions.
Chapter 1 Introduction | 47
Calc Guide
Chapter 2
Entering, Editing, and
Formatting Data
Introduction
You can enter data into Calc in several ways: using the keyboard, the Fill tool, and selection lists,
as well as dragging and dropping. Calc also provides the ability to enter data into multiple sheets
of the same spreadsheet at the same time. After entering data, you can format and display it in
various ways.
Entering data
Most data entry in Calc can be done using the keyboard.
Numbers
Click in the cell and type the number using the number keys on either the main keyboard or the
numeric keypad.
Negative numbers
To enter a negative number, either type a minus sign in front of the number or enclose the
number in parentheses (), for example (1234). The result for both methods of entry is the same;
for example, –1234.
Leading zeroes
By default, if a number is entered with leading zeroes, for example 01481, Calc will automatically
drop the leading zeroes. To retain both the number format and a minimum number of characters
in a cell when entering numbers, for example 1234 and 0012, use this method to add leading
zeroes:
1) With the cell selected, go to Format > Cells on the Menu bar, or right-click on the cell and
select Format Cells in the context menu, or use the keyboard shortcut Ctrl+1, to open the
Format Cells dialog (Figure 28).
2) Make sure the Numbers tab is selected, then select Number in the Category list.
3) In the Leading zeroes field within the Options area, enter the maximum number of
zeroes to display in front of the decimal point. For example, for four characters, enter 4.
Any number less than four characters will then have leading zeroes added, for example
12 becomes 0012.
4) Click OK. The number entered retains its number format and any formula used in the
spreadsheet will treat the entry as a number in formula functions.
Tip
To format numbers with only decimal places, but without a leading zero, follow steps
1 and 2 above, then in the Format code box type a . (period or full stop) followed
by ? (one or more question marks) to represent the number of decimal places
required. For example, for 3 decimal places, type .??? and click OK. Any number
with only decimal places will then have no zero before the decimal, for example
0.01856 becomes .019.
Numbers as text
Numbers can also be converted into text as follows:
1) With the cell selected, open the Format Cells dialog (Figure 28).
2) Make sure the Numbers tab is selected, then select Text from the Category list.
3) Click OK. The number is converted to text and, by default, is left-aligned. You can change
the formatting and alignment of any text numbers just as you would with normal text.
Text
Click in a cell and type the text. The text is left-aligned by default. Cells can contain several lines
of text. If you want to use paragraphs, press Ctrl+Enter to create another paragraph.
On the Formula Bar, you can extend the Input line if you are entering several lines of text. Click
on the Expand / Collapse Formula Bar icon located on the right of the Formula Bar and the
Input line becomes multi-line, as shown in Figure 29. You can drag the bottom of the Input line up
and down to control its exact height. Click the Expand / Collapse Formula Bar icon again to
return the Input line to its default single line height.
Note
Tools > Options > Language Settings > Languages > Formats > Date
acceptance patterns defines the date patterns that will be recognized by Calc. In
addition, every locale accepts input in an ISO 8601 Y-M-D pattern (for example,
2020-07-26).
When you enter a time, separate time elements with colons, for example 10:43:45. The time
format automatically changes to the selected format used by Calc.
To change the date or time format used by Calc:
1) With the cell selected, open the Format Cells dialog (Figure 28).
2) Make sure the Numbers tab is selected, then select Date or Time from the Category list.
3) Select the date or time format you want to use from the Format list.
4) Click OK to save the changes and close the dialog.
Note
The date format will be influenced by the system or document language settings.
Special characters
A special character is a character not normally found on a standard keyboard; for example, © ¾
æ ç ñ ö ø ¢. To insert a special character:
1) Select a cell and place the cursor in the cell or in the Input line, at the point where you
want the character to appear.
2) Go to Insert > Special Character on the Menu bar to open the Special Characters dialog
(Figure 30).
3) From the grid of characters, select the required character. The last character selected is
shown on the right of the Special Characters dialog along with its numerical code.
4) Any recently inserted characters are shown below the grid of characters and can be
selected in the same way as any other character in the dialog.
5) At the bottom of the dialog there is provision for building a small collection of Favorite
Characters. To add a new character to the collection, select the required character and
Tip
You can quickly insert one of your recent or favorite special characters by clicking the
Insert Special Characters icon on the Standard toolbar and selecting the required
character from the drop-down. Click More Characters on this drop-down to open the
Special Characters dialog (Figure 30).
Note
Different fonts include different special characters. If you do not find a particular
special character you want, try changing the Font and Subset selections.
AutoCorrect options
Calc automatically applies many changes during data input using AutoCorrect, unless you have
deactivated any AutoCorrect changes. You can undo any AutoCorrect changes by selecting Edit
> Undo on the Menu bar, pressing the keyboard shortcut Ctrl+Z, or manually going back to the
change and replacing the autocorrection with what you actually want to see.
To change the AutoCorrect options, go to Tools > AutoCorrect Options on the Menu bar to
open the AutoCorrect dialog (Figure 31).
• Replace – edit the replacement table for automatically correcting or replacing words or
abbreviations.
• Exceptions – specify the abbreviations or letter combinations that you do not want
corrected automatically.
• Options – select the options for automatically correcting errors as you type.
• Localized Options – specify the AutoCorrect options for quotation marks and for options
that are specific to the language of the text.
• Reset – reset modified values back to their previous values.
Inserting dashes
Calc provides text shortcuts so that you can quickly insert dashes into a cell and these shortcuts
are shown in Table 4.
AutoInput tool
The AutoInput function in Calc automatically completes entries, based on other entries in the
same column. The column is scanned up to a maximum of 2000 cells or 200 different strings.
When text is highlighted in a cell, AutoInput can be used as follows:
• To accept the completion, press Enter or F2, or click the mouse button.
• To view more completions that start with the same letters, use the key combinations
Ctrl+Tab to scroll forward, or Ctrl+Shift+Tab to scroll backward.
• To see a list of all available AutoInput text items for the current column, use the keyboard
combination Alt+↓. See “Selection lists” on page 57 for more information.
When typing formulas using characters that match function names, a Help tip will appear listing
the available functions that start with matching characters.
AutoInput ignores the case sensitivity of any data you enter. If, for example, you have written
“Total” in a cell, you cannot then use AutoInput to enter “total” in another cell of the same column
without first deactivating AutoInput or entering “total” manually.
By default, AutoInput is activated in Calc. To turn it off, go to Tools on the Menu bar and deselect
AutoInput.
Fill tool
You can use the Fill tool in Calc to duplicate existing content or create a series in a range of cells
in the spreadsheet as shown by the examples in Figure 32.
1) Select the cell containing the contents you want to copy or start the series from.
2) Drag the cursor in any direction or hold down the Shift key and click in the last cell you
want to fill.
3) Go to Sheet > Fill Cells on the Menu bar and select the direction in which you want to
copy or create data (Down, Right, Up, Left, Sheets, Series, or Random Number). A
menu option will be grayed out if it is not available.
Tip
You can use the keyboard shortcut Ctrl+D as an alternative to selecting Sheet > Fill
Cells > Fill Down on the Menu bar.
Caution
When you are selecting cells so you can use the Fill tool, make sure that none of the
cells contain data, except for the cell data you want to use. When you use the Fill
tool, any data contained in selected cells is overwritten.
Selection lists
Selection lists are available only for text and are limited to using only text that has already been
entered in the same column.
1) Select a blank cell in a column that contains cells with text entries.
2) Right-click and select Selection List in the context menu, or use the keyboard shortcut
Alt+↓. A drop-down list appears listing any cell in the same column that either has at least
one text character or whose format is defined as text.
3) Click on the text entry you require and it is entered into the selected cell.
Caution
Merging cells can lead to calculation errors in formulas used in the spreadsheet.
Splitting
You can reverse a merge operation by splitting a cell that was previously created by merging
several cells.
1) Select a merged cell.
2) Go to Format > Merge Cells > Split Cells on the Menu bar, or click on the Merge and
Center Cells icon on the Formatting toolbar, or right-click and select Split Cells from the
context menu.
3) Any data in the cell will remain in the first cell. If the hidden cells did have any contents
before the cells were merged, then you may have to manually move the contents to the
correct cell.
1) Go to Edit > Select > Select Sheets on the Menu bar to open the Select Sheets dialog
(Figure 37).
2) Select the individual sheets where you want the information to be repeated.
3) Click OK to select the sheets and the sheet tabs will be highlighted.
4) Enter the information in the cells on the sheet where you want the information to first
appear and the information will be repeated in the selected sheets.
5) Deselect the sheets when you have finished entering the information that you want
repeated in the sheets.
Tip
You can select sheets with the mouse, as described in the “Selecting sheets” section
of Chapter 1, Introduction.
Caution
This technique automatically overwrites, without any warning, any information that is
already in the cells on the selected sheets. Make sure you deselect the additional
sheets when you have finished entering the information to be repeated before
continuing to enter data into the spreadsheet.
Defining validation
To validate any new data entered into a cell:
1) Select a cell and go to Data > Validity on the Menu bar to open the Validity dialog (Figure
38).
2) Define the type of contents that can be entered in that cell using the options given on the
tabbed pages for Criteria, Input Help, and Error Alert. The options are explained below.
Criteria options
Specify the validation rules for the selected cells using the Criteria tab of the Validity dialog as
shown in Figure 38. For example, you can define criteria such as numbers between 1 and 10, or
texts that are no more than 20 characters.
The options available on the Criteria tab will depend on what has been selected in the Allow
drop-down list.
• Allow – select a validation option for the selected cells from the drop-down list.
– All values – no limitation.
– Whole Numbers – only whole numbers allowed.
– Decimal – all numbers correspond to decimal format.
– Date – all numbers correspond to date format. The entered values are formatted the
next time the dialog is called up.
– Time – all numbers correspond to time format. The entered values are formatted the
next time the dialog is called up.
– Cell range – allow only values that are given in a cell range. The cell range can be
specified explicitly, or as a named database range, or as a named range. The range
Calc Detective
The Detective is a tool within Calc that you can use to locate any cells in a spreadsheet that
contain invalid data if the cells are set to accept invalid data with a warning.
1) Go to Tools > Detective > Mark Invalid Data on the Menu bar to locate any cells
containing invalid data. The Detective function marks any cells containing invalid data.
2) Correct the data so that it becomes valid.
3) Go to Tools > Detective > Remove All Traces on the Menu bar and any cells that were
previously marked as containing invalid data have the invalid data mark removed.
Note
A validity rule is considered part of the format for a cell. If you select Delete all from
the Delete Contents dialog (Figure 42), then it is removed. If you want to copy a
validity rule with the rest of the cell, use Edit > Paste Special > Paste Special to
open the Paste Special dialog (Figure 43), then select Paste all or Formats and
click OK.
Editing data
Deleting data
Deleting cell data only
Data can be deleted from a cell without deleting any of the cell formatting. Select a cell or a range
of cells and then press the Delete key.
Note
The selected delete option is stored and reloaded when the dialog is next opened,
until LibreOffice is closed. After opening LibreOffice again the delete option contains
the default setting.
Replacing data
To completely replace data in a cell and insert new data, select the cell and type in the new data.
The new data will replace the data already contained in the cell and will retain the original
formatting used in the cell.
Alternatively, click in the Input line on the Formula Bar, then double-click on the data to highlight it
completely and type the new data.
Editing data
Sometimes it is necessary to edit the contents of a cell without removing all of the data from the
cell. For example, changing the phrase “Sales in Qtr. 2” to “Sales rose in Qtr” can be done as
follows.
Tip
Each time you select a cell, the contents are displayed in the Input line on the
Formula Bar. Using the Input line may be easier when editing data.
Tip
Instead of steps 5) and 6) above, you can press one of the three shortcut buttons at
the top of the dialog – Values Only, Values & Formats, or Transpose.
Note
The Insert Field > Document Title command inserts the name of the spreadsheet
and not the title defined on the Description tab of the Properties dialog for the file.
Tip
The fields are refreshed when the spreadsheet is saved or recalculated when using
the Ctrl+Shift+F9 shortcut.
Formatting data
Note
All the settings discussed in this section can also be set as a part of the cell style.
See Chapter 4, Using Styles and Templates, for more information.
You can format the data in Calc in several ways, either defined as part of a cell style so that it is
automatically applied, or applied manually to the cell. For more control and extra options, select a
cell or cell range and use the Format Cells dialog. All of the format options are discussed below.
Automatic wrapping
To automatically wrap multiple lines of text in a cell:
1) Select a cell or cell range.
2) Go to Format > Cells on the Menu bar, or right-click and select Format Cells in the
context menu, or press Ctrl+1, to open the Format Cells dialog.
3) Click on the Alignment tab (Figure 44).
4) Under Properties, select Wrap text automatically and click OK.
Formatting numbers
Several different number formats can be applied to cells by using icons on the Formatting toolbar
(highlighted in Figure 45). Select the cell, then click the relevant icon to change the number
format.
For more control or to select other number formats, use the Numbers tab of the Format Cells
dialog (Figure 28 on page 50):
• Apply any of the data types in the Category list to the data.
• Select one of the predefined formats in the Format list.
Formatting fonts
To select a font and format it for use in a cell:
1) Select a cell or cell range.
2) Click the down arrow on the right of the Font Name box on the Formatting toolbar
(highlighted in Figure 46) and select a font from the drop-down list. The font can also be
changed using the Font tab on the Format Cells dialog.
3) Click on the down arrow on the right of the Font Size box on the Formatting toolbar and
select a font size from the drop-down list. The font size can also be changed using the
Font tab on the Format Cells dialog.
4) To change the character format, click on the Bold, Italic, or Underline icons on the
Formatting toolbar.
5) To change the paragraph alignment, click on one of the alignment icons (Align Left,
Align Center, Align Right, and Justified). The Format > Align menu also provides
these options.
Note
To specify the language used in the cell, open the Font tab on the Format Cells
dialog. Changing language in a cell allows different languages to exist within the
same document. For more changes to font characteristics, see “Font effects” below.
Tip
To choose whether to show the font names in their font or in plain text, go to Tools >
Options > LibreOffice > View and select or deselect the Show preview of fonts
option in the Font Lists section. For more information, see Chapter 14, Setting up
and Customizing.
Font effects
1) Select a cell or cell range.
2) Right-click and select Format Cells in the context menu, or go to Format > Cells on the
Menu bar, or press Ctrl+1, to open the Format Cells dialog.
3) Click on the Font Effects tab (Figure 47).
4) Select the font effect you want to use from the options available. The options available
are described in Chapter 4, Using Styles and Templates.
Text direction
To change the text direction within a cell, use the Alignment tab on the Format Cells dialog
(Figure 44 on page 69).
1) On the Alignment tab of the Format Cells dialog, select the Reference edge from which to
rotate the text as follows:
– Text Extension From Lower Cell Border – writes the rotated text from the bottom cell
edge outwards.
– Text Extension From Upper Cell Border – writes the rotated text from the top cell edge
outwards.
– Text Extension Inside Cell – writes the rotated text only within the cell.
2) Click on the small indicator at the edge of the text orientation dial and rotate it until you
reach the required degrees.
3) Alternatively, enter the number of degrees to rotate the text in the Degrees box.
4) Select Vertically stacked to make the text appear vertically in the cell.
Note
The text direction icons can only be made available if the Asian and Complex text
layout options are checked under Tools > Options > Language Settings >
Languages > Default Language for Documents. If it is necessary to make the
buttons visible, right-click on the toolbar and select Visible Buttons from the context
menu, then click on the icon you require and it will be placed on the Formatting
toolbar.
Asian Typography
If Asian language support is enabled through Tools > Options > Language Settings >
Languages > Default Languages for Documents > Asian, an Asian Typography tab is
included on the Format Cells dialog (Figure 48). This tab enables setting of typographic options
for cells in Asian language documents.
Note
Cell border properties apply only to the selected cells and can only be changed if you
are editing those cells. For example, if cell C3 has a top border, that border can only
be removed by selecting C3. It cannot be removed in C2, even though it appears to
be the bottom border for cell C2.
Note
When entering borders with the border icons on the Formatting toolbar, you have two
choices: click the required icon to add a border to the present borders or Shift-click to
add a border and remove the present borders.
Using themes
Calc comes with a predefined set of formatting themes that you can apply to spreadsheets. It is
not possible to add new themes to Calc and the predefined styles cannot be modified. You can
modify styles after you apply them to a spreadsheet, but the modified styles are only available for
use for that spreadsheet.
To apply a theme to a spreadsheet:
1) Go to Format > Spreadsheet Theme on the Menu bar, or click the Spreadsheet Theme
icon in the Tools toolbar, to open the Theme Selection dialog (Figure 51), which lists the
available themes for the whole spreadsheet.
2) Select the theme that you want to apply. As soon as you select a theme, the theme styles
are applied to the spreadsheet and are immediately visible.
3) Click OK.
Value highlighting
Value highlighting displays cell contents in different colors depending on the type of content. An
example of value highlighting is shown in Figure 52.
Note
Conditional formatting depends upon the use of styles and the AutoCalculate feature
must be enabled. If you are not familiar with styles, see Chapter 4, Using Styles and
Templates, for more information.
Color Scale
Use color scale to set the background color of cells depending on the values of the data in those
cells. Color scale can only be used when All Cells has been selected for the condition. You can
use either two or three colors for the color scale.
Icon Set
Icon sets display an icon next to the data in each selected cell to give a visual representation of
where the cell data falls within the defined range that you set. The icon sets available include
colored arrows, gray arrows, colored flags, colored signs, symbols, bar ratings, and quarters.
Icon sets can only be accessed when the Conditional Formatting dialog has been opened and All
Cells has been selected for the condition.
Date
Date applies a defined style depending on a data range that you choose from the drop-down
menu. Examples include Tomorrow, Last 7 days, This week, Next month, Last year.
Tip
Although each can be accessed using a different option in the Format > Conditional
menu of the Menu bar, the five variants of the Conditional Formatting dialog shown in
Figures 53 to 57 are not distinct. Once the dialog is open you can create conditions
of all types without interacting with the Menu bar. For example, you might create
Condition 1 to select a cell style to be used if the cell takes a certain value (Condition
1 is of type “Condition”). You might then press the Add button to create Condition 2
by selecting All Cells in the condition’s upper left drop-down and then selecting Data
Bar in the adjacent drop-down (Condition 2 is of type “Data Bar”). You might then
press the Add button to create Condition 3 by selecting Date is in the condition’s
upper left drop-down (Condition 3 is of type “Date”). In this way you can create many
conditions of different types to control the conditional formatting of the selected cells.
Defining conditions
1) Select the cells where you want to apply a conditional style.
2) Go to Format > Conditional > Condition, Color Scale, Data Bar, Icon Set, or Date
from the Menu bar to open the Conditional Formatting dialog.
3) Enter the conditions you want to use for conditional formatting.
Calculating average
In our particular example, we are calculating the average of the random values. The result is
placed in a cell:
1) Click in a blank cell, for example, J14, and go to Insert > Function on the Menu bar, or
click the Function Wizard icon on the Formula Bar, or press Ctrl+F2, to open the
Function Wizard dialog.
2) Select AVERAGE from the Functions list.
3) Use the cursor to select all your random numbers.
4) Click OK to close the Function Wizard.
Cells
Hiding individual cells is more complicated. First, you need to define the cells as protected and
hidden; then you need to protect the sheet.
1) Select the cells you want to hide.
2) Go to Format > Cells on the Menu bar, or right-click and select Format Cells in the
context menu, or press Ctrl+1, to open the Format Cells dialog (Figure 60).
3) Click the Cell Protection tab and select an option for hiding and printing the cells.
4) Click OK to save the changes and close the dialog.
5) Go to Tools > Protect Sheet on the Menu bar, or right-click on the sheet tab and select
Protect Sheet in the context menu, to open the Protect Sheet dialog (Figure 61).
6) Select Protect this sheet and the contents of protected cells.
7) Create a password and then confirm the password.
8) Select or deselect the options in the Allow all users of this sheet to area so that users can
select protected or unprotected cells.
9) Click OK to save the changes and close the dialog.
Note
When content in cells is hidden, it is only the content contained in the cells that is
hidden and the protected cells cannot be modified. The blank cells remain visible in
the spreadsheet.
Cells
1) Go to Tools > Protect Sheet on the Menu bar, or right-click on the sheet tab and select
Protect Sheet in the context menu, to open the Protect Sheet dialog (Figure 61).
2) Enter the password to unprotect the sheet and click OK.
3) Go to Format > Cells on the Menu bar, right-click and select Format Cells in the context
menu, or press Ctrl+1, to open the Format Cells dialog (Figure 60).
4) Click the Cell Protection tab and deselect the hide options for the cells. Click OK.
Note
When protecting a sheet using the Protect Sheet dialog, you can leave the password
fields blank. In this case, the Protect Sheet dialog is not presented at step 1) above
and step 2) is not necessary.
Grouping
To group rows or columns:
1) Select the cells you want to group in the spreadsheet.
2) Go to Data > Group and Outline > Group on the Menu bar, or press the F12 key.
3) In the Group dialog that opens, select either Rows or Columns and click OK. A group
indicator appears to the left of any rows grouped or above any columns grouped. Figure
62 shows a group indicator on the left of the first two rows of the spreadsheet showing
that they have been grouped.
Hiding details
To hide the details of any group of rows or columns:
1) Click on the minus (–) sign on the group indicator.
2) Alternatively, select a cell within the group and go to Data > Group and Outline > Hide
Details on the Menu bar.
3) The rows or columns are hidden and the minus (–) sign becomes a plus (+) sign on the
group indicator.
Showing details
To show the details of any hidden groups of rows or columns:
1) Click on the plus (+) sign on the group indicator.
2) Alternatively, select a cell on each side of the hidden group and go to Data > Group and
Outline > Show Details on the Menu bar.
3) The hidden rows or columns are displayed and the plus (+) sign becomes a minus (–)
sign on the group indicator.
Ungrouping
To ungroup any groups of rows or columns:
1) Make sure the grouped rows or columns are displayed and click on a cell within the
group.
2) Go to Data > Group and Outline > Ungroup on the Menu bar, or use the keyboard
combination Ctrl+F12.
3) If only rows or only columns are grouped, they are ungrouped. If both rows and columns
are grouped, select either Rows or Columns on the Ungroup dialog and click OK.
Caution
Any hidden groups of rows or columns must be displayed. If they are hidden, then
the grouped rows or columns are deleted from the spreadsheet.
Note
If there are nested groups, only the last group of rows or columns created is
ungrouped.
AutoOutline
If a selected cell range contains formulas or references, Calc can automatically outline the
selection. For example, in Figure 63 the cells for the 1st and 2nd quarters each contain a sum
formula for the three cells to their left. If you apply the AutoOutline command, the columns are
grouped into two quarters.
To apply the AutoOutline function, go to Data > Group and Outline > AutoOutline on the Menu
bar. Calc will then check for cells that contain formulas or references and automatically group the
cells as necessary.
Removing
To remove any cell groups of rows or columns, go to Data > Group and Outline > Remove
Outline on the Menu bar and any groups are removed.
For any cell group of rows or columns that are hidden, the grouping is removed from the cells
and the cells are displayed in the spreadsheet.
Filtering
A filter is a list of conditions that each entry has to meet to be displayed. Calc provides three
types of filters:
• Standard – specifies the logical conditions to filter the data.
• AutoFilter – filters data according to a specific value or string. Automatically filters the
selected cell range and creates one-row list boxes where you can choose the items that
you want to display.
• Advanced – uses filter criteria from specified cells.
Applying an AutoFilter
An AutoFilter adds a drop-down list to the top row of one or more data columns which lets you
select the rows to be displayed. The list includes every unique entry in the selected cells sorted
into lexical order (see https://www.dictionary.com/browse/lexical-order for an explanation of
lexical order). AutoFilter can be used on multiple sheets without first defining a database range.
1) Click in a cell range on the spreadsheet. If you want to apply multiple AutoFilters to the
same sheet, you must first define database ranges, then apply the AutoFilters to the
database ranges.
2) Go to Data > AutoFilter on the Menu bar, or click the AutoFilter icon on the Standard
toolbar. An arrow button is added to the head of each column in the database range.
3) Click the arrow or small triangle in the column that contains the value or string that you
want to set as the filter criteria (shown in Figure 65).
4) Select the value or string that you want to use as the filter criteria. The records that match
the filter criteria that you selected are then shown.
Note
The options for advanced filtering are the same as those used for standard filtering,
see “Applying a standard filter” on page 88 for more information.
Sorting records
Sorting within Calc arranges the cells in a sheet using the sort criteria that you specify. Several
criteria can be used and a sort applies each criteria consecutively. Sorts are useful when you are
searching for a particular item and become even more useful after you have filtered data.
Also, sorting is useful when you add new information to a spreadsheet. When a spreadsheet is
long, it is usually easier to add new information at the bottom of the sheet, rather than adding
rows in their correct place. After you have added information, you can then sort the records to
update the spreadsheet.
Sort dialog
To sort cells in a spreadsheet using the Sort dialog:
1) Select the cells, rows, or columns to be sorted.
Note
If any of the cells that you select for sorting are protected and the sheet is protected,
then Calc cannot modify those cells and the sort will not be executed. An error
message will be displayed to indicate that protected cells cannot be modified.
However, it is possible to sort a range containing a row of column labels that are
protected, since these are not modified by the sort.
Sort options
On the Options tab of the Sort dialog (Figure 67), you can set these options:
• Case sensitive – sorts first by uppercase letters and then by lowercase letters. For Asian
languages, special handling applies.
Note
For Asian languages, select Case sensitive to apply multi-level collation. With multi-
level collation, entries are first compared in their primitive forms with their cases and
diacritics ignored. If they evaluate as the same, their diacritics are taken into account
for the second-level comparison. If they still evaluate as the same, their cases,
character widths, and Japanese Kana difference are considered for the third-level
comparison.
• Range contains column/row labels – omits the first column/row in the selection from
the sort. The Direction setting at the bottom of the dialog defines the name and function
of this check box: if top to bottom, then column labels; if left to right, then row labels.
• Include formats – preserves the current cell formatting.
• Enable natural sort – natural sorting is a sort algorithm that sorts string-prefixed
numbers based on the value of the numerical element in each sorted number, instead of
the traditional way of sorting them as ordinary strings. For instance, assume you have a
series of values such as, A1, A2, A3, A4, A5, A6, ..., A19, A20, A21. When you put these
values into a range of cells and run the sort, it will become A1, A11, A12, A13, ..., A19,
A2, A20, A21, A3, A4, A5, ..., A9. With natural sorting selected, values such as these are
sorted correctly.
Quick sort
If the columns in the spreadsheet have a header with a text format, you can use a quick sort.
1) Select a cell or a cell range to be sorted.
2) Select Data > Sort Ascending or Data > Sort Descending on the Menu bar, or click the
Sort Ascending or Sort Descending icon on the Standard toolbar.
Find toolbar
Finding
1) In the Find and Replace dialog (Figure 70), enter the search criteria in the Find box.
2) Select basic options from those located directly under the Find box.
3) If necessary, click on Other options to increase the number of search filters.
4) Click Find Next to locate the first instance of the search criteria.
5) Click Find Next again to locate the next instance of the search criteria. Repeat as
needed.
6) Or, click Find All to locate all cells containing the search criteria. These cells will be
highlighted in the spreadsheet. A Search Results dialog will pop up, listing the cell
locations.
Replacing
1) In the Find and Replace dialog (Figure 70), enter the search criteria in the Find box.
2) Select basic options from those located directly under the Find box.
3) Enter the replacement contents in the Replace box.
4) If necessary, click on Other options to increase the number of search filters.
5) To step through the cells and choose whether to replace the contents:
6) Click Find Next to locate the first instance of the search criteria.
7) If necessary, click Replace to replace the search criteria with the contents of the Replace
box.
8) Repeat as required.
9) Or, to locate and replace all instances of the search criteria without stopping at each one,
click Replace All. A Search Results dialog will pop up, listing the affected cells.
Tip
To replace the first instance of the search criteria you can simply press Replace
without pressing Find Next first.
Caution
Use Replace All with caution; otherwise, you may end up with some highly
embarrassing mistakes. A mistake with Replace All might require a manual, word-
by-word search to fix, if it is not discovered in time to undo it.
Note
The Wildcards, Regular expressions, and Similarity search options are mutually
exclusive; only one can be selected.
Chapter 3
Creating Charts and Graphs
Presenting information visually
Introduction
Charts and graphs can be powerful tools for conveying information and Calc offers a variety of
ways to present data. They can be customized to a considerable extent, enabling information to
be shown in the clearest manner.
For readers interested in effective ways to present information graphically, two excellent
introductions to the topic are William S. Cleveland’s The Elements of Graphing Data, 2nd edition,
Hobart Press (1994) and Edward R. Tufte’s The Visual Display of Quantitative Information, 2nd
edition, Graphics Press (2001).
Chart Wizard
Use the Chart Wizard to create an initial chart using data in a spreadsheet. Then use the Chart
Wizard options to change the type of chart, adjust data ranges, and edit some chart elements.
Each change is immediately seen in the underlying chart.
Tip
When the data is in one place, the Chart Wizard can guess the range and create an
initial chart even if all of the data is not selected. Before opening the Chart Wizard,
just place the cursor or select a cell anywhere in the area of the data.
2) Do one of the following. This will cause a chart to be placed on the spreadsheet as an
object (Figure 73) and the Chart Wizard dialog will be opened (Figure 74).
– Go to Insert > Chart on the Menu bar.
– Click the Insert Chart icon on the Standard toolbar.
3) Choose the chart type and make any other selections desired. The options are explained
below.
4) Click Finish to save the selections and close the Chart Wizard.
The following sections provide further details about using the Chart Wizard.
50
40
Canoes
30
Boats
Motors
20
10
0
Jan Feb Mar Apr May Jun
Figure 73: Example chart automatically created using the Chart
Wizard
Note
To recreate many of the charts shown in the following sections, select the Column
chart type, Normal variant, with the 3D Look option unchecked.
Note
If the syntax for a data range is not correct, Calc highlights the Data range text box to
indicate the error and disables the < Back, Next >, and Finish buttons.
Note
The options under Tools > Options may not be available when the chart is in edit
mode. If desired, click outside the chart to leave edit mode and see the options. Click
the chart twice to enter edit mode again.
Note
When the data is in the same document as the chart, changes to the data are
instantly reflected in the chart.
Tip
The Chart Wizard makes initial assumptions about how the data should be
displayed, but the assumptions could be incorrect. If a chart does not look as
expected, the first thing to check is if all data series are defined correctly.
Also, check the settings on the Data Range page that define whether the data are in
rows or columns and whether the first row or first column should be considered
labels.
The names of each data series appear in the Data series list box (the middle box in Figure 76).
To organize the data series, select an entry in the Data series list and do one or more of the
following:
Note
Different data series must be in separate columns or rows. Otherwise Calc will
assume that they are the same data series.
Data ranges that may be defined for a specific chart type appear in the Data ranges box on the
right side of the Data Series page, shown in Figure 76. Not all data ranges may need to be filled
in.
Note
XY (scatter) and bubble charts are unlike other chart types because they use value
data for their X axis rather than category data. For the XY (scatter) and bubble chart
types, the Data Series page of the Chart Wizard includes a Data labels box instead
of the Categories box displayed for other chart types. To create a set of data labels
(one for each data point), enter the required text strings into a range of spreadsheet
cells and then enter details of that cell range into the Data labels box. The labels can
then be displayed on the chart by selecting the Show category option on the Data
Labels dialog (see Figures 106 and 107).
Depending on the type of chart, other data ranges may need to be defined in addition to those
shown in Figure 76.
Figure 77: Chart Wizard dialog – selecting and changing chart elements
On the Chart Elements page of the Chart Wizard dialog (Figure 77), add or change the title,
subtitle, axes names, and grids. Use titles that draw the attention of viewers to the purpose of the
chart and describe what they should focus on.
The chart elements for 2D and 3D charts are illustrated in Figure 78.
• The chart wall contains the graphic displaying the data.
• The chart area is the background of the entire chart.
• The chart title and subtitle, chart legend, axes labels, and axes names are in the chart
area.
• The chart floor is only available for 3D charts.
Note
While clicking Finish closes the Chart Wizard, the chart remains in edit mode,
indicated by gray borders, and can still be modified. Click outside the chart in any
cell to exit the edit mode.
Tip
If you follow the directions above and the Properties deck of the Sidebar does not
appear, click the Properties icon on the upper right of the Sidebar.
The options available on the Properties deck of the Sidebar are also available elsewhere. They
may be found in the Menu bar, the Formatting toolbar, or context menus (made available by right-
clicking a chart element).
Note
The Sidebar can be quite useful. However, because the options are easy to see and
are available elsewhere, further references to it are not included in this chapter.
Insert menu
In edit mode, the Insert menu on the Menu bar displays the options shown in Figure 80 and
discussed below:
Format menu
In edit mode, these settings appear on the Format menu (Figure 81) of the Menu bar.
Descriptions of the options follow:
Formatting toolbar
In edit mode, the Formatting bar appears as in Figure 82. Click one of the icons to open a dialog
or turn an option on or off. The Insert and Format menus on the Menu bar, described above,
contain the same options, with one exception.
The option Select Chart Element drop-down list does not appear elsewhere. Use it to easily
select individual chart elements. It can be especially helpful when the chart is crowded or it is
otherwise difficult to select elements using the cursor. Note that options such as Data Labels or
Trend Line do not appear on this list unless they have already been inserted using the Insert
menu.
Tip
When you hover the cursor over an element, Calc will display the element name,
making it easier to select the correct element. The name of the selected element also
appears in the Status Bar.
Tip
For some chart elements (such as title, subtitle, axis name, and legend), press the
arrow keys to move the object in small steps.
Note
When a 3D chart element is selected, round selection handles may appear. These
handles control the 3D angle of the element. You cannot resize or reposition the
element while they are showing. Click again to obtain the square selection handles
that allow you to resize and reposition the 3D chart graphic.
Tip
The text of a title (but not formatting) can be modified directly. With the chart in edit
mode, double-click on the text to directly change it. Use Shift+Enter at the end of the
line to create an additional line that splits the text.
Formatting text
Use a more extensive Titles dialog to format the appearance of a chart title, subtitle, or axis
name. To access this dialog:
1) Select the chart by double-clicking on it to enter edit mode. The chart should now be
surrounded by a gray border.
2) Do one of the following to open the Titles dialog for formatting (Figure 84):
– Click Format > Title and select the desired type of title or the All Titles option.
– Click on the element in the chart, right-click, and select Format Title (or appropriate
element) from the context menu.
– Click on the element in the chart or select it in the Select Chart Element drop-down list
on the Formatting toolbar. Then select Format > Format Selection on the Menu bar
or click on the Format Selection icon on the Formatting toolbar.
3) Format titles or names as needed. The options are self-explanatory or easily researched.
4) Click OK to close the dialog. If desired, click outside the chart to leave edit mode.
Legends
When a legend is displayed, it shows data series names along with their graphical
representations, such as bars, lines, or points. It will also show trend lines when those are turned
on, as shown in Figure 85.
Note
The names in the legend are the data series names. They are taken from the Name
data range, discussed in “Selecting data series” on page 103. Change a legend
name by changing the text in the spreadsheet.
Tip
For finer positioning of the Legend, use one of the methods described in “Moving
chart elements” on page 113.
Formatting legends
For advanced editing of a legend’s appearance, a more extensive Legend dialog (Figure 87) has
several options for formatting borders, fill, fonts, transparency, and position.
1) Enter edit mode by double-clicking the chart. The chart should now be surrounded by a
gray border.
2) Do one of the following to open the Legend dialog (Figure 87):
– Click on the Legend icon on the Formatting toolbar.
– Select Format > Format Legend on the Menu bar.
– Right-click on the legend and select Format Legend in the context menu.
– Click on Legend in the Select Chart Element drop-down list on the Formatting toolbar
or click the legend in the chart to select it. Then click on the Format Selection icon on
the Formatting toolbar or select Format > Format Selection.
3) Make any desired changes. The options are self-explanatory or easily researched.
4) Click OK to close the dialog. If desired, click outside the chart to leave edit mode.
Note
The chart automatically reflects changes in the spreadsheet data. Thus, changing a
number from 5 to 50 in the data will instantly show the new number in the chart.
Tip
If Calc is taking a significant amount of time to process a large amount of data for a
chart, try this: Select only limited data for each data series to initially organize the
chart. Adjust the settings until the chart looks as desired, then select all of the data.
For further information, see “Selecting data range” on page 102 and “Selecting data series” on
page 103.
Note
The tabs that appear on the Data Series dialog depend on the type of chart selected.
Similarly the controls that appear on each tab may differ depending on the type of
chart.
Note
A data series can be associated with a secondary Y axis only after the Chart Wizard
has finished creating the chart.
Tip
If applying a gradient does not work as expected, do this: After selecting the desired
options on the Gradient page, click Add, provide a name for the gradient (or accept
the default), and click OK.
Figure 93: Data Series dialog for line and scatter charts – Line tab
Assigning colors
Colors for the display of data series can be specified in three ways: changing the default color
scheme, using the Data Series dialog, or using data ranges to set colors for border and fill.
Note
Data ranges for border color and fill can only be specified for column, bar, pie,
bubble, and column and line charts.
In addition to directly assigning colors, use conditional formatting to define criteria for when
specific colors will be used. (Conditional formatting is described in Chapter 2, Entering, Editing,
and Formatting Data.)
Figure 94 shows an example of using conditional formatting to specify colors. The COLOR
function in the Formula Wizard was used to create the conditional formula
=IF(B2>100,COLOR(240,240,0,20),COLOR(150,0,150,20))
This formula says that when the value in column B is over 100, the first RGB setting is used to
color that data point in the chart. When the value in column B is 100 or less, the default color
(150, 0, 150) is used. This formula is in all cells of column C. The numbers appearing in column
C are the RGB values calculated using the conditional formula (with cell references changed
accordingly).
Figure 94: Using the COLOR function and a conditional formula to specify colors
The chart on the right in Figure 94 shows how the colors change to reflect the conditional
formatting.
Tip
As shown in Figure 95, hover the cursor over a data point to show the number of the
data point, the number of the series, and the X and Y values of the data point.
Axes
Add or remove axis labels
Use the Axes dialog shown in Figure 96 to add or remove axis labels, such as numbers or
categories. (To change the name of an axis, see “Titles, subtitles, and axis names” on page 114).
To use the Axes dialog:
1) Enter edit mode by double-clicking the chart. The chart should now be surrounded by a
gray border.
2) Open the Axes dialog by doing one of the following:
– Go to Insert > Axes on the Menu bar.
– Right-click on the chart and select Insert/Delete Axes in the context menu.
Defining Scales
Use the Scale tab to modify the automatically generated scale for a primary axis. In addition, use
the Scale tabs for secondary axes to specify scales that are different from the scales for primary
axes. This can be quite useful for showing Celsius and Fahrenheit scales on the same chart, for
example, or for when data are aligned to a secondary Y axis (see “Aligning data to secondary Y
axis” on page 121).
The contents of the Scale tab (Figure 98) vary with chart type but may contain the following
options:
Reverse direction
Defines the order of lower and higher values along the axis. When not selected, the X axis
shows the lower values on the left and the Y axis shows the lower values at the bottom.
When selected, the orientation of the data display is reversed, as in Figure 99.
Logarithmic scale
Specifies that the axis is to be subdivided logarithmically. Logarithmic scaling makes the
grid lines of the axis equidistant from each other, but the values between the lines are not
equal. Use this option when working with values that differ sharply from each other.
Tip
If the X axis is not displaying time as expected, manually entering the minimum and
maximum times on the Scale tab may solve the problem.
Line tab
The Line tab has options for formatting the axis line style, color, width, and transparency. It has
the same contents as the Line tab of the Data Series dialog shown in Figure 93 on page 124 but
excluding the Icon section.
Label tab
On the Label tab (Figure 103), choose whether to show or hide the labels and specify how to
handle them when they do not fit neatly in the chart. The options are described below.
Note
Problems may arise in displaying labels if the chart is too small. Avoid this by either
enlarging the chart or decreasing the font size.
Text flow
Determines how text flows in axis labels.
– Overlap – allows axis labels to overlap.
– Break – allows text breaks, enabling text to wrap into new lines in the available space.
Text Orientation
Defines the direction and orientation of label text.
Vertically stacked
Stacks characters vertically so that text is read from top to bottom.
ABCD wheel
Defines text orientation by clicking and dragging the indicator on the wheel. Orientation of
the characters “ABCD” on the wheel corresponds to the new setting.
Degrees
Shows the orientation angle of the text as determined by the ABCD wheel or by manually
entering the degrees in the spin box.
Text direction
Specifies the direction for any text that uses complex text layout (CTL). CTL is only
available if Tools > Options > Language Settings > Languages > Default Languages
for Documents > Complex text layout is enabled.
Numbers
Use the Numbers tab (Figure 104) to set the attributes for any numbers used on the axis. When
Source format is selected (as it is by default), numbers are formatted exactly as they are
formatted on the spreadsheet. Deselect this option to change number formatting. For information
about formatting numbers, see Chapter 2, Entering, Editing, and Formatting Data, as well as the
online Help.
Asian Typography
Sets the Asian typographic options for axis labels. This tab is the same as that for specifying
Asian typographic options for cells. See Chapter 2, Entering, Editing, and Formatting Data for
more information.
Data labels
Data labels display information next to data points on the chart. They can be quite useful for
highlighting specific data when presenting detailed information, but be careful not to create a
chart that is too cluttered to read easily.
Note
If no data series is selected, then all data series on the chart will be labeled.
3) To open the Data Labels dialog (Figure 107), do one of the following:
– Go to Insert > Data Labels on the Menu bar. If you selected a data series, Calc
displays data labels for that data series using default settings, and displays the Data
Labels dialog for the selected data series. In this case, the data labels will remain
displayed even if you press Cancel on the dialog. If no data series was selected, Calc
displays the Data Labels for all Data Series dialog (Figure 106). The controls on this
dialog are similar to those on the Data Labels tab of the Data Labels dialog, which are
described below.
– First right-click on the selected data series in the chart and select Insert Data Labels
in the context menu. Calc displays data labels with default settings. Then right-click
again and select Format Data Labels in the context menu.
– Select the intended data labels on the chart or in the Select Chart Element drop-down,
and then select Format > Format Selection on the Menu bar or press the Format
Selection icon on the Formatting toolbar.
Tip
Select a data series by clicking once on a column, bar, or other graphic
representation of the data series. Select a single data point by pausing, then clicking
again.
Most of the tabs in the Data Labels dialog are used in other dialogs and can be readily
understood or easily researched. The exception is the Data Labels tab (Figure 107), which
contains the following options:
Show value as number
Displays the numeric value of a data point. When selected, this option activates the
Number format button.
Number format
Opens the Format Number dialog, which is the same as the Numbers tab of the Format
Cells dialog discussed in Chapter 2, Entering, Editing, and Formatting Data. Deselect
Source format to activate options on the Format Number dialog.
Figure 109: Major and minor gridlines for the X and Y axes
Grids are available for all chart types with the exception of pie charts.
Note
In the Formatting toolbar, the Horizontal Grids icon and the Vertical Grids icon set
grid lines for the Y axis and X axis, respectively. This can be misleading because
both the Y axis and the X axis can be horizontal or vertical, depending on the type of
chart. Thus, for a bar chart, click the Horizontal Grids icon to control the vertical
grids.
Formatting grids
In addition to the Grids dialog shown in Figure 110, there is another dialog for formatting grids. To
open the grid formatting dialog:
Note
Use the Scale tab of the Axis dialog to specify the intervals between grid lines. This
is described in “Defining Scales” on page 128.
3D charts
Setting 3D look
Column, bar, pie, and area charts can be displayed as 3D charts. The setting to make a chart 3D
is on the first page of the Chart Wizard. If the chart has already been created, do the following to
give it a 3D look:
1) Select the chart by double-clicking on it to enter edit mode. The chart should now be
surrounded by a gray border.
2) Do one of the following:
– Go to Format > Chart Type.
– Click on the Chart Type icon on the Formatting toolbar.
– Right-click in the chart and select the Chart Type option in the context menu.
3) Select 3D Look in the Chart Type dialog.
4) Select the basic rendering scheme as Simple or Realistic from the adjacent drop-down.
Formatting 3D view
To make changes to a 3D chart, use the 3D View dialog (Figure 112).
Appearance
Use the Appearance tab of the 3D View dialog (Figure 113) to modify some aspects of the
appearance of the data in a 3D chart.
First select a rendering scheme from the Scheme drop-down list – Realistic (default) or Simple.
The scheme selected sets the options and light sources. Depending on the scheme selected, not
all options may be available. To create a custom scheme, select or deselect a combination of
Shading, Object borders, and Rounded edges.
Some hints:
• Select Shading to use the Gouraud method for rendering the surface. Otherwise, a flat
method is used. The flat method sets a single color and brightness for each polygon. The
edges are visible but soft gradients and spotlights are not possible. The Gouraud method
applies gradients for a smoother, more realistic look. See the Draw Guide for more
information on the use of shading.
• Select Object borders to draw lines along the edges.
• Select Rounded edges to smooth the edges of box shapes.
Illumination
Use the Illumination tab (Figure 114) of the 3D View dialog to control light sources for the 3D
view.
Here are the options with some hints:
• Click any of the eight buttons to switch a directed light source on or off.
• The first light source projects a specular light with highlights.
• By default, the second light source is switched on. It is the first of seven normal, uniform
light sources.
• For the selected light source, select a color from the first drop-down list below the eight
light source buttons. Alternatively press the adjacent button to select a color using the
Pick a Color dialog. Note that the brightness values of all lights are added together, so
use dark colors when enabling multiple lights.
• The small preview in the dialog shows the effect of repositioning the light source.
• Each selected light source appears as a small colored sphere in the specified color. The
sphere is larger when the light source is actively selected.
• Each light source always points at the middle of the object initially. Move the vertical
slider to adjust the lighting angle. The horizontal slider rotates the light around the object.
In addition, click the light source and drag it to the desired location.
• Click the button in the bottom right corner of the preview to switch the internal illumination
model between a sphere and a cuboid.
• Use the Ambient light drop-down list to define the ambient light, which shines with a
uniform intensity from all directions. Alternatively press the adjacent button to select a
color using the Pick a Color dialog.
See the Draw Guide for more information on setting the illumination.
Note
For chart types that use categories for the X axis, such as column, bar, or line charts,
the numbers 1, 2, 3… are used as values for calculating trend lines. By contrast, XY
(scatter) chart types show data rather than categories along the X axis. Thus, only XY
(scatter) chart types can show meaningful regression equations.
Regression types
By default, x is used for the abscissa variable and f(x) for the ordinate variable. Change the
names under X Variable Name and Y Variable Name on the Trend Line dialog.
Linear trend line
Regression through equation y = a ∙ x+b. Intercept b can be forced.
Polynomial trend line
Regression through equation y = Σi (ai ∙ xi). Intercept a0 can be forced. Degree of
polynomial must be given (at least 2).
Logarithmic trend line
Regression through equation y = a ∙ ln(x) + b. Only positive x values are used.
Exponential trend line
Regression through equation y = b ∙ exp(a ∙ x).This equation is equivalent to y = b ∙ mx, with
m = exp(a). Intercept b can be forced. Only positive y values are considered, except if all y
values are negative. In that case, the equation used is y = -b∙exp(a ∙ x).
Power trend line
Regression through equation y = b ∙ xa. Only positive x values are considered. Only positive
y values are considered, except if all y values are negative. In that case, the equation used
is y = -b ∙ xa.
Moving Average trend line
Simple moving average for n previous y-values, with n being the period. No equation is
available for this trend line.
Search for the term “Trend Lines” in the index of the Help system for more information about
these regression types.
Select a trend line to display information about it in the Status bar, as shown in Figure 117. The
Status bar is normally located at the bottom of the spreadsheet.
Tip
To place arrows, text, or other drawing objects in a chart, be sure that the chart is in
edit mode. Otherwise, an object will not be connected to the chart and will not be
moved with it.
Note
If you draw a line in the spreadsheet (outside any chart), you can hold down Shift
while dragging to constrain angles of the line to multiples of 45 degrees. This facility
is not applicable when inserting a line on a chart.
Write on the line by double-clicking the line and typing or pasting text. If the text is too low,
press Enter to raise it above the line.
Insert Text Box
Draws a text box with horizontal text direction. To place the text at an angle, click once on
the text box to select it, right-click, and select Position and Size from the context menu.
Specify the angle on the Rotation tab.
Figure 123: Tool palettes that can be opened from the Drawing toolbar
Changing interactively
Resizing
To resize a chart interactively:
1) Click once on the chart to select it. Square selection handles appear around the border of
the chart.
2) Click and drag one of the selection handles. The cursor indicates the direction to increase
or decrease the chart size. Clicking and dragging a corner handle preserves the
horizontal to vertical size ratio.
Moving
Move a chart interactively using one of two methods:
For small moves
1) Click once on the chart to select it. Square selection handles appear around the border of
the chart.
2) Press an arrow key to move the chart a few pixels at a time, or press Alt + an arrow key
to move the chart one pixel at a time.
3) When finished, click outside the chart to leave selection mode.
For larger moves
1) Click once on the chart to select it. Square selection handles appear around the border of
the chart.
2) Hover the cursor anywhere over the chart until it changes to a move cursor (shape
depends on computer setup).
3) Click and drag the chart to its new location.
4) Release the mouse button when the chart is in the required position.
5) When finished, click outside the chart to leave selection mode.
Note
In addition to charts, the Position and Size dialog can also be used to modify and
position other graphic elements, such as those available on the Drawing toolbar.
Rotation
The options for the Rotation tab (Figure 125) are as follows:
Figure 126: Position and Size dialog – Slant and Corner Radius
tab
To Foreground/To Background
Places charts or stacks of objects in either the foreground or the background. In Calc,
objects in the background are behind the cell grid and may be difficult to select. Use the
Select tool (arrow icon) on the Drawing toolbar (Figure 122) to select them.
Line Style/Line Width/Line Color
Formats the outer borders of charts.
Note
A copied chart links to or retains its data only when pasted into a LibreOffice
document. To retain data or links outside LibreOffice, use embedding or linking, as
explained in Chapter 10, Linking Data.
Figure 128: Data Table dialog when a chart is copied into another
document
Note
Calc does not provide a direct way to save chart settings for creating another chart in
LibreOffice. Here are three options for using the same chart settings: 1) copy and
paste the chart into another file; 2) save the file containing the chart as a new file;
and 3) save the chart in a template. Depending on the method used, create a new
chart by modifying either the data range or the data table.
Column charts
A column chart shows vertical bars, with the height of each bar proportional to its value. The X
axis shows categories and the Y axis shows the value for each category.
Column charts are commonly used for data that show trends over time. They are best for a
relatively small number of data points. It is the default chart type provided by Calc, as it is one of
the most useful and easy to understand. For a larger time series, a line chart would be more
appropriate.
The column chart type has three variants, with a preview pane for each variant as shown in
Figure 129.
Bar charts
A bar chart is like a column chart that has been shifted 90 degrees. It shows horizontal bars
rather than vertical columns. In contrast to some other chart types, the Y axis is horizontal and
the X axis is vertical. The Chart Type dialog for a bar chart is essentially the same as for a
column chart, which was described above, with the previews modified to show horizontal bars.
Bar charts can have an immediate visual impact when time is not an important factor — for
example, when comparing the popularity of a few products in a marketplace. They may be
preferred to column charts when the category names are long or there are a significant number
of categories.
In the examples in Figure 130 below:
• To make the first chart, after using the Chart Wizard enter the edit mode and go to Insert
> Grids, deselect Y axis, and choose Insert > Mean Value Lines. Right-click each
mean value line and select Format Mean Value Line to increase the width of the lines.
Create rectangles from the Drawing toolbar to cover the mean value line entries in the
legend. Make them white by right-clicking and selecting Line and then Area.
• The second chart is a 3D chart created with a simple border and cylinder shape. The
chart area is rotated (described under “Rotation and perspective” on page 141).
• The third chart eliminates the legend by using labels with the names of the companies on
the Y axis. Whereas the first two charts treat the data as separate data series, this chart
treats the data as one data series in order to have category labels for the X axis. Rather
than colors, a colored hatch pattern is used for the bars.
Line charts
A line chart is useful for showing trends or changes over time when you want to emphasize
continuity. Values are shown as points on the Y axis and the X axis shows categories—often time
series data. The Y values of each data series may be connected by a line.
Note
The difference between line charts, described in this section, and XY (scatter) charts,
described in the next section, is this: line charts show categories along the X axis
while XY (scatter) charts show values along the X axis.
Scatter or XY charts
In contrast to line, column, and bar charts, which contain numeric values on the Y axis and
categories on the X axis, scatter or XY charts contain values along both axes. They are quite
useful, especially for understanding relationships among data that are precise and complex. An
XY chart may contain more than one data series and can perform many tasks, such as
generating a parameter curve or drawing the graph of a function.
Tip
When plotting time on the X axis, make sure that it is not text and is written in the
correct format for your locale. For example, instead of January, use a format such as
1/1/2022. Check locale formats at Tools > Options> Language Settings >
Languages > Date acceptance patterns.
XY charts are most frequently used to explore the statistical associations among quantitative
variables. There is often a constant value against which to compare the data — for example,
weather data, reactions under different acidity levels, or conditions at various altitudes.
XY chart variants
Bubble charts
A bubble chart is a variation of a scatter chart that can show three variables in two dimensions.
The data points are shown with bubbles. Two variables are plotted along the X and Y axes, while
the third variable is represented by the relative size of the bubbles. These charts are often used
to present financial data or social/demographic data.
One or more data series can be included in a single chart. The data series dialog for a bubble
chart has an entry to define the data range that determines the size of the bubbles.
It may be necessary to build a bubble chart manually in the data series page of the Chart Wizard.
Figure 143 shows how the data ranges can be set for a bubble chart.
Net charts
Net charts are also known as spider, polar, or radar charts. They display data values as points on
radial spokes, with each spoke representing a variable. They compare data that are not time
series, but show different circumstances, such as variables in a scientific experiment. They are
especially useful for displaying clusters and outliers.
Figure 145 shows an example of a simple net chart. The radial spokes of the net chart are
equivalent to the Y-axes of other charts. All data values are shown with the same scale, so all
data values should have about the same magnitude.
Figure 147: Filled net chart and net chart with 3D data point icons
Stock charts
A stock chart illustrates the market trends for stock and shares by giving opening price, bottom
price, top price, and closing price. The transaction volume can also be shown and the X axis
usually represents a time series.
When setting up a stock chart in the Chart Wizard, the data should be arranged as shown in
Figure 148. It specifies which columns should be the opening, low, high, and closing prices of the
stock as well as the transaction volume. However, manual adjustments may still be needed when
defining the data series.
Figure 151: Stock chart variant 2 showing low and high prices as well as the
range between opening and closing prices
Stock Chart 3
Using the low, high, and close columns, draws a chart similar to Stock Chart 1 but with
additional columns for transaction volume. As shown in Figure 152, a secondary Y axis
enables both transaction volume and price to be shown on vertical axes.
Note
Variants 3 and 4 automatically align data to the secondary Y axis. For more
information about a secondary Y axis, see “Aligning data to secondary Y axis” on
page 121.
Stock Chart 4
Based on all five data columns (volume, open, low, high, and close), this variant combines
Stock Chart 2 with a column chart for the transaction volume (Figure 153).
Figure 153: Stock chart variant 4 showing opening, low, high, and closing prices as
well as transaction volumes.
Pivot charts
Pivot tables are special types of data tables that simplify the manipulation and analysis of data.
They are widely used, especially for processing large amounts of data. Pivot charts are based on
pivot tables and are created by selecting Insert > Chart, or clicking the Insert Chart icon in the
Standard toolbar, after left-clicking a cell inside a pivot table. Pivot charts inherit many properties
of the other chart types described in this chapter but also have other characteristics that are
described in Chapter 8, Using Pivot Tables.
Chapter 4
Using Styles and Templates
Using consistent formatting in spreadsheets
What are styles? Why use them?
A style is a set of formats that you can apply to selected elements in a document to quickly
change their appearance. Applying a style often means applying a group of formats at the same
time.
Many people manually format spreadsheet cells and pages without paying any attention to styles
and are accustomed to formatting documents according to physical attributes. For example, for
the contents of a cell you might specify the font family, font size, and any character formatting
such as bold, italic, or underline.
Using styles means that you stop applying attributes and characteristics individually (for example,
font size 14 pt, Times New Roman, bold, centered) and start using a style, for example Title.
Applying attributes and characteristics is time-consuming and prone to errors. In contrast, using a
style, which has been defined to include the attributes and characteristics you want, will save you
time and give greater consistency in formatting.
Styles also make major formatting changes easy. For example, you may decide to change the
appearance of all subtotals in a spreadsheet to be 10 pt Arial instead of 8 pt Times New Roman
after you have created a 15-page spreadsheet. Assuming that you have formatted all subtotals
with a specific style, you can change all of the subtotals in the document by simply changing the
properties of that style.
In addition, Calc also provides page styles, as described below.
You can modify the attributes of the supplied styles and define as many new styles as you
require. Creating, modifying, and accessing styles is explained in the following sections.
Cell styles
Cell styles are similar to paragraph styles used in LibreOffice Writer. They are the most basic
type of style in Calc. Cell styles are used for applying fonts, alignment, borders, background,
number formats (for example, currency, date, number), and cell protection to format the data in
the cells.
A basic range of cell styles is supplied with Calc. Many of these styles are shown on the Styles
menu on the Menu bar and all are shown in the Styles deck of the Sidebar. If you create a new
cell style, it will be shown in the Sidebar. To add it to the Styles menu, see Chapter 14, Setting
up and Customizing, for instructions.
Initially, the basic styles are configured so that if you change the characteristics of the Default
Cell Style cell style, then all of the other styles, inheriting from it, will change to match.
Styles menu
By default, the Styles menu (Figure 156) lists many of the cell styles supplied with Calc. To apply
a cell style, select the cell or group of cells to be formatted, and then choose Styles and click on
the required style.
Figure 158: Adding the Apply Style list to the Formatting toolbar
To apply a style using the Apply Style list:
1) Select a cell or a group of cells in the spreadsheet.
2) Click the down arrow at the right of the Apply Style list to open the drop-down menu
(Figure 159).
3) Select the required style. The formatting attributes of that style are applied to the selected
cells.
Keyboard shortcuts
You can create keyboard shortcuts to apply commonly-used cell or page styles, including any
custom styles that you have created. See Chapter 14, Setting up and Customizing, for more
information.
Note
Any new (custom) styles, and any changes to existing styles, apply only to the
spreadsheet in use. To save new styles in a template, see “Creating a template” on
page 198 for more information.
Note
Style names are case sensitive. You can define, for example, a style called red and
another style called Red. Make sure all style names are sufficiently different to
prevent any confusion.
Organizer tab
• Name – displays the name of the selected style. If you are creating or modifying a
custom style, enter a name for the style. You cannot change the name of a predefined
style.
• Inherit from – you can choose to link the new style to an existing style and then modify
some of the attributes. If you do this, any change to the parent style’s attributes will affect
Numbers tab
• Category – select a category from the list.
• Format – select how you want the contents of the selected cell(s) to be displayed.
When you select Currency as a category, you need to select a currency from the drop-
down list and then select the format to use from the options available for that currency.
The currency format is not dependent on the language that you select in the Language
box. The default currency format for a cell is determined by the regional settings of your
operating system.
• Language – specifies the language settings for the selected cells. With the language set
to the default, Calc automatically applies the number formats associated with the system
default language. The language setting ensures that date and currency formats are
preserved even when the document is opened in an operating system that uses a
different default language setting.
• Options – specify the options for the selected format:
– Decimal places – enter the number of decimal places that you want to display.
– Leading zeroes – enter the maximum number of zeroes to display in front of the
decimal point.
– Negative numbers red – select to change the font color of negative numbers to red.
– Thousands separator – select to insert a separator between thousands. The type of
separator (for example, a comma or a space) depends on your language settings.
• Format code – displays the number format code for the selected format. You can also
enter a custom format.
Font tab
Depending on your language settings, you can change the formatting for the following font types
on this tab – Western text font (Latin character sets), Asian text font (Chinese, Japanese, or
Korean character sets), and Complex text layout font (right-to-left text direction). Figure 163
shows the Font tab of the Cell Style dialog when the Asian and Complex text layout options are
selected in the Default Languages for Documents area of the Tools > Options > Language
Settings > Languages page. The layout of the Font and Font Effects tabs are modified if either
of these two options is deselected.
• Font – select an installed font from the list.
• Style – select the formatting you want to apply, for example bold, Italic, or underline.
• Size – select or enter the font size that you want to apply. For scalable fonts, you can
also enter decimal values. If you are creating a style that is based on another style, you
can enter a percentage value or a point value (for example, 2 pt or 5 pt).
Alignment tab
• Text Alignment – sets the alignment options for the contents of the current cell, or the
selected cells.
Background tab
Click Color to select a color to use as a background for the formatted cells. You can choose from
several palettes. To change the color, select another one. To remove the background color, select
None.
Organizer tab
This tab is similar to the Organizer tab for the Cell Style dialog, although page styles cannot
inherit settings from other styles.
• Name – displays the name of the selected style. If you are creating or modifying a
custom style, you can enter or change the name of the style. You cannot change the
name of a predefined style.
• Category – displays the category of the current style. If you are creating or modifying a
new style, select Custom Styles from the list. You cannot change the category for a
predefined style.
• Contains – describes the formatting used in the style.
Page tab
You can define page layouts for single and multiple-page spreadsheets, as well as page
numbering and paper formats.
• Paper Format – select from a list of predefined paper sizes, or define a custom paper
format.
– Format – select a predefined paper size, or create a custom format by entering the
dimensions for the paper in the Height and Width boxes.
– Width – displays the width of the selected paper format. To define a custom (user)
format, enter a width here.
– Height – displays the height of the selected paper format. To define a custom (user)
format, enter a height here.
– Orientation:
– Portrait – displays and prints the spreadsheet with the paper oriented vertically.
– Landscape – displays and prints the spreadsheet with the paper oriented
horizontally.
– Text direction – select the text direction that you want to use in your document. The
"right-to-left (vertical)" text flow direction rotates all layout settings to the right by 90
degrees, except for the header and footer. This option is only available if Complex
text layout is selected at Tools > Options > Language Settings > Languages.
– Preview Field – displays a preview of the current selection.
Sheet tab
Specifies the elements to be included in the printout of all sheets with the page style. Additionally,
you can set the print order, the first page number, and the page scale. See Chapter 6, Printing,
Exporting, E-mailing, and Signing for details.
Managing styles
Modifying styles
1) Go to the Styles deck in the Sidebar and click the icon for the type of style you want to
modify.
2) Right-click on the name of the style and select Modify in the context menu to open either
the Cell Style dialog (Figure 161) or the Page Style dialog (Figure 170).
Note
The Modify command is unavailable if one or more sheets are protected, even if the
cell style to be modified is being used in an unprotected sheet.
Renaming styles
You can rename custom styles, but not the styles supplied with Calc.
1) Go to the Styles panel in the Sidebar (Figure 157) and click the icon for the type of style
you want to rename.
2) Right-click on the style you want to rename and select Modify from the context menu to
open either the Cell Styles dialog or the Page Styles dialog.
3) On the Organizer tab, rename the style, and click OK.
Deleting styles
You can delete custom styles, but not the styles supplied with Calc. Custom cell styles can only
be deleted if they are not applied. If an applied page style is deleted, affected sheets revert to the
Default Page Style.
1) Go to the Styles deck in the Sidebar (Figure 157) and click the icon for the type of style
you want to delete.
2) Right-click on the style you want to delete and select Delete from the context menu.
3) Select Yes on the warning message, if displayed.
Creating a template
You can easily create a template from any spreadsheet:
1) Open a new or existing spreadsheet that you want to use as a base for the template.
2) Add any necessary pre-defined content that you want to appear in a spreadsheet each
time you use the new template, for example company logo and name, company
information, page numbers, and so on. Delete any information that you do not want in the
template.
3) Create or modify the cell and page styles that you want to use in the template.
4) On the Menu bar, choose File > Templates > Save as Template, or click the down arrow
at the right of the Save button on the Standard toolbar and select Save as Template, or
press Shift+F11. The Save As Template dialog (Figure 172) opens, displaying the existing
template categories and a name box.
5) Type a name for the new template and select the required template category. You can
also choose to make this the default template (see “Setting the default template” on page
201 for more information).
6) Click Save to save the new template.
Note
Although the Save as Template dialog shows no document type when saving a new
template of any type, the template will appear on the correct tab (Spreadsheets, in
this case) when you return to the Templates dialog.
It is unnecessary to save or do anything further with the spreadsheet file you have
been using to create the new template. It can be safely closed without saving.
Note
You can also save a template through the Save As dialog, accessed by a variety of
interactions including selecting File > Save As on the Menu bar or pressing
Ctrl+Shift+S. Select the ODF Spreadsheet Template option in the Save as type
menu.
Editing a template
You can edit a template’s styles and content. If you wish, you can then apply the new styles to
spreadsheets that were created from the original template (see below for details).
To edit a template:
1) On the Menu bar, choose File > Templates > Manage Templates, or press Ctrl+Shift+N,
to open the Templates dialog.
2) Navigate to the spreadsheet template that you want to edit. Right-click to open the
context menu and choose Edit (see Figure 173). The template opens in Calc.
3) Edit the template as you would edit any other spreadsheet. To save the changes, choose
File > Save in the Menu bar or perform any equivalent action. To save the edited template
as a new template, choose File > Save As Template or perform any equivalent action.
Caution
If you select Keep Old Styles, the confirmation message will not appear again the
next time you open the spreadsheet using the same changed template. Although the
template is still listed under File > Properties > General, the spreadsheet is no
longer connected to the template, so it will not update. You can still import styles
manually from the template, but to reconnect the spreadsheet to the template, you
will have to copy it into an empty document based on the template.
Tip
You can manually copy new templates into the template folders. The location varies
with your computer’s operating system. To learn where the template folders are
stored on your computer, go to Tools > Options > LibreOffice > Paths.
Tip
Some extensions are packaged as .ZIP files.
Note
Resetting the default template back to the Calc default template is only available if
the default has been changed previously.
Organizing templates
LibreOffice can only manage templates that are in its template folders (categories), although you
can create a spreadsheet from a template that is not in one of these folders. You can create new
template folders and use them to organize your templates and import templates into these
folders. For example, you might have one template folder for sales templates and another for
invoice templates. You can also export templates.
To begin, choose File > Templates > Manage Templates, or press Ctrl+Shift+N, to open the
Templates dialog.
Note
You cannot create a sub-category inside a template category.
Moving a template
To move a template from one template category to another:
1) Open the Templates dialog and select the template you want to move.
2) Click the Move icon near the bottom of the dialog, select the destination category from
the popup dialog (Figure 177), and click OK. The selected template is moved to the
folder. You can also create a new category into which to move the template.
Deleting a template
You cannot delete templates supplied with LibreOffice. Nor can you delete any templates
installed by the Extension Manager except by removing the extension that installed them. You
can only delete templates that you have created or imported.
1) In the Filter drop-down lists at the top of the Templates dialog, select the category that
contains the template you want to delete.
2) Right-click on the template that you want to delete to open the context menu and click
Delete (Figure 173).
3) A message box appears and asks you to confirm the deletion. Click Yes.
Note
Moving or deleting a template has no impact on any document that was created from
that template. The spreadsheet will retain the style definitions that it inherited from
the moved / deleted template. The Template tellback on the File > Properties >
General page can continue to show the name of a template that no longer exists.
Exporting a template
The easiest way to send a template to someone else, or to store it on a network, is to export it:
1) Open the Templates dialog and find the template that you want to export.
2) Select the template and click the Export icon.
3) The Select Folder dialog opens. Navigate to the location where you want to export the
template and click Select Folder. You can also rename the template.
Note
Exporting a template does not remove it from the Templates dialog. The action
places a copy of the template in the location you specify.
Chapter 5
Using Graphics
Introduction
Calc is used to present and analyze data and to make forecasts and predictions. Graphics can
turn an average spreadsheet into a more memorable document. Calc can import various vector
(line drawing) and raster (bitmap or photo) file formats. Commonly used graphic formats include
GIF, JPG, and PNG. See the LibreOffice Help for a full list of the formats that Calc can import.
Graphics in Calc are of three basic types:
• Image files, such as photographs, drawings, and scanned images
• Diagrams created using LibreOffice’s drawing tools
• Charts and graphs created using LibreOffice’s Chart facility; see Chapter 3, Creating
Charts and Graphs, for more information
Using graphics in Calc is similar to using graphics in other components of LibreOffice. For more
detailed descriptions, please refer to the Getting Started Guide or the Draw Guide.
Note
In LibreOffice, the terms graphics and images refer to both pictures and drawing
objects. Often the word images is used when referring to pictures and other graphics
that are not drawing objects.
Note
Going from embedded to linked images is not so easy. You must replace them one at
a time, selecting the Insert as Link option when you reinsert each file.
Tip
If you wish to use gallery images from earlier versions of LibreOffice, go to
https://extensions.libreoffice.org/ and search for items with a tag filter of “Gallery”.
Modifying images
When you insert a new image, you may need to modify it to suit the document. Any changes
made in Calc do not affect the original image, whether it is an embedded or a linked image file.
Calc provides several tools for working with images. These tools are sufficient for most
requirements. However, for professional results it is generally better to use Draw or other
software designed to modify image files, and then insert the result into Calc.
Note
Changes to image properties affect only the display and printing of the image. The
original image file remains unchanged.
• Anchor – choose between anchoring the image to a cell (with or without resize) or to a
page. See “Anchoring images” on page 214.
• Align – if two or more images are selected, you can adjust the horizontal and vertical
alignment of the images in relation to each other. See “Aligning images” on page 214.
• Six buttons for arrangement (positioning images in the stacking order): Bring to Front,
Forward One, Back One, Send to Back, To Foreground, To Background. See
“Arranging images” on page 214.
• Line Style, Line Width, Line Color – set the attributes of the border around the image.
• Area Style / Filling – sets the color or other characteristics of the background area that
contains the image, not the image itself. To see the background, you must set the
transparency of the image to a suitably high value. See the Draw Guide for more
information on how to modify areas.
• Shadow – sets the default shadow effect around the image. To adjust the shadow effect,
open the Area dialog (Format > Object > Area) and choose the Shadow tab.
• Filter – opens the Image Filter toolbar. See the Draw Guide for details on image filters.
Figure 182:
Color toolbar
Adding text
You can add text to an image or drawing object. That text will move with the image when the
image is repositioned. For more information on adding text to images, see the Draw Guide.
1) Double-click on the image. The text cursor flashes in the center of the image. The Text
Formatting toolbar automatically opens at the top of the spreadsheet.
Tip
To retain the original proportions of the image, click and drag one of the corner
handles. If you want to change the original proportions, Shift+Click one of the corner
handles, then drag.
Figure 185: Position and Size dialog – Position and Size tab
Anchoring images
Anchor images so they stay in their position in relation to other items.
• To Page – anchor an image to the page to position it in a specific place. The image does
not move when cells are added or deleted; it will always stay in the same position on the
page where it is placed.
• To Cell – anchor an image to a cell to ensure that the image always stays with the
content it is originally anchored to. If an image is anchored to cell B10, and a new row is
inserted above row 10, the image will then be anchored to cell B11.
• To Cell (resize with cell) – similar to To Cell but with the additional property that the
image resizes as you resize the cell to which it is anchored.
To anchor a selected image or change the type of anchor used:
• Go to Format > Anchor on the Menu bar, or right-click on the image and select Anchor
in the context menu, or click on the Anchor icon on the Image toolbar.
• Select To Page, To Cell, or To Cell (resize with cell) in the menu.
Aligning images
When you have more than one image in your spreadsheet, you can align these images to give
your spreadsheet a more professional look. The options include three for aligning the images
horizontally (left, centered, right) and three for aligning the images vertically (top, center, bottom).
1) Select all of the images to be aligned (select one and hold down the Shift key while
selecting others).
Tip
Press the main area of the Align icon on the Image toolbar (to the left of its down
arrow) to quickly left align the selected images.
Drawing toolbar
To begin using the drawing tools, go to View > Toolbars > Drawing to open the Drawing toolbar,
which appears in its default position at the bottom of the spreadsheet. You can make this toolbar
a floating toolbar and move it to a more convenient position.
When the Drawing toolbar opens, it displays a default set of tools as shown in Figure 186. Hover
the mouse pointer over a tool to see a tooltip describing its function. Icons with small arrows on
the right side open with palettes of tools. To add tools to the Drawing toolbar, right-click in an
empty area on the toolbar and select Visible Buttons in the context menu.
Figure 187: Drawing Object Properties toolbar – controls available for setting
default properties
3) After you draw an object or group it with another object, more properties become active.
These appear on the toolbar (Figure 188) and some are shown in the Properties deck of
the Sidebar (Figure 189).
Using Fontwork
With Fontwork, you can create graphical text art objects to make your work more attractive.
There are many different settings for text art objects (line, area, position, size, and more), so you
have a large choice.
Fontwork is available with each component of LibreOffice, but you will notice small differences in
the way that each component displays it.
Chapter 6
Printing, Exporting,
E-mailing, and Signing
Printing
Quick printing
To quickly print a spreadsheet, click on the Print Directly icon on the Standard toolbar to send
the entire spreadsheet to the default printer that is defined for your computer.
Note
You can change the action of the Print Directly icon to send a document to the
printer defined for the document instead of the default printer for the computer. Go to
Tools > Options > Load/Save > General and select the Load printer settings with
the document option.
Tip
The initial default when you first install LibreOffice is for the Print Directly icon not to
appear on Calc’s Standard toolbar. However, you can enable its display by following
the instructions given in Chapter 14, Setting up and Customizing.
Controlling printing
For more control over printing, select File > Print on the Menu bar, or click the Print icon on the
Standard toolbar, or press Ctrl+P, to open the Print dialog (Figure 193).
Note
The options selected on the Print dialog apply to this printing of this document only.
To specify default printing settings for LibreOffice, go to Tools > Options >
LibreOffice > Print and Tools > Options > LibreOffice Calc > Print. For details,
see Chapter 14, Setting up and Customizing Calc.
The Print dialog has multiple tabs where you can choose a range of options, as described in the
following sections. Depending on your computer’s operating system, the number of tabs and the
layout of each tab may be different from the illustrations shown in this chapter. On some
installations, a More Options button is provided in the Print dialog.
The Print dialog includes a Preview checkbox which enables you to turn on/off a preview of how
your data will appear on the printed page. The preview appears on the left hand side of the
dialog. Adjacent controls allow you to navigate through multiple pages.
General tab
On the General tab of the Print dialog (Figure 193), you can choose from the following options:
• Printer
– Select the printer to use, from the list of those available.
– Press the Properties button to change any required settings of the selected printer.
The options available through this interaction will depend on your printer and system.
• Range and Copies
– Select which sheets and pages to print; single or double sided printing; the number of
copies to print; whether to collate multiple copies; and the page order for printing.
(See “Selecting what to print” on page 223.)
Tip
To access some of the options on the General tab of the Print dialog, you may need
to click one of the more options. For simplicity, these clicks are deliberately omitted
from the descriptions in this chapter.
Note
Some color printers may print in color regardless of the settings you choose.
For an individual file, you can change the printer settings to print in black and white or grayscale:
1) Choose File > Print on the Menu bar, or click the Print icon on the Standard toolbar, or
press Ctrl+P, to open the Print dialog.
2) Click Properties to open the Properties dialog for the printer. The available choices vary
from one printer to another, but you should find options for the color settings. See your
printer’s help or user manual for more information.
3) The choices for color might include black and white, or grayscale. Choose grayscale.
4) Click OK to confirm your choice and return to the Print dialog.
5) Click Print to print the document.
You can change the LibreOffice settings to print all color text and graphics as grayscale:
1) Choose Tools > Options > LibreOffice > Print.
2) Select Convert colors to grayscale. Click OK to save the change.
Tip
You can check the print range by using Toggle Print Preview or the Preview pane in
the Print dialog. Calc will display only the cells in the print range. See “Viewing print
ranges” on page 226.
Page breaks
While defining a print range can be a powerful tool, you may sometimes need to manually adjust
the page breaks to make sure the spreadsheet prints the way you want it to look. You can insert
two types of page breaks into a spreadsheet:
Note
The Column Break or Row Break options are grayed if an appropriate cell has not
been selected, either to the right of a column break or below a row break.
Tip
You can also open the Page Style dialog by going to the Styles deck of the Sidebar,
right-clicking the relevant page style, and selecting Modify in the context menu.
Another alternative is to double-click the name of the page style in the Status Bar.
• Page Order – defines the order in which data in a sheet is numbered and printed when it
does not fit on one printed page. A preview of the page order is shown in the graphic on
the top right of the dialog in Figure 205.
– Top to bottom, then right – prints vertically from the left column to the bottom of the
sheet.
– Left to right, then down – prints horizontally from the top row of the sheet to the right
column.
– First page number – select this option if you want the first page to start with a
number other than 1. Enter the number of the first page in the box.
• Print – defines which elements of the spreadsheet are to be printed.
– Column and row headers – prints the column and row headers.
Exporting to PDF
Calc can export documents to PDF (Portable Document Format). This industry-standard file
format is ideal for sending a file to someone else, for viewing using Adobe Acrobat Reader or any
other PDF viewer.
Caution
By default, a document in PDF format is not protected against contents tampering or
editing. The PDF document contents can be edited by specialized software tools,
including LibreOffice Draw.
Tip
Unlike Save As, the Export command writes a copy of the current document in a
new file with the chosen format, but keeps the current document and format open in
your session.
Tip
You can also access the PDF Options dialog by going to File > Export on the Menu
bar and then then selecting the PDF - Portable Document Format entry in the Save
as type drop-down menu.
• Tagged PDF: Tagged PDF contains information about the structure of the document’s
contents. This can help to display the document on devices with different screens, and
when using screen reader software. Some tags that are exported are table of contents,
hyperlinks, and controls. This option can increase file sizes significantly.
• Create PDF form – Submit format: Use the drop-down menu to choose the format of
submitting forms from within the PDF file (FDF, PDF, HTML, or XML).
• Allow duplicate field names – If enabled, the same field name can be used for multiple
fields in the generated PDF file. If disabled, field names will be exported using generated
unique names.
• Export bookmarks: Generally not used in Calc.
• Comments as PDF annotations: Exports comments as PDF notes. You may not want
this!
• Whole Sheet Export: The setting allows you to export your Calc spreadsheet to PDF,
with the content of a sheet exported as one page in the PDF. This facility is not intended
for printing but allows you to easily see and review the full content of a spreadsheet
document in a PDF form, without the usual slicing of the sheets into printable pages.
Preview pages will have different sizes, as do the source sheets.
Note:
Selecting the Whole Sheet Export option causes Calc to disregard many of the
other settings on the PDF Options dialog.
Note
Bookmarks are generally not used in Calc.
Note
Permissions settings are effective only if the user’s PDF viewer respects the settings.
• Use this certificate to digitally sign PDF documents: Click Select to open the Select
Certificate dialog, where all certificates found in your selected key store are displayed. If
the key store is protected by a password, you are prompted for it. When using a
smartcard that is protected by a PIN, you are also prompted for that.
Select the certificate to use for digitally signing the exported PDF, then click Select.
All other fields on the Digital Signatures tab are accessible only after a certificate has
been selected.
E-mailing spreadsheets
LibreOffice provides several ways to send documents quickly and easily as an e-mail attachment
in OpenDocument format (LibreOffice default format), other spreadsheet formats, or as a PDF
file. You can also email a document to several recipients. For more information, see the Getting
Started Guide.
To send the spreadsheet as an email:
1) Go to File > Send on the Menu bar and select from the following options. LibreOffice
opens your default e-mail program (if set) with the spreadsheet attached in the selected
format.
– Email Document: the spreadsheet is sent in its current format.
– E-mail as OpenDocument Spreadsheet: the spreadsheet is sent in the ODF format
(.ods).
– E-mail as Microsoft Excel: the spreadsheet is sent in the Excel format (.xlsx).
– E-mail as PDF: The PDF Options dialog opens. Select the parameters to be used for
the PDF file. See “Controlling PDF content and quality” on page 236.
2) In your e-mail program, enter the recipient, subject, and any text you want to add, then
send the e-mail.
Note
If you make any changes to the document after digitally signing, the digital signature
is removed automatically and you have to repeat the above procedure to digitally
sign it again.
Chapter 7
Using Formulas and
Functions
Introduction
In previous chapters, we have been entering one of two basic types of data into each cell:
numbers and text. However, we will not always know what the contents should be. Often the
contents of one cell depends on the contents of other cells. To handle this situation, we use a
third type of data: the formula. Formulas are equations using numbers and variables to get a
result. In a spreadsheet, the variables are cell locations that hold the data needed for the
equation to be completed.
A function is a predefined calculation entered in a cell to help you analyze or manipulate data. All
you have to do is add the arguments, and the calculation is made automatically. Functions help
you create the formulas needed to get the results that you are looking for.
Setting up a spreadsheet
If you are setting up more than a simple one-sheet system in Calc, it is worth planning ahead a
little. Make sure to:
• Avoid typing fixed values into formulas
• Include documentation (notes and comments) describing what the system does,
including what input is required and where the formulas come from (if not created from
scratch)
• Incorporate a system of error-checking of formulas to verify that the formulas do what is
intended
Lack of documentation
Lack of documentation is a very common point of failure. Many users prepare a simple sheet
which then develops into something much more complicated over time. Without documentation,
the original purpose and methodology is often unclear and difficult to decipher. In this case it is
usually easier to start again from the beginning, wasting the work done previously. If you insert
comments in cells, and use labels and headings, a spreadsheet can later be modified by you or
others and much time and effort will be saved.
Error-checking formulas
Adding up columns of data or selections of cells from a sheet often results in errors due to
omitting cells, wrongly specifying a range, or double-counting cells. It is useful to institute checks
in your spreadsheets. For example, set up a spreadsheet to calculate columns of figures, and
use SUM to calculate the individual column totals. You can check the result by including (in a
non-printing column) a set of row totals and adding these together. The two values—row total
and column total—must agree. If they do not, you have an error somewhere.
Creating formulas
You can enter formulas in two ways. One method is to use the Function Wizard or the equivalent
facilities in the Functions deck of the Sidebar. The second method is to type directly into the cell
or into the Input line. A formula must begin with an = symbol. When typing directly, you normally
need to start a formula with =. However, if your formula begins with a + or – (for example -2*A1),
then Calc automatically adds the = symbol. An = is not added if you simply enter a positive or
negative number (such as -2 or +3). Starting with anything else causes your intended formula to
be treated as if it were text.
Operators in formulas
Each cell in the sheet can be used as a data holder or a place for data calculations. To enter
data, simply type in the cell and move to the next cell or press Enter. With formulas, the equals
sign indicates that the cell will be used for a calculation. An example of a mathematical
calculation like 15 + 46 is shown in Figure 218.
While the calculation on the left used only one cell, the real power is shown on the right where
the data is placed in cells and the calculation is performed using references to the cells. In this
case, cells B3 and B4 were the data holders, with B5 the cell where the calculation was
performed. Notice that the formula was shown as =B3+B4. The plus sign indicates that the
contents of cells B3 and B4 are to be added together and then have the result in the cell holding
the formula. All formulas build upon this concept. Other ways of using formulas are shown in
Table 5.
These cell references allow formulas to use data from anywhere in the sheet being worked on, or
from any other sheet in the document that is opened. If the data needed was in different sheets,
they would be referenced by referring to the name of the sheet, for example =$Sheet2.B12+
$Sheet3.A11.
Note
To enter the = symbol for a purpose other than creating a formula as described in
this chapter, type an apostrophe or single quotation mark before the =. For example,
in the entry '= means different things to different people, Calc treats everything after
the single quotation mark—including the = sign—as text.
Formula Description
=A1+10 Displays the contents of cell A1 plus 10.
=A1*16% Displays 16% of the contents of A1.
=A1*A2 Displays the result of multiplying the contents of A1 and A2.
=ROUND(A1,1) Displays the contents of cell A1 rounded to one decimal place.
=EFFECT(5%,12) Calculates the effective interest for 5% annual nominal interest
with 12 payments a year.
=B8-SUM(B10:B14) Calculates B8 minus the sum of the cells B10 to B14.
=SUM(B8,SUM(B10:B14) Calculates the sum of cells B10 to B14 and adds the value to B8.
)
=SUM(B1:B1048576) Sums all numbers in column B.
=AVERAGE(BloodSugar) Displays the average of a named range defined under the name
BloodSugar. It is possible to establish ranges for inclusion by
naming them using Sheet > Named Ranges and Expressions
> Define, for example BloodSugar representing a range such as
B3:B10.
Operator types
You can use the following operator types in Calc: arithmetic, comparative, text, and reference.
Arithmetic operators
The addition, subtraction, multiplication, and division operators return numerical results. The
negation and percent operators identify a characteristic of the number found in the cell, for
example -37. The example for exponentiation illustrates how to enter a number that is being
multiplied by itself a certain number of times, for example 2^3 = 2*2*2.
Table 6: Arithmetic operators
Operator Name Example
+ (Plus) Addition =1+1
– (Minus) Subtraction =2–1
– (Minus) Negation –5
* (Asterisk) Multiplication =2*2
/ (Slash) Division =10/5
% (Percent) Percent 15%
^ (Caret) Exponentiation =2^3
Comparative operators
Comparative operators are found in formulas that use the IF function and return either a true or
false answer; for example, =IF(B6>G12, 127, 0) which, loosely translated, means if the
contents of cell B6 are greater than the contents of cell G12, then return the number 127,
otherwise return the number 0.
A direct answer of TRUE or FALSE can be obtained by entering a formula such as =B6>B12. If
the numbers found in the referenced cells are accurately represented, the answer TRUE is
returned, otherwise FALSE is returned.
Table 7: Comparative operators
Operator Name Example
= Equal A1=B1
> Greater than A1>B1
< Less than A1<B1
>= Greater than or equal to A1>=B1
<= Less than or equal to A1<=B1
<> Inequality A1<>B1
Text operators
It is common for users to place text in spreadsheets. To provide for variability in what and how
this type of data is displayed, text can be joined together in pieces coming from different places
on the spreadsheet. Figure 219 shows an example.
In this example, specific pieces of the text were found in three different cells. To join these
segments together, the formula also adds required spaces and punctuation enclosed within
quotation marks, resulting in a formula of =B2 & “ ” & C2 & “, ” & D2. The result is the
concatenation into a date formatted in a particular sequence.
Calc has a CONCATENATE function which performs the same operation.
Reference operators
An individual cell is identified by the column identifier (letter) located along the top of the columns
and a row identifier (number) found along the left-hand side of the spreadsheet. On spreadsheets
read from left to right, the reference for the upper left cell is A1.
Thus in its simplest form a reference refers to a single cell, but references can also refer to a
rectangle or cuboid range, or a reference in a list of references. To build such references you
need reference operators.
Example Description
A2:B4 Reference to a rectangle range with 6 cells, 2 column width × 3 row
height. When you click on the reference in the formula in the input line, a
border indicates the rectangle.
(A2:B4):C9 Reference to a rectangle range with cell A2 top left and cell C9 bottom
right. So the range contains 24 cells, 3 column width × 8 row height. This
method of addressing extends the initial range from A2:B4 to A2:C9.
Sheet1.A3:Sheet3.D Reference to a cuboid range with 24 cells, 4 column width × 2 row height
4 × 3 sheets depth. (Assumes that sheets Sheet1, Sheet2, and Sheet3
appear in that order on the Sheet tabs area.)
B:B Reference to all cells of column B.
A:D Reference to all cells of columns A to D.
20:20 Reference to all cells of row 20.
1:20 Reference to all cell of rows 1 to 20.
When you enter B4:A2, B2:A4, or A4:B2 directly, then Calc will turn it to A2:B4. So the left top cell
of the range is left of the colon and the bottom right cell is right of the colon. But if you name the
cell B4 for example with _start and A2 with _end, you can use _start:_end without any error.
Tip
Always put in parentheses the part that is to be calculated first.
Relative referencing
An example of a relative reference will illustrate the difference between a relative reference and
absolute reference using the spreadsheet from Figure 222.
1) Type the numbers 4 and 11 into cells C3 and C4 respectively of that spreadsheet.
2) Copy the formula in cell B5 (=B3+B4) to cell C5. You can do this by using a simple copy
and paste or click and drag B5 to C5 as shown below. The formula in B5 calculates the
sum of values in the two cells B3 and B4.
3) Click in cell C5. The formula bar shows =C3+C4 rather than =B3+B4 and the value in C5
is 15, the sum of 4 and 11 which are the values in C3 and C4.
In cell B5 the references to cells B3 and B4 are relative references. This means that Calc
interprets the formula in B5, applies it to the cells in the B column, and puts the result in the cell
holding the formula. When you copied the formula to another cell, the same procedure was used
to calculate the value to put in that cell. This time the formula in cell C5 referred to cells C3 and
C4.
Absolute referencing
You may want to multiply a column of numbers by a fixed amount. A column of figures might
show amounts in US Dollars. To convert these amounts to Euros it is necessary to multiply each
dollar amount by the exchange rate. $US10.00 would be multiplied by 0.75 to convert to Euros, in
this case Eur7.50. The following example shows how to input an exchange rate and use that rate
to convert amounts in a column from USD to Euros.
1) Input the exchange rate Eur:USD (0.75) in cell D1. Enter amounts (in USD) into cells D2,
D3 and D4, for example 10, 20, and 30.
Enter the conversion formula into E2, which will show the correct result, then copy it to E3.
Knowledge of the use of relative and absolute references is essential if you want to copy and
paste formulas and to link spreadsheets.
Named ranges
Cells and cell ranges can have a name assigned to them. Naming cells and ranges enhances
formula readability and document maintenance. A simple example would be naming a range of
cells B1:B10 as “Weight” and sum all weights. The formula is =SUM(B1:B10). When the range
B1:B10 is named as Weight, you can transform the formula to =SUM(Weight). The advantage is
clear in terms of readability of the formulas.
Another advantage is that all formulas that have the named range as argument are updated
when the named range changes location or size. For example, if the range Weight is now in cells
P10:P30, you do not need to review all the formulas that have Weight as an argument; you only
need to update the named range Weight with the new size and location.
To define a named cell or range select the cell or range and use menu Sheet > Named Ranges
and Expressions > Define. The dialog in Figure 224 appears with the selected range and you
define the name and scope of the named range.
You can also define a named range directly in the sheet by selecting the range and typing its
name in the Name Box at the left of the Formula Bar (Figure 225).
Order of calculation
Order of calculation refers to the sequence in which numerical operations are performed and the
Wikipedia article at https://en.wikipedia.org/wiki/Order_of_operations provides useful general
background information. Division and multiplication are performed before addition or subtraction.
There is a common tendency to expect calculations to be made from left to right as the equation
would be read in English. Calc evaluates the entire formula, then based upon programming
precedence, breaks the formula down executing multiplication and division operations before
other operations. Therefore, when creating formulas you should test your formula to make sure
that the expected and correct result is being obtained. Following is an example of the order of
calculation in operation.
Table 10: Order of calculation
Left To Right Calculation Ordered Calculation
1+3*2+3 = 11 =1+3*2+3 result 10
1+3 = 4, then 4x2 = 8, then 8+3 = 11 3*2 = 6, then 1+6+3 = 10
Another possible intention could be: The program resolves the multiplication of 3 x 2
1+3*2+3 = 20 before dealing with the numbers being added.
1+3 = 4, then 2+3 = 5, then 4x5=20
If you intend for the result to be either of the two possible solutions on the left, order the formula
as:
((1+3) * 2)+3 = 11 (1+3) * (2+3) = 20
Note
Use parentheses to group operations in the order you intend; for example,
=B4+G12*C4/M12 might become =((B4+G12)*C4)/M12.
Figure 227: Combining data from several sheets into a single sheet
The sheets have been set up with identical structures. The easiest way to do this is to open a
new spreadsheet, set up the first branch sheet, input data, format cells, and prepare the formulas
for the various sums of rows and columns. After that, create copies from the first sheet as
following:
1) On the sheet tab, right-click and select Rename Sheet. Type Branch1. Right-click on the
tab again and select Move or Copy Sheet.
2) In the Move/Copy Sheet dialog (Figure 228), select the Copy option (automatically
selected if there is only one sheet in the spreadsheet) and select -move to end position-
in the Insert before area. Change the entry in New name to Branch2. Click OK. Repeat to
produce the Branch3 and Combined sheets.
Argument Description
"text data" The quotes indicate text or string data is being
entered.
9 The number nine is being entered as a number.
"9" The number nine is being entered as text.
A1 The address for whatever is in cell A1 is being
entered.
B2:D9 The range of cells is being entered.
Nested functions
Functions can also be used as arguments within other functions. These are called nested
functions.
=SUM(2,PRODUCT(5,7))
To get an idea of what nested functions can do, imagine that you are designing a self-directed
learning module. During the module, students do three quizzes, and enter the results in cells A1,
A2, and A3. In A4, you can create a nested formula that begins by averaging the results of the
quizzes with the formula =AVERAGE(A1:A3). The formula then uses the IF function to give the
student feedback that depends upon the average grade on the quizzes. The entire formula would
read:
=IF(AVERAGE(A1:A3) >85, “Congratulations! You are ready to advance to
the next module”, “Failed. Please review the material again. If
necessary, contact your instructor for help”)
Depending on the average, the student would receive the message for either congratulations or
failure.
Note
Calc keeps the syntax of a formula displayed in a tool tip next to the cell as a handy
memory aid as you type.
The Function Wizard now displays an area to the right where you can enter data manually in text
boxes or click the Shrink button to shrink the Function Wizard so you can select cells from the
sheet.
Note
If you select a function by double-clicking it in the list, and then change your mind
and select a different one by double-clicking again, then the second choice formula is
added into the first choice formula in the Formula text box. You must clear the
Formula text box and then double-click the function to add it to the box.
This additive facility allows you to create complex formulas by building them up in the
Formula box.
You can also select the Structure tab to see a tree view of the parts of the formula. The main
advantage over the Functions deck is that each argument is entered in its own field, making it
easier to manage. The price of this reliability is slower input, but precision is generally more
important than speed when creating a spreadsheet.
The structure view of the Function Wizard is important for debugging and fixing very long, nested,
and complex formulas. In this view, the formula is parsed, and each formula component is
Tip
The menu option View > Show Formula and the Windows / Linux shortcut Ctrl+`
(grave accent) also toggle formulas on / off.
Array formulas
What is an array formula?
A formula in which the individual values in a cell range are evaluated is referred to as an array
formula. The difference between an array formula and other formulas is that the array formula
deals with several values simultaneously instead of just one.
Not only can an array formula process several values, but it can also return several values. The
results of an array formula is also an array.
When Calc updates the formulas, each affected cell is read and its formula is recalculated. If you
have a thousand cells in a column with the same formula (the formula expression only changes
the data to compute), you end with one thousand identical formulas to interpret and execute.
Array formulas will evaluate the formula once and execute calculations as many time as the size
of the array, thus saving the time used to interpret each cell formula. And because Calc stores
only one formula for the entire array of data cells, it also save space in the spreadsheet file.
Figure 236: Source array in yellow and resulting array in green. The array
formula is shown in the Formula Bar
To multiply the values in the individual cells by 10 in the above array (Figure 236), you do not
need to apply a formula to each individual cell or value. Instead you just need to use a single
array formula. Select a range of 3 x 5 cells on another part of the spreadsheet, enter the formula
Note
Array formulas appear in braces (curly brackets) in Calc. You cannot create array
formulas by manually entering the braces.
Note
The cells in a results array are automatically protected against changes. However,
you can edit or copy the array formula by selecting the entire array cell range.
Speeding up calculations
Spreadsheets are often used to process raw data and produce meaningful summaries,
consolidation and display of information for the decision maker, or to be used as the source for
reports. The raw data can be produced by physical measurements, business transactions, or
various other means. Sheets with thousands or even hundreds of thousands of rows and several
columns are frequently found in finance departments or laboratories. Computations carried out
on these raw data sets can be time consuming and last for minutes, hours and perhaps, days.
A common mistake is to insert formulas for each cell and perform thousands of formula
interpretations and calculations. Here are some recommendation for speeding up calculations.
Multi-threading
Many modern computers have multi-core processors and provide for multiple threads. A core is a
physical hardware component within a CPU. Threads are virtual components that help to
efficiently manage the workload and tasks of the CPU. A CPU can interact with more than one
thread at a time and multi-threading makes CPUs more efficient, to give better overall
performance.
Calc supports multi-threading to help your spreadsheets take advantage of whatever parallel
processing is available within your computer. This facility is controlled by the Enable multi-
threaded calculation option in the CPU threading settings section of the Tools > Options >
LibreOffice Calc > Calculate dialog. The initial default is for this option to be enabled, and
disabling it is not recommended. This is the only control in the Calc user interface that relates to
multi-threading; once initiated, the processing operates automatically.
If multi-threading is enabled, Calc automatically identifies where your spreadsheet could benefit
from multi-threading and processes it accordingly. Threads are generally used for formula
groups, where enough adjacent cells in a column use the same formula but get different results
because of relative cell addressing. One implication of this approach is that the optimization is
column-based and so a row-based layout could be less efficient.
There are other ways to control Calc’s multi-threading capability, such as adjusting the
MAX_CONCURRENCY LibreOffice specific environment variable. However, these methods are
beyond the scope of this document.
Error messages
The most basic tool is error messages. Error messages display in a formula’s cell, on the Status
Bar, or in the Function Wizard instead of the result.
An error message for a formula is usually a three-digit number from 501 to 540, or sometimes an
unhelpful piece of text such as #NAME?, #REF!, or #VALUE!. The error message appears in the
cell, and a brief explanation of the error is shown on the right side of the Status bar.
Most error messages indicate a problem with how the formula was input, although several
indicate that you have run up against a limitation of either Calc or its current settings.
Error messages are not user-friendly, and may intimidate new users. However, they are valuable
clues to correcting mistakes. You can find detailed explanations of them in Appendix B, Error
Codes, and in the Help, by searching for “error codes” in Calc. A few of the most common are
shown in Table 13.
Table 13: Common error messages
Code Meaning
#NAME? Instead of displaying Err:525. No valid reference exists for the argument.
Instead of displaying Err:524. The column, row, or sheet for the referenced cell is
#REF!
missing.
Instead of displaying Err:519. The value for one of the arguments is not the type that
the argument requires. The value may be entered incorrectly; for example, double-
#VALUE!
quotation marks may be missing around the value. At other times, a cell or range used
may have the wrong format, such as text instead of numbers.
#DIV/0! Instead of displaying Err:532. Division by zero.
Instead of displaying Err:503. A calculation results in an overflow of the defined value
#NUM!
range.
509 An operator such as an equals sign is missing from the formula.
510 A variable is missing from the formula.
Value highlighting
There are situations where the display of cell contents is the same when the data type is
different. For example a text contents and a numeric contents can look the same but can produce
a mistake if both are used in some calculations. To illustrate, the string “10.35” right-aligned in a
cell can be confused with the value 10.35. When the cell is used in a formula the string may take
the value of zero and an error may be produced.
If you enable value highlighting (View > Value Highlighting or Ctrl+F8), Calc distinguishes the
text and numeric data types by assigning different colors to the content’s characters. By default,
the text contents is in black characters and the numeric contents is in blue. See Chapter 2,
Entering, Editing, and Formatting Data, for more information on value highlighting.
The Detective
In a long or complicated spreadsheet, color coding becomes less useful. In these cases, consider
using the submenu under Tools > Detective. The Detective is a tool for checking which cells are
used as arguments by a formula (precedents) and which other formulas it is nested in
(dependents), and tracking errors. It can also be used for tracing errors, marking invalid data
(that is, information in cells that is not in the proper format for a function’s argument), or even for
removing precedents and dependents.
To use the Detective, select a cell with a formula, then select the required option from the Tools >
Detective menu. On the spreadsheet, you will see lines ending in dots to indicate precedents,
and lines ending in arrows for dependents. The lines show the flow of information.
Use the Detective to assist in following the precedents referred to in a formula in a cell. By tracing
these precedents, you frequently can find the source of the errors. Place the cursor in the cell in
question and then choose Tools > Detective > Trace Precedents from the Menu bar or press
Shift+F9. Figure 243 shows a simple example of tracing precedents for cell B4.
This allows us to check the source cells (which may be a range) for any errors which have
caused us to query the calculation result. If a source is a range, then that range is highlighted in
blue.
In other instances we may have to trace an error. For this we use the Trace Error function, found
under Tools > Detective > Trace Error, to find the cells that caused the error.
For more information search for “Detective” in the Help system’s index.
Examples of functions
For novices, functions are one of the most intimidating features of LibreOffice Calc. New users
quickly learn that functions are an important feature of spreadsheets, but there are hundreds, and
many require input that assumes specialized knowledge. Fortunately, Calc includes many
functions that anyone can use.
Basic arithmetic
The simple arithmetic functions are addition, subtraction, multiplication, and division. Except for
subtraction, each of these operations has its own function:
• SUM for addition
• PRODUCT for multiplication
• QUOTIENT for division
SUM, PRODUCT, and QUOTIENT are useful for entering ranges of cells in the same way as any
other function, with arguments in brackets after the function name.
However, for basic equations, many users prefer the time-honored computer symbols for these
operations, using the plus sign (+) for addition, the hyphen (–) for subtraction, the asterisk (*) for
multiplication and the forward slash (/) for division. These symbols are quick to enter without
requiring your hands to stray from the keyboard.
A similar choice is also available if you want to raise a number by the power of another. Instead
of entering =POWER(A1,2), you can enter =A1^2.
Moreover, they have the advantage that you enter formulas with them in an order that more
closely approximates human readable format than the spreadsheet-readable format used by the
equivalent function. For instance, instead of entering =SUM(A1:A2), or possibly =SUM(A1,A2),
you enter =A1+A2. This almost-human readable format is especially useful for compound
operations, where writing =A1*(A2+A3) is briefer and easier to read than
=PRODUCT(A1,SUM(A2:A3)).
Simple statistics
Another common use for spreadsheet functions is to pull useful information out of a list, such as
a series of test scores in a class, or a summary of earnings per quarter for a company.
You can, of course, scan a list of figures if you want basic information such as the highest or
lowest entry or the average. The only trouble is, the longer the list, the more time you waste and
the more likely you are to miss what you are looking for. Instead, it is usually quicker and more
efficient to enter a function. Such reasons explain the existence of a function like COUNT, which
does no more than give the total number of entries in the designated cell range.
Similarly, to find the highest or lowest entry, you can use MIN or MAX. For each of these
formulas, all arguments are either a range of cells, or a series of cells entered individually.
Each also has a related function, MINA or MAXA, which performs the same function, but also
treats a cell formatted for text as having a value of 0. (The same treatment of text occurs in any
variation of another function that adds an "A" to the end.) Either function gives the same result,
and could be useful if you used a text notation to indicate, for example, if any students were
absent when a test was written, and you wanted to check whether to schedule a makeup exam.
For more flexibility in similar operations, you could use LARGE or SMALL, both of which add a
specialized argument of rank. If the rank is 1 used with LARGE, you get the same result as you
would with MAX. However, if the rank is 2, then the result is the second largest result. Similarly, a
rank of 2 used with SMALL gives you the second smallest number. Both LARGE and SMALL are
handy as a permanent control, since, by changing the rank argument, you can quickly scan
multiple results.
You would need to be an expert to want to find the Poisson distribution of a sample, or to find the
skew or negative binomial of a distribution (and, if you are, you will find functions in Calc for such
things). However, for the rest of us, there are simpler statistical functions that you can quickly
learn to use.
In particular, if you need an average, you have a number of functions to choose from. You can
find the arithmetical mean—that is, the result when you add all entries in a list then divided by the
number of entries, by entering a range of numbers when using AVERAGE, or AVERAGEA to
include text entries and to give them a value of zero.
In addition, you can get other information about the data set:
• MEDIAN: Logically ranks the numbers (lowest to highest) to evaluate the median value.
In a set containing an uneven number of values, the median will be the number in the
middle of the ranked list. In a set containing an even number of values, the median will
be the mean of the two values in the middle of the ranked list.
• MODE: The most common entry in a list of numbers.
• QUARTILE: The entry at a set position in the array of numbers. Besides the cell range,
you enter the type of quartile: 0 for the lowest entry, 1 for the value of 25%, 2 for the
value of 50%, 3 for 75%, and 4 for the highest entry. Note that the result for types 1
through 3 may not represent an actual item entered.
• RANK: The position of a given entry in the entire list, measured either from top to bottom
or bottom to top. You need to enter the cell address for the entry, the range of entries,
Figure 244: Tools > Option > LibreOffice Calc > Calculate dialog
Tip
When both the Search criteria = and <> must apply to whole cells and Enable
wildcards in formulas options are selected, Calc behaves exactly as Microsoft
Excel when searching cells in the database functions.
To illustrate some of the features of regular expressions, consider the simple spreadsheet shown
in Figure 245 and assume that Enable regular expressions in formulas is selected on the
Tools > Options > LibreOffice Calc > Calculate dialog.
Advanced functions
As is common with other spreadsheet programs, Calc can be enhanced by user-defined
functions or add-ins. Setting up user-defined functions can be done either by using macros or by
writing separate add-ins or extensions.
The basics of writing and running macros is covered in Chapter 12, Macros. Macros can be
linked to menus or toolbars for ease of operation or stored in template modules to make the
functions available in other documents. Calc macros can be written in Basic, BeanShell,
JavaScript, or Python.
Calc Add-ins are specialized office extensions which can extend the functionality of LibreOffice
with new built-in Calc functions. A number of extensions for Calc have been written; these can be
Chapter 8
Using Pivot Tables
Introduction
Many requests for spreadsheet support are the result of using complicated formulas and
solutions to solve simple day-to-day problems. For more efficient and effective solutions, use the
pivot table, a tool for combining, comparing, and analyzing large amounts of data easily. Using
pivot tables, you can view different summaries of the source data, display the details of areas of
interest, and create reports, whether you are a beginner, an intermediate, or an advanced user.
In addition you can create a pivot chart to view a graphical representation of the data in a pivot
table.
Database preconditions
To work with a pivot table, you need a list of raw data, similar to a database table, consisting of
rows (data sets) and columns (data fields). The field names are in the first row above the list.
The data source could be an external file or database. For the simplest case, where data is
contained in a Calc spreadsheet, Calc offers sorting functions that do not require the pivot table.
For processing data in lists, Calc needs to know where in the spreadsheet the list is. The list can
be anywhere in the sheet, in any position. A spreadsheet can contain several unrelated lists.
Calc recognizes your lists automatically. It uses the following logic: Starting from the cell you
have selected (which must be within the list), Calc checks the surrounding cells in all four
directions (left, right, above, below). The border is recognized if the program discovers an empty
row or column, or if it hits the left or upper border of the spreadsheet. This means that the
described functions can only work correctly if there are no empty rows or columns in the list.
Avoid empty lines (for example for formatting). You can format the list by using cell formats.
Tip
To make sure that Calc automatically recognizes a list correctly, check that there are
no empty rows or empty columns within the list.
If you select more than one cell before creating a pivot table, then Calc’s automatic list
recognition logic is not applied. Instead, Calc assumes that the pivot table is to be created using
exactly the cells that you selected.
Tip
Always select only one cell before initiating creation of a pivot table. This allows Calc
to automatically determine the full scope of your data list.
A relatively common source of errors is to inadvertently declare a list by mistake and then to sort
that list. If you select multiple cells—for example, a whole column—then the sorting mixes up the
data that should be together in one row.
In addition to these formal aspects, the logical structure of the list is also very important.
Note
Calc lists must have the normal form; that is, they must have a simple linear
structure.
When entering the data, do not add outlines, groups, or summaries. Here are some mistakes
commonly made by inexperienced spreadsheet users:
• You made several unnecessary sheets; for example, a sheet for each group of articles. In
this case, analyses are only possible within each group.
Data sources
The possible data sources for the pivot table are a Calc spreadsheet or an external data source
that is registered in LibreOffice.
Calc spreadsheet
Analyzing a list in a Calc spreadsheet is the simplest and most often used case. Lists might be
updated regularly or the data might be imported from a different application.
The list data might be entered directly into the spreadsheet or copied from another file or
application. You can also use a Web Page Query input filter to insert data from a HTML file, a
CSV file, a Calc spreadsheet, or a Microsoft Excel spreadsheet. See Chapter 10, Linking Data,
for more information.
The behavior of Calc while inserting data from a different application depends on the format of
the data. If the data is in a common spreadsheet format, it is copied directly into Calc. However, if
the data is in plain text format, the Text Import dialog appears after you select the file containing
the data; see Chapter 1, Introduction, for more more information about this dialog.
Using shortcuts
If you use pivot tables often in Calc, you might find the frequent use of the built-in menu paths
inconvenient.
In some cases built-in keyboard shortcuts are already defined; see Appendix A, Keyboard
Shortcuts. An example is the F12 function key, which groups a selected data range. In some
other cases, the built-in toolbars already provide relevant icons. An example is the Insert or Edit
Pivot Table icon on the Standard toolbar.
In addition to using the built-in keyboard shortcuts and toolbar icons, you can also define your
own. See Chapter 14, Setting up and Customizing, for instructions.
Note
See Chapter 13, Calc as a Database, for more information about named ranges. See
Chapter 10, Linking Data, for more information about linking to registered data
sources.
Tip
To access the Pivot Table Layout dialog again after initial creation of a pivot table,
left-click in any cell of the pivot table. Then select Insert > Pivot Table on the Menu
bar, or select Data > Pivot Table > Insert or Edit on the Menu bar, or click the
Insert or Edit Pivot Table icon on the Standard toolbar, or right-click in any cell of
the pivot table and select the Properties option in the context menu.
Figure 248: Field order for analysis and resulting layout of pivot table
Fields that are placed into the Filters area appear at the top of the resulting pivot table as a drop-
down list. The summary in the result takes into account only that part of the base data that you
have selected. For example, if you include Employee in the Filters area, you can filter the result
shown for each employee.
To move a field from an area, just drag it to a new area. To remove a field from the Filters,
Column Fields, Row Fields, or Data Fields areas, drag it to the Available Fields area.
Tip
To rapidly move a selected field from one area of the Pivot Table Layout dialog to
another, press the Alt+letter on the keyboard that corresponds to the underlined letter
in the target area’s label.
Note
By default, Calc inserts a Data field into the Column Fields area. The Data field can
be moved between the Column Fields and Row Fields areas as required. Depending
on its position within the list of fields in its area, the Data field may lead to a button
labeled Data appearing in the results of the pivot table, affecting the layout of the
results. If you do not wish to use this facility, simply place the Data field at the bottom
of the list of fields in its area.
More options
To expand the Pivot Table Layout dialog and show more options, click the expansion symbol
(plus or triangle sign) adjacent to the Options and Source and Destination labels (Figure 249).
Ignore empty rows
If the source data is not in the recommended form, this option tells the pivot table to ignore
empty rows.
Note
The filtering provided through the Add filter option is independent of the filtering
provided by including fields in the Filters area of the Pivot Table Layout dialog.
Tip
To display the pivot table on the same sheet as the raw data, check the Selection
option in the Destination area, click the Shrink button to the right of the Selection
field, click at an appropriate cell in an empty area of the sheet, click the Expand
button, and click OK on the Pivot Table Layout dialog.
Figure 255: Original pivot table (top) and a Difference from example (bottom)
Figure 261: Division of the regions for employees with subtotals (by region)
Note
Before you can group, you have to produce a pivot table with ungrouped data. The
time needed for creating a pivot table depends mostly on the number of columns and
rows and not on the size of the basic data. Through grouping you can produce the
pivot table with a small number of rows and columns. The pivot table can contain a
lot of categories, depending on your data source.
To remove grouping again, click inside the group, then choose Data > Group and Outline >
Ungroup, or press Ctrl+F12.
Tip
You can select several non-contiguous cells by pressing and holding the Control key
while clicking with the mouse.
Given the input data shown in Figure 275, create a pivot table with Department in the Row Fields
area and Sum - Sick days in the Data Fields area. The result should be as shown in Figure 276.
Note
A well-structured database makes manual sorting within the pivot table obsolete. In
the example shown, you could add another column with the name Department, that
has the correct entry for each person based on whether the employee’s department
belongs to the group Office or Technical. The mapping for this (1:n relationship) can
be done easily with the VLOOKUP() function.
Figure 282: Arrow color change and indicator square on column heading
Sort automatically
To sort automatically, right-click within the pivot table and choose Properties. This will open the
Pivot Table Layout dialog (Figure 247). Double-click the row or column field you want to sort. In
the Data Field dialog which opens (Figure 258), click Options to display the Data Field Options
dialog (Figure 264).
For Sort by, choose either Ascending, Descending, or Manual. If the selected field is the field
for which the dialog was opened, the items are sorted by name. If a data field was selected, the
items are sorted by the resultant value of the selected data field. Ascending sorts the values
from the lowest value to the highest value. Similarly Descending sorts the values descending
from the highest value to the lowest value. Manual sorts values alphabetically.
Figure 286: New sheet after the drill down for a value in a data field
Filtering
To limit the pivot table analysis to a subset of the information that is contained in the data basis,
you can filter the pivot table results.
To do this, click the Filter button at the top left above the results, or right-click in the results and
select Filter in the context menu.
Note
The Filter button is available only if the Add filter option on the Pivot Table Layout
dialog is selected.
Figure 287: Filter button in the upper left area of the pivot table
In the Filter dialog (Figure 288), you can define up to three filter options that are used in the same
way as Calc’s default filter. The controls in the Options section of this dialog are similar to the
equivalent controls on Calc’s Standard Filter dialog – see Chapter 2, Entering, Editing, and
Formatting Data for more information.
Cell formatting
The cells in the results area of the pivot table are automatically formatted by Calc. You can
change this formatting using all the tools in Calc. However if you make any change in the design
of the pivot table using direct formatting, the formatting will return to that applied automatically by
Calc when the table is next refreshed.
On creating a pivot table, six standard cell styles are added to the list of styles in the document if
they are not included already. Each of these styles is applied to part of the pivot table. You can
customize these pivot table styles. The pivot table styles are:
• Pivot Table Category
• Pivot Table Corner
• Pivot Table Field
Tip
Use the pivot table styles to make sure that the format of your pivot table is not
unexpectedly changed during updates and that all pivot tables in your document
have the same appearance.
For the number format in the data field, Calc uses the number format that is used in the
corresponding cell in the source list. In most cases, this is useful (for example, if the values are in
the currency format, then the corresponding cell in the result area is also formatted as currency).
However, if the result is a fraction or a percentage, the pivot table does not recognize that this
might be a problem; such results must either be without a unit or be displayed as a percentage.
Although you can correct the number format manually, the correction stays in effect only until the
next update.
Caution
If you delete a pivot table with an associated pivot chart, the pivot chart is also
deleted. Calc opens a dialog box to confirm the pivot chart deletion.
Figure 291: The value that you really want to use can be
found now in a different location
Syntax
The syntax has two variations:
GETPIVOTDATA(Target Field; Pivot Table[; Field 1; Item 1][; ...
[Field 126; Item 126]])
or
GETPIVOTDATA(Pivot Table; Constraints)
The square brackets in the first variation surround optional arguments.
Figure 297: Enter chart elements through the Chart Wizard when creating a pivot chart
Click Finish to close the wizard and create the pivot chart.
Note
When you delete a pivot chart, the associated pivot table is not affected.
Chapter 9
Data Analysis
Using Scenarios, Goal Seek, Solver, Statistics, others
Introduction
Once you are familiar with functions and formulas, the next step is to learn how to use Calc’s
automated processes to quickly perform useful analysis of your data.
In addition to formulas and functions, Calc includes several tools for processing your data. These
tools include features for copying and reusing data, creating subtotals, running what-if analysis,
and performing statistical analysis. They can be found under the Tools and Data menus on the
Menu bar. Although they are not necessary when using Calc, they can help you save time and
effort with handling large data sets or preserving your work for future review.
Note
A related tool, the Pivot Table, is not mentioned here, as it is complex enough to
require its own chapter. See Chapter 8, Using Pivot Tables, for more information.
Consolidating data
The Consolidate tool allows you to combine and aggregate data spread across one or more
sheets. This tool is useful if you need to quickly summarize a large, scattered set of data for
review. For example, you could use it to consolidate multiple department budgets from different
sheets into a single company-wide budget contained in a master sheet.
To consolidate data:
1) Open the document containing the cell ranges to be consolidated.
2) Select Data > Consolidate on the Menu bar to open the Consolidate dialog (Figure 299).
3) Click on the Source data ranges field, then type a reference to a source data range, a
named range, or select it with the mouse. Use the associated Shrink / Expand button if
you need to minimize the dialog while you select the range. Alternatively, select a named
range from the drop-down list to the left of the field.
4) Click Add. The selected range is added to the Consolidation ranges list.
5) Repeat steps 3 and 4 to add additional source ranges.
6) To delete an entry in the Consolidation ranges list, select it and click Delete. The deletion
is carried out without further confirmation.
7) Click on the Copy results to field, then type a reference to the first cell of the target range
or select it with your mouse. You can also select a named range from the drop-down list
to the left of the field.
8) Select a function to aggregate your data from the Function drop-down list. The default is
Sum. Other available functions are Count, Average, Max, Min, Product, Count (numbers
only), StdDev (sample), StDevP (population), Var (sample), and VarP (population).
9) Click OK to consolidate the ranges. Calc runs the function from step 8 on your source
data ranges and populates the target range with the results.
Tip
If you are consolidating the same cell ranges repeatedly, consider converting them
into reusable named ranges to make the process easier. For more information about
named ranges, see Chapter 13, Calc as a Database.
Consolidation settings
In the Consolidate dialog, expand the Options section to access the the settings shown in Figure
300.
Consolidation example
Figures 301, 302, and 303 show a simple example of consolidation using a spreadsheet with the
sheets Year 1, Year 2, and Consolidated Sales. Figure 301 shows the contents of the Year 1
sheet, with sales figures by region for each of the four product colors.
Creating subtotals
Calc offers two methods of creating subtotals: the SUBTOTAL function and the Subtotals tool.
A SUBTOTAL example
To illustrate how to use the SUBTOTAL function, we use the sales data sheet shown in Figure
304. The AutoFilter function is already applied to the sales data, as indicated by the down arrow
buttons at the head of each column. AutoFilters are described in Chapter 2, Entering, Editing,
and Formatting Data.
Figure 304: Sales data with AutoFilter applied (only the first few rows
are shown)
To create a summation subtotal for the Sales Value field using the Function Wizard:
1) Select the cell to contain a subtotal. Typically, this cell is at the bottom of the column
being subtotaled, which, for our example, is the Sales Value column.
2) Use one of the following methods to open the Function Wizard dialog (Figure 305):
– Select Insert > Function on the Menu bar
– Click the Function Wizard icon on the Formula bar
– Press Ctrl+F2
3) Select SUBTOTAL from the Function list in the Function Wizard dialog and click Next.
4) Enter the numeric code of a function into the Function field on the right side of the dialog.
This code must be a value in the range 1 to 11, or 101 to 111, with the meaning of each
value shown in Table 15.
Note
Values 1 to 11 include hidden values in the calculated subtotal, while values 101 to
111 do not. Hiding and showing data is described in Chapter 2, Entering, Editing, and
Formatting Data. Filtered-out cells are always excluded by the SUBTOTAL function.
5) Click on the Range field, then type a reference to the Sales Value range or select the
cells with your mouse (Figure 305). Use the Shrink / Expand button if you need to
temporarily minimize the dialog while selecting the cells.
6) Click OK to close the Function Wizard dialog. The cell you selected in step 1 now
contains the total sales value.
7) Click on the AutoFilter down arrow button at the top of the Employee column and remove
all marks from the Standard Filter area except those next to Brigitte and (empty). The cell
that you selected in step 1 should now reflect the sum of all of Brigitte’s sales (Figure
306).
Note
If the cell range used to calculate a subtotal contains other subtotals, these subtotals
will not be counted in the final one. Similarly, if you use this function with AutoFilters,
only the data satisfying the current filter selections will be displayed. Any filtered-out
data is ignored.
Figure 308: Partial outlined view of sales data example with subtotals
Column 1 represents the highest group level, the grand total over all employees. Columns 2 to 5
show descending group levels as follows:
• Column 2 represents the grand total over all categories.
Using scenarios
Scenarios are saved, named cell ranges that you can use to answer “what-if” questions about
your data. You can create multiple scenarios for the same calculation set, then quickly swap
between them to view the outcomes of each. This feature is useful if you need to test the effects
of different conditions on your calculations, but do not want to deal with repetitive manual data
entry. For example, if you wanted to test different interest rates for an investment, you could
create scenarios for each rate, then switch between them to find out which rates work the best for
you.
Creating scenarios
To create a new scenario:
1) Select the cells that contain the values that will change between scenarios. To select
multiple ranges, hold down the Ctrl key as you click. You must select at least two cells.
2) Choose Tools > Scenarios on the Menu bar to open the Create Scenario dialog (Figure
310).
4) Optionally, add information to the Comment field. The example in Figure 310 shows the
default comment.
5) Click OK to close the dialog. The new scenario is automatically activated upon creation.
6) Repeat steps 1 to 5 to create additional scenarios. Select the same cell range that you
used for the first scenario to have multiple scenarios for the same calculations.
Tip
To keep track of what calculations are dependent on your scenarios, use Tools >
Detective > Trace Dependents on the Menu bar after highlighting your scenario
cells. Arrows will point from your scenario cells to the dependent formula cells. For
more information about the Detective tool, see Chapter 7, Using Formulas and
Functions.
Scenario settings
The Settings sections of the Create Scenario dialog contains the following options:
Caution
When creating a new scenario from the cells of a scenario with Copy back enabled,
be careful not to overwrite the old scenario. To avoid this situation, create the new
scenario with Copy back enabled first, then change its values only once it is active.
Changing scenarios
Scenarios have two aspects that can be altered independently:
• Scenario properties (that is, its settings)
• Scenario cell values
The extent to which these aspects can be changed depends on the active scenario's properties
and the current sheet and cell protections. For more detail about sheet and cell protections, see
Chapter 2, Entering, Editing, and Formatting Data.
Tip
Exercising good organization can make using this tool relatively painless. For
example, we recommend keeping your data together on one sheet and using labels
to identify your formulas, variables, and table ranges.
7) Click OK. The profits for the different quantities are now shown in column E (Figure 316).
We can see that the break-even point is between 1000 and 1500 toys sold – namely,
1250. Figure 316 shows an XY (Scatter) chart showing the profit as a function of quantity.
Figure 316: Results of Multiple Operations tool for one formula and one variable
Note
The Multiple Operations tool only accepts formulas arranged in a single row or
column, depending on how your results table is oriented. If the table is column-
oriented – that is, the way it is in our sales data example – then your formulas must
be arranged in a row. If the table is row-oriented, then your formulas must be in a
column.
Caution
Be careful not to add empty cells between formulas, as they will create gaps in the
results table and may cause some results not to appear if you don't select enough
rows or columns for the table.
Figure 318: Inputs to Multiple Operations tool for one variable and two
formulas
7) Click OK. Now the profits are listed in column E and the annual profit per item in column
F.
Figure 319: Results of Multiple Operations tool for one variable and two formulas
Tip
A good guideline to remember is that since column headings are in a row at the top
of the table, they correspond to the Row input cell field. Likewise, row headings are
in a column, so they correspond to the Column input cell field.
Note
If you use two variables, the Multiple Operations tool will not work with multiple
formulas. It will allow you to enter the extra formulas, but will not generate the
expected results for any formula beyond the first.
Note
Only one argument can be altered at a time in a single goal seek. If you need to test
multiple arguments, then you must run a separate goal seek on each one.
6) Click OK. A dialog appears informing you that the goal seek was successful (Figure 324).
Note
Not every goal seek problem succeeds in returning a good result. It depends on the
formula used, goal value, and initial value. The goal seek algorithm iterates internally
several times converging to the goal.
If the goal seek is unsuccessful, Calc displays an information dialog reporting the
failure. This dialog offers the choice of inserting the closest value into the variable
cell. Press Yes or No as required.
The DEPS and SCO Evolutionary Algorithms are intended for solving non-linear problems - they
are only available if you have a Java runtime environment installed on your computer and have
enabled the Tools > Options > LibreOffice > Advanced > Use a Java runtime environment
configuration option. The DEPS Evolutionary Algorithm is the initial default if it is available, while
LibreOffice CoinMP Linear Solver is the initial default otherwise.
The available options provide flexibility to choose the most suitable algorithm for a given problem,
which may be linear or non-linear, and a given performance requirement. The Help system
contains much more information about the available algorithms and their configuration options.
In order to use the Solver to solve a mathematical programming problem, you must formulate the
problem as follows:
• Decision variables – a set of n non-negative variables x1, … , xn,. Decision variables
may be real numbers, but generally tend to be integers in many real world problems.
• Constraints – a set of linear equalities or inequalities involving the decision variables.
• Objective function – a linear expression involving the decision variables.
The goal is usually to find values of the decision variables that satisfy the constraints and
maximize or minimize the result of the objective function.
Solver dialog
After setting up the data for the problem in your Calc spreadsheet, select Tools > Solver on the
Menu bar to open the Solver dialog (Figure 326).
Note
Depending on the configuration of your computer, a message may be displayed the
first time that you select Tools > Solver after starting Calc. The nature of this
message will change dependent on the existence of a Java runtime environment
(JRE) on your system. If no JRE is detected, the message will simply be a warning to
that effect. In the case where a JRE is detected but the Tools > Options >
LibreOffice > Advanced > Use a Java runtime environment option is disabled,
then the message will include a button to enable that option.
Target cell
Type a cell reference to the objective function or select it with the mouse.
Optimize result to
Select Maximum to find the maximum result for the objective function, Minimum to find the
minimum result, or Value of to set it to a specific value. If you select Value of, enter the
required value or a reference to the cell containing that value.
By changing cells
Enter the locations of any cells that define your decision variables.
Limiting Conditions
Enter your constraints in the fields in this area:
– Cell reference – enter a cell reference to a decision variable.
Tip
Remember that for some of these options, you can minimize the Solver dialog using
the associated Shrink / Expand buttons if you need to select cells with the mouse.
Once you have finished setting up the Solver, click the Solve button to begin the process of
adjusting values and calculating results. Depending on the complexity of the task, this may take
some time. On successful completion, Calc presents a Solving Result dialog (Figure 327). This
dialog includes buttons to save (Keep Result) or discard (Restore Previous) your results.
Solver options
Sampling tool
The Sampling tool creates a target table with data sampled from a source table. The sampling
tool can pick samples randomly or on a periodic basis. Sampling is done row-wise, with whole
rows of the source table copied into rows of the target table. To use this tool, select Data >
Statistics > Sampling on the Menu bar to access the Sampling dialog (Figure 331).
Tip
Use the Shrink / Expand buttons next to the Input range and Results to fields if you
need to shrink the dialog while selecting cells with the mouse.
Figure 332 shows the source table (below the Source Data heading) and the corresponding
target table (under the Target Data heading), sampled using the settings shown in Figure 331.
Input range
Specifies the cell range containing the source data.
Results to
Specifies the top left cell of the results area. When you run the tool, it will fill out the rest of
the report table starting at this cell.
Columns / Rows
Specifies whether the data to be analyzed is organized in columns or rows.
Tip
Use the Shrink / Expand buttons next to the Input range and Results to fields if you
need to shrink the dialog while selecting cells with the mouse.
Figure 334 shows a small data set comprising student examination results in three subjects.
Figure 335 shows the statistics report generated for this input data using the settings shown in
Figure 333.
Tip
For more information on descriptive statistics, refer to the corresponding Wikipedia
article at https://en.wikipedia.org/wiki/Descriptive_statistics.
Tip
Use the Shrink / Expand buttons next to the Input range and Results to fields if you
need to shrink the dialog while selecting cells with the mouse.
To illustrate how to use this tool, we use the input data set from Figure 334. Figure 337 shows the
analysis of variance results generated for this data using the settings shown in Figure 336.
Tip
For more information on analysis of variance, refer to the corresponding Wikipedia
article at https://en.wikipedia.org/wiki/Analysis_of_variance.
Correlation tool
The Correlation tool calculates the correlation of two sets of numeric data and generates the
resulting correlation coefficient. This coefficient is a value between -1 and +1 that indicates how
strongly two variables are related to each other. A correlation coefficient of +1 indicates a perfect
positive correlation (the data sets match) and a coefficient of -1 indicates a perfect negative
correlation (the data sets are inverse to each other). Select Data > Statistics > Correlation on
the Menu bar to access the Correlation dialog (Figure 338).
Tip
Use the Shrink / Expand buttons next to the Input range and Results to fields if you
need to shrink the dialog while selecting cells with the mouse.
To illustrate how to use this tool, we again use the data set from Figure 334. Figure 339 shows
the six correlation coefficients generated for this input data using the settings shown in Figure
338.
Tip
For more information on statistical correlation, refer to the corresponding Wikipedia
article at https://en.wikipedia.org/wiki/Correlation_and_dependence.
Covariance tool
The Covariance tool measures how much two sets of numeric data vary together. Select Data >
Statistics > Covariance on the Menu bar to access the Covariance dialog (Figure 340).
Tip
Use the Shrink / Expand buttons next to the Input range and Results to fields if you
need to shrink the dialog while selecting cells with the mouse.
To illustrate how to use this tool, we again use the data set from Figure 334. Figure 341 shows
the six covariance values generated for this input data using the settings shown in Figure 340.
Tip
For more information on statistical covariance, refer to the corresponding Wikipedia
article at https://en.wikipedia.org/wiki/Covariance.
Input range
Specifies the cell range containing the source data.
Results to
Specifies the top left cell of the results area. When you run the tool, it will generate
smoothed results starting at this cell.
Columns / Rows
Specifies whether the data to be analyzed is organized in columns or rows.
Smoothing factor
Enter a value here between 0 and 1 (default is 0.2) that represents the damping factor
alpha in the smoothing equation.
Tip
Use the Shrink / Expand buttons next to the Input range and Results to fields if you
need to shrink the dialog while selecting cells with the mouse.
To illustrate how to use this tool, we use the data set shown in Figure 343. The table has two time
series representing impulse functions at times t=0 and t=2.
Tip
For more information on exponential smoothing, refer to the corresponding Wikipedia
article at https://en.wikipedia.org/wiki/Exponential_smoothing.
Tip
Use the Shrink / Expand buttons next to the Input range and Results to fields if you
need to shrink the dialog while selecting cells with the mouse.
To illustrate how to use this tool, we again use the data set from Figure 343. Figure 346 shows
the moving averages calculated for this input data using the settings shown in Figure 345.
Tip
For more information on the moving average, refer to the corresponding Wikipedia
article at https://en.wikipedia.org/wiki/Moving_average.
Regression tool
The Regression tool analyzes the relationship in a data set between one or more independent
variables and a dependent variable. Select Data > Statistics > Regression on the Menu bar to
access the Regression dialog (Figure 347).
Independent variable(s) (X) range
Specifies the cell range containing the independent variables in the source data.
Dependent variable (Y) range
Specifies the cell range containing the dependent variable in the source data.
Both X and Y ranges have labels
Specifies whether the ranges above include data labels.
Results to
Specifies the top left cell of the results area. When you run the tool, it will generate the
regression analysis table starting at this cell.
Columns / Rows
Specifies whether the data to be analyzed is organized in columns or rows.
Linear Regression
Select this option to use linear regression. Linear regression finds a straight line in the form
of y = (a * x) + b that best fits the data, where a is the slope and b is the intercept.
Logarithmic Regression
Select this option to use logarithmic regression. Logarithmic regression finds a logarithmic
curve in the form of y = (a * ln(x)) + b that best fits the data, where a is the slope, b
is the intercept and ln(x) is the natural logarithm of x.
Power Regression
Select this option to use power regression. Power regression finds a power curve in the
form of y = (a * x) ^ b that best fits the data, where a is the coefficient and b is the
exponent.
Tip
Use the Shrink / Expand buttons next to the Independent variable(s) (X) range,
Dependent variable (Y) range, and Results to fields if you need to shrink the dialog
while selecting cells with the mouse.
Tip
Calc utilizes the small, otherwise blank area above the Help, OK, and Cancel
buttons to provide feedback on erroneous selections on the dialog. For example, the
text “Independent variable(s) range is not valid.” appears if you have not entered a
valid cell range in the Independent variable(s) (X) range field, and in this
circumstance the OK button is grayed.
Tip
For more information on regression analysis, refer to the corresponding Wikipedia
article at https://en.wikipedia.org/wiki/Regression_analysis.
Tip
Use the Shrink / Expand buttons next to the Variable 1 range, Variable 2 range, and
Results to fields if you need to shrink the dialog while selecting cells with the mouse.
F-test tool
The F-test tool calculates the F-test of two data samples. The tool is used to test the hypothesis
that the variance of two populations are equal. Click Data > Statistics > F-test on the Menu bar
to access the F-test dialog shown in Figure 353 and define the required inputs to the tool.
Tip
Use the Shrink / Expand buttons next to the Variable 1 range, Variable 2 range, and
Results to fields if you need to shrink the dialog while selecting cells with the mouse.
To illustrate how to use this tool, we again use the data set from Figure 351. In this case, the data
in columns A and B represent two independent sample sets, referred to as Variable 1 and
Variable 2. Figure 354 shows the F-test results calculated for this input data using the settings
shown in Figure 353.
It is possible to insert different values for Alpha. The F Critical values (right-tail, left-tail, and two-
tail) will be updated automatically.
Tip
For more information on F-tests, refer to the corresponding Wikipedia article at
https://en.wikipedia.org/wiki/F-test.
Z-test tool
The Z-test tool calculates the Z-test of two data samples. The tool performs a two sample Z-test
to test the null hypothesis that there is no difference between the means of the two data sets.
The Z-test works better for large samples (n > 30); if you are using a small sample, the Paired t-
test tool may be more appropriate. Click Data > Statistics > Z-test on the Menu bar to access
the z-test dialog shown in Figure 355 and define the required inputs to the tool.
Variable 1 range
Specifies the cell range containing the first set of input data.
Variable 2 range
Specifies the cell range containing the second set of input data.
Results to
Specifies the top left cell of the results area. When you run the tool, it will generate the Z-
test table starting at this cell.
Columns / Rows
Specifies whether the data to be analyzed is organized in columns or rows.
Tip
For more information on z-tests, refer to the corresponding Wikipedia article at
https://en.wikipedia.org/wiki/Z-test.
Tip
Use the Shrink / Expand buttons next to the Input range and Results to fields if you
need to shrink the dialog while selecting cells with the mouse.
To provide an example of using this tool, we again make use of the input data set shown in
Figure 351. In this case the data in column A is the observed data while the data in column B are
the corresponding expected values. Figure 358 shows the chi-square results calculated for this
input data using the settings shown in Figure 357.
It is possible to insert different values for Alpha. The Critical Value will be updated automatically.
Tip
For more information on chi-square tests, refer to the corresponding Wikipedia article
at https://en.wikipedia.org/wiki/Chi-squared_test.
Tip
Use the Shrink / Expand buttons next to the Input range and Results to fields if you
need to shrink the dialog while selecting cells with the mouse.
Tip
Calc utilizes the small, otherwise blank area above the Help, OK, and Cancel
buttons to provide feedback on erroneous selections on the dialog. For example, the
text “Output address is not valid.” appears if you have not entered a valid cell range
in the Results to field, and in this circumstance the OK button is grayed.
To provide an example of using this tool, we make use of the input data set shown in columns B
(real values) and C (imaginary values) of the spreadsheet shown in Figure 360. The data shown
in columns E (real values) and F (imaginary values) of the spreadsheet are the Fourier transform
results calculated by the tool for this input data, using the settings shown in Figure 359.
Note
For those with a technical interest in the algorithms used by the Fourier Analysis tool,
a radix-2 decimation-in-time FFT is used when the length of the input sequence is an
even power of 2, while Bluestein’s FFT algorithm is used when the length of the input
sequence is not an even power of 2.
Tip
For more information on Fourier analysis, refer to the corresponding Wikipedia article
at https://en.wikipedia.org/wiki/Fourier_analysis.
Chapter 10
Linking Data
Sharing data in and out of Calc
Using multiple sheets
Why use multiple sheets?
Chapter 1, Introduction, introduced the concept of multiple sheets in a spreadsheet. Multiple
sheets help keep information organized; once you link those sheets together, you unleash the full
power of Calc. Consider this case:
John is having trouble keeping track of his personal finances. He has several bank
accounts and the information is scattered and disorganized. He can’t get a good grasp
on his finances until he can see everything at once.
To resolve this, John decides to track his finances in LibreOffice Calc. John knows Calc
can do simple mathematical computations to help him keep a running tab of his
accounts, and he wants to set up a summary sheet so that he can see all of his account
balances at once.
Note
For users with experience of using Microsoft Excel: what Excel calls a workbook,
Calc calls a spreadsheet (the whole document). Both Excel and Calc use the terms
sheet and worksheet.
Identifying sheets
When you open a new spreadsheet it has, by default, one sheet named Sheet1. You can specify
a different number of sheets to be created in a new document, or a different prefix name for new
sheets, by going to Tools > Options > LibreOffice Calc > Defaults on the Menu bar (Figure
361).
Sheets in Calc are managed using tabs located at the bottom of the spreadsheet.
Figure 362: Creating a new sheet through the sheet tabs area
The above methods use either the Insert Sheet dialog (Figure 363) or the Append Sheet dialog
(Figure 364).
On the Insert Sheet dialog you can:
• Choose whether to put the new sheet before or after the currently selected sheet tab.
• Choose how many sheets to insert.
Figure 365: From file area of Insert Sheet dialog showing file path
and names of available sheets
If you prefer, select the Link option to insert the external sheet as a link instead of as a copy. This
is one of several ways to include “live” data from another spreadsheet – see also “Linking to
external data” (page 381). The links can be updated manually to show the current contents of the
external file using Edit > Links to External Files on the Menu bar. Alternatively the links can be
updated automatically whenever the file is opened, depending on the options set on the dialog
accessed by selecting Tools > Options > LibreOffice Calc > General on the Menu bar. The
three options available in the Update links when opening section are Always (from trusted
locations), On request, and Never.
To define trusted file locations, select Tools > Options > LibreOffice > Security > Macro
Security (Trusted Sources tab) on the Menu bar. This is useful if you want to use macros in your
spreadsheet. For more information about macros see Chapter 12, Macros.
Note
The following characters are not allowed in sheet names: colon (:), back slash (\),
forward slash (/), question mark (?), asterisk (*), left square bracket ([), right square
bracket (]). The apostrophe (') character is not allowed as the first or last character
of the name.
Tip
In some LibreOffice Calc installations you can hold down the Alt key, click on the
sheet name, and enter the new name directly.
Now we will set up the account ledgers. This is just a simple summary that includes the previous
balance plus the amount of the current transaction. For withdrawals, we enter the current
transaction as a negative number so the balance gets smaller. A basic ledger is shown in Figure
368.
This ledger is set up in the sheet named Checking Account. The total balance is added up in cell
F3. You can see the equation for it in the Formula bar. It is the summary of the opening balance,
cell C3, and all of the subsequent transactions.
Note
The sheet name is in single quotation marks because it contains a space, and the
mandatory period (.) always falls outside any quotation marks.
So, you can fill in the Savings Account cell reference by just typing it in. Assuming that the
balance is in the same cell (F3) in the Savings Account sheet, the cell reference should be
=$'Savings Account'.F3 (Figure 374).
Note
The reference for a file has three forward slashes ///, while the reference for a
hyperlink has two forward slashes //. See “Using hyperlinks and URLs” below.
Tip
When you rest the mouse pointer on a hyperlink, a help tip displays the absolute
reference, because Calc uses absolute path names internally. The complete path
and address can only be seen when you view the result of the HTML export (saving
a spreadsheet as an HTML file), by loading the HTML file as text, or by opening it
with a text editor.
Creating hyperlinks
You can insert a hyperlink into a Calc spreadsheet using one of these methods:
• Place the text cursor at the point where you want to insert the hyperlink, or select the text
that you want to put the hyperlink on. Select Insert > Hyperlink on the Menu bar, or click
the Insert Hyperlink icon on the Standard toolbar, or press Ctrl+K, to access the
Hyperlink dialog; see “Hyperlink dialog” (page 377).
• Drag-and-drop an item from the Navigator to the point where you want to insert the
hyperlink (for example, a sheet or cell name).
• Type the target web address or URL at the point where you want to insert the hyperlink.
When you type text that can be used as a hyperlink (such as a website address or URL),
Calc formats it automatically, creating the hyperlink and applying color to the text. If this
does not happen, you can enable this feature using Tools > AutoCorrect Options >
Options on the Menu bar and selecting URL Recognition. Make sure you start the
hyperlink with ‘http://’, ‘www.’ or ‘ftp.’, if you type only libreoffice.org for
example, Calc won’t recognize it as a hyperlink.
When you use the Hyperlink dialog to insert a hyperlink, you can select either a text hyperlink
(Figure 377) or a button hyperlink (Figure 378). In both cases, the visible text can be different
from the linked URL.
To change the color of text hyperlinks, go to Tools > Options > LibreOffice > Application
Colors on the Menu bar, scroll to Unvisited links and/or Visited links, pick the new colors, and
click OK.
A button hyperlink is a type of form control. As with all form controls, it can be anchored or
positioned by right-clicking on the button in design mode. More information about forms can be
found in Chapter 18, Forms, of the Writer Guide.
Opening hyperlinks
To open a text hyperlink carry out one of the following actions:
• Ctrl-click with the cursor positioned over the hyperlink. This option is only available if the
Tools > Options > LibreOffice > Security > Security Options and Warnings >
Options > Ctrl-click required to open hyperlinks option is selected.
• Left-click with the cursor positioned over the hyperlink. This option is only available if the
Tools > Options > LibreOffice > Security > Security Options and Warnings >
Options > Ctrl-click required to open hyperlinks option is not selected.
• Right-click with the cursor positioned over the hyperlink and select the Open Hyperlink
option in the context menu.
To open a button hyperlink, left-click the button. This option is only available when the form
design mode is deactivated; the status of this mode is controlled by clicking the Design Mode
button in either the Form Controls toolbar or the Form Design toolbar.
Hyperlink dialog
You can insert and modify hyperlinks using the Hyperlink dialog (Figure 379). To display this
dialog, choose Insert > Hyperlink on the Menu bar, or click the Insert Hyperlink icon on the
Standard toolbar, or press Ctrl+K.
The Further Settings section on the Hyperlink dialog has some commonality for all the hyperlink
categories, although some choices are more relevant to some types of links and the Text option
is omitted from this area for Internet hyperlinks.
• Set the value of Frame to determine how the hyperlink will open. This applies to
documents that open in a web browser. Options are _top, _parent, _blank, and _self.
• Form specifies if the link is to be presented as text or as a button.
• Text specifies the text that will be visible to the user. If you do not enter anything here,
Calc will use the full URL or path as the link text. Note that if the link is relative and you
move the file, this text will not change, though the target will.
• Name is applicable to HTML documents. It specifies text that will be added as a NAME
attribute in the HTML code behind the hyperlink.
• Events button: this button will be activated to allow Calc to react to events for which the
user has written some code (macro). This function is not covered further in this chapter.
Editing hyperlinks
To edit an existing text hyperlink:
• If the Tools > Options > LibreOffice > Security > Security Options and Warnings >
Options > Ctrl-click required to open hyperlinks option is selected, then click the cell
containing the hyperlink. Select Insert > Hyperlink on the Menu bar, or click the Insert
Hyperlink icon on the Standard toolbar, or press Ctrl+K.
• Select the cell containing the hyperlink. In some cases you may need to select a nearby
cell that does not contain a hyperlink and use the arrow keys to move the selection to the
hyperlink cell. Select Insert > Hyperlink on the Menu bar, or click the Insert Hyperlink
icon on the Standard toolbar, or press Ctrl+K.
• Right-click on the hyperlink and select the Edit Hyperlink option in the context menu.
In all cases, Calc opens the Hyperlink dialog, enabling you to modify the characteristics of the
hyperlink.
For a button hyperlink, the spreadsheet must have the form design mode enabled in order to edit
the hyperlink. With the button selected, select Insert > Hyperlink on the Menu bar, or click the
Insert Hyperlink icon on the Standard toolbar, or press Ctrl+K. Make your changes and click OK.
If you need to edit several hyperlinks, you can leave the Hyperlink dialog open until you have
edited all of them. Be sure to click Apply after each one. When you are finished, click Close.
You can also edit a button hyperlink by selecting the button (with form design mode enabled),
right-clicking, and selecting Control Properties in the context menu. Calc displays the Properties
Removing hyperlinks
To remove a text or button hyperlink from the document completely, select it and use one of the
many available deletion mechanisms (for example, select Edit > Cut on the Menu bar or Cut on
the Standard toolbar; or right-click on the hyperlink and select Cut in the context menu; or press
Backspace or Delete on the keyboard).
Note
When you open a file that contains links to external data, depending on your settings
you may be prompted to update the links or they may be updated automatically.
Depending on where the linked files are stored, the update process can take several
minutes to complete.
a) Click OK on the Import Options dialog. Calc loads the list of available tables/ranges
into the Available Tables/Ranges area of the External Data dialog. The Web Page
Query import filter can create names for cell ranges as they are imported. As much
formatting as possible is retained while the filter intentionally does not import any
images. The filter additionally creates two additional entries in the list: HTML_all to
permit selection of the entire document and HTML_tables to permit selection of all the
tables.
b) In the Available Tables/Ranges area, select the named ranges or tables you want to
insert (hold Ctrl to select multiple entries). The OK button then becomes available.
8) For all external data source file types, you can also specify that the data is refreshed at a
specific frequency, defined in seconds.
9) Click OK to close the External Data dialog and insert the linked data.
Calc adds the new entry to the Linked areas list in the Navigator (Figure 387). If you double-click
this entry, Calc highlights the linked data within the sheet. When you hover the cursor over the
entry, a tooltip indicates the file location of the linked data.
Note
The Edit Links dialog can display information about other links that were not created
using the External Data dialog.
For links that have been created using the External Data dialog, you can access that dialog again
by selecting the link on the Edit Links dialog and clicking the Modify button, or double-clicking
the link. If you click Break Link and confirm that you want to remove the selected link, the
previously-linked data becomes embedded in the spreadsheet. Click Update to refresh the linked
data in the target file so that it matches that in the source file.
You can also change the drag mode by right-clicking on a range name and selecting the
required option in the context menu.
6) Select the required Range names or Database ranges entry and drag it from the
Navigator into the target document, to the cell where you want the upper left cell of the
data range to be.
7) Re-select the target document in the drop-down menu at the bottom of the Navigator.
Instead of a + icon next to Range names, it shows a + icon next to Linked areas. Click the
+ icon to see the entry dragged across from the source document, similar to Figure 387.
If the Formula bar is visible, the range name is also displayed in the Name Box at the left end
(Figure 393). The range name can be selected from the drop-down list to highlight it on the page.
Note
The OK button on the Create Database Link dialog is enabled only when both the
Database file and Registered name fields are filled in.
Note
The exact interactions required to connect to a database vary depending on the type
of database. Steps 3 and 4 assume that you selected a dBASE database type at step
2.
3) Click Next >. Type the path to the folder where the dBase files are stored or click Browse
and use the folder selection dialog to navigate to the relevant folder before clicking the
Select Folder button.
4) Click Next >. Select Yes, register the database for me, but clear the Open the
database for editing checkbox.
5) Click Finish. Name and save the database in the location of your choice.
Note
The above steps create a *.odb format database based on the content of the original
dBASE database. The original dBASE database remains unchanged.
Once a data source has been registered, it can be used by any LibreOffice component (for
example, Calc or Writer).
Note
If your OLE object is empty, inactive, and not displayed as an icon, then it will be
transparent.
Note
If the object inserted is handled by LibreOffice, then the transition to the program to
manipulate the object will be seamless; in other cases the object opens in a new
window and an option in the File menu becomes available to update the object you
inserted.
Note
This facility is not limited to LibreOffice files; you can create OLE objects using
existing files from many other applications.
3) To insert the object as a link to the original file, select the Link to file option. Otherwise,
the object will be embedded in your document.
4) If you want the object to appear as a selectable icon, rather than a section of your file,
select the Display as icon option.
5) Click the OK button. A section of the inserted file is shown in the document. If your source
spreadsheet has multiple sheets, it’s possible to navigate between them in the edit mode.
Note
You can only edit one copy of a spreadsheet at a time. If you have a linked OLE
spreadsheet object in an open Writer document and then open the same
spreadsheet in Calc, the Calc spreadsheet will be a read-only copy.
Note
When you open a spreadsheet containing linked data, you may get a warning
message indicating that automatic update of external links has been disabled. You
will need to click the Enable Content button to update the linked cells. You can
avoid this message and interaction by making sure that the spreadsheet containing
the original data is in a trusted file location and that the option is selected to always
update links from trusted locations when opening. Check these settings via Tools >
Options > LibreOffice > Security > Macro Security (Trusted Sources tab) and
Tools > Options > LibreOffice Calc > General (Update links when opening section)
respectively.
XML Source
The XML Source feature allows a user to import data from arbitrarily structured XML content into
cells in an existing spreadsheet document. It allows XML content to be imported either partially or
in full, depending on the structure of the XML content and the map definitions that the user
defines. The user can specify multiple non-overlapping sub-structures to be mapped to different
cell positions within the same document, and can select to import either element contents,
attribute values, or both.
Note:
The XML Source feature currently allows you to import XML data as a one-time
event; it will not store the information about the data source once the data is
imported.
Suppose that you have sales data in an XML file, such as the following:
<sales>
<sale>
<date>01/19/08</date>
<value>$2,032</value>
<category>Golf</category>
<region>West</region>
<employee>Brigitte</employee>
</sale>
<sale>
<date>01/25/08</date>
Chapter 11
Sharing and Reviewing
Spreadsheets
Introduction
This chapter covers methods for collaboration through sharing and reviewing spreadsheets:
simultaneous editing, recording changes, adding comments, reviewing changes, merging and
comparing documents, saving, and using document versions.
Some menu commands are not available (grayed out) when sharing or change tracking are
active.
Sharing spreadsheets
Sharing a spreadsheet allows several users to open the same file for editing at the same time.
The spreadsheet needs to be on a shared drive, server, website, or similar. Some conditions
must be met on operating systems with user permission management:
• The shared file needs to reside in a location which is accessible by all collaborators.
• The file permissions for both the document and the corresponding lock file need to be set
so that all collaborators can create, delete, and change the files.
Consult your operating system’s documentation for details on setting file permissions. See also
“Opening and saving files on remote servers” in Chapter 1, Introducing LibreOffice, in the Getting
Started Guide.
Tip
In order to correctly identify the changes, each collaborator should enter their name in
Tools > Options > LibreOffice > User Data on the Menu bar.
• If the changes conflict, the Resolve Conflicts dialog (Figure 412) is shown. You must
decide for each conflict which version to keep, yours or the other person’s. When all
conflicts are resolved, the document is saved. While you are resolving the conflicts, no
other user can save the shared document.
• If another user is trying to save the shared spreadsheet and resolve conflicts, they see a
message that the file is locked due to a merge in progress. They can cancel the Save
command and retry saving later.
When you successfully save a shared spreadsheet, the document shows the latest version of all
changes saved by all users.
Reviewing documents
You can use several methods to review, edit, and comment on a spreadsheet. Each reviewer
works on a separate copy of the document.
• You can use change marks to show added and deleted material. Later, you or another
person can review the document and accept or reject each change.
• You can make changes to a copy of the document (stored in a different folder, under a
different name, or both), then use Calc to compare the files and show the changes. See
“Comparing documents” on page 413.
• You can save versions that are stored as part of the original file. See “Saving versions”
on page 414.
Reviewers can leave comments in the document, either attached to specific changes or
standalone.
Recording changes
To record changes, open the spreadsheet and make sure that the Edit > Track Changes >
Record menu item has a check mark next to it, indicating that change recording is active.
Caution
After making some changes, do not turn off change recording. Turning off change
recording in Calc causes all the recorded changes to be accepted and no longer
shown as changes. A message box will warn if you try to do this.
When changes are made in a cell, a colored border with a dot in the upper left-hand corner
appears around the cell (Figure 413). A deleted column or row is marked by a heavy colored bar.
Note
Some changes, for example cell formatting, are not recorded and marked.
Tip
To change the color that indicates a changed cell, select Tools > Options >
LibreOffice Calc > Changes on the Menu bar.
Note
Do not use Insert > Comment on the Menu bar or the context menu for this
purpose. Comments inserted using that method are handled differently (see “Adding
other (general) comments” on page 410) and do not appear in the Manage Changes
dialog.
The comment also appears on the Manage Changes dialog when you are accepting and
rejecting changes, as shown in the first line of Figure 420 on page 412.
3) Type your comment in the box, then click outside the box to close it.
Now the cell to which you added the comment has a colored dot in the upper right-hand corner,
as shown in Figure 418. It does not have a colored border, unless the cell was also changed.
Tip
You can change the colors Calc uses for comments by selecting Tools > Options >
LibreOffice > Application Colors and adjusting the color for Notes background in
the Spreadsheet section.
To view the comment you just added, hover the mouse pointer over the cell that has a comment.
The comment appears, as shown below.
Note
View > Comments and the Navigator show general comments but not the
comments associated with tracked changes.
On the Filter tab of this dialog (Figure 421), you can choose how to filter the list of changes: by
date, author, cell range, or comments containing specific terms. After selecting the filter criteria,
switch back to the List tab to see the results. Filtering the changes affects only the contents of the
List tab on the dialog, you will not see any filtered results in your spreadsheet.
Merging documents
The processes discussed to this point are effective when you have one reviewer at a time.
Sometimes, however, multiple reviewers all return edited versions of a document at the same
time. In this case, it may be faster to review all of the changes at once, rather than one review at
a time. For this purpose, you can merge documents in Calc.
To merge documents, all of the edited documents need to have recorded changes in them.
1) Open the original document.
2) Select Edit > Track Changes > Merge Document on the Menu bar.
3) A file selection dialog opens. Select a file you want to merge and click Open.
4) After the documents merge, the Manage Changes dialog opens, showing changes by
more than one reviewer. If you want to merge more documents, close the dialog and then
repeat steps 2 and 3.
Now all of the changes are combined into one document and you can accept or reject the
changes. Changes from different authors appear in cells outlined in different colors.
Comparing documents
Sometimes reviewers may not record the changes they make. Calc can find the changes by
comparing documents.
In order to compare documents you need to have the original document and the one that is
edited. To compare them:
1) Open the edited document that you want to compare with the original document.
Saving versions
For auditing and other purposes, you may need to save new versions of a spreadsheet. You can
do this by saving a copy of the spreadsheet (under a different name) after each revision, or by
using Calc’s version feature.
Caution
If you select File > Save As on the Menu bar, or press Ctrl+Shift+S, for a document
with different versions stored in it, the old versions are not saved in the new file.
Chapter 12
Macros
Automating repetitive tasks
Introduction
Chapter 13 of the Getting Started Guide (entitled Getting Started with Macros) is an introduction
to the macro facilities that are available in LibreOffice. The current chapter provides further
introductory information about the use of macros within a Calc spreadsheet.
A macro is a set of commands or keystrokes that are stored for later use. An example of a simple
macro is one that enters your address into the current cell of an open spreadsheet. You can use
macros to automate both simple and complex tasks, and they enable you to introduce new
features that are not built into Calc.
The simplest way to create a macro is to record a series of actions through Calc’s user interface.
Calc saves recorded macros using the open source LibreOffice Basic scripting language, which
is a dialect of the well-known BASIC programming language. Such macros can be edited and
enhanced after recording using the built-in LibreOffice Basic Integrated Development
Environment (IDE).
The most powerful macros in Calc are created by writing code using one of the four supported
scripting languages (LibreOffice Basic, BeanShell, JavaScript, and Python). This chapter
provides an overview of Calc’s macro facilities, mostly focused on its default macro scripting
language, LibreOffice Basic. Some examples are included for the BeanShell, JavaScript, and
Python scripting languages but fuller descriptions of the facilities for these languages are beyond
the scope of this document.
Note
Use Tools > Options > LibreOffice > Advanced on the Menu bar and select the
Enable macro recording (may be limited) option to enable the macro recorder.
1) Use File > New > Spreadsheet on the Menu bar to create a new spreadsheet.
2) Enter the numbers shown in Figure 425 into cells A1:C3 of Sheet1 in the new
spreadsheet.
8) Click the Stop Recording button to stop the macro recorder. Calc displays a variant of
the Basic Macros dialog (Figure 429).
Note
The Save Macro In area of the Basic Macros dialog shows the existing LibreOffice
Basic macros, hierarchically structured into library containers, libraries, modules, and
macros as described in Chapter 13 of the Getting Started Guide. Figure 429 shows
the My Macros library container, the LibreOffice Macros library container, the library
container for the open balance.ods file, and the library container for the untitled file
created at step 1. Use the expand / collapse icons to the left of each library container
name to view the libraries, modules and macros within that container.
11) Click the OK button to create a new module. As no macro libraries exist in our current
document, Calc automatically creates and uses a Standard library.
12) On the Basic Macros dialog, select the entry for the newly created module in the Save
Macro In area, type the text PasteMultiply in the Macro Name box, and click the Save
button (Figure 431).
sub PasteMultiply
rem --------------------------------------------------------------
rem define variables
dim document as object
dim dispatcher as object
rem --------------------------------------------------------------
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem --------------------------------------------------------------
dim args1(5) as new com.sun.star.beans.PropertyValue
end sub
Note
The component model used in LibreOffice is Universal Network Objects (UNO) and
the macro recorder uses the UNO dispatcher for most commands. However, there
are two problems associated with this technical approach. One is that the dispatches
are not fully documented and may be subject to change. Another is that the recorder
ignores some values from dialogs that are opened while recording a macro – it is
possible, therefore, that you will record a complicated macro that will not actually
execute everything as expected. For more information, search for “macro recording –
limitations” in the Help index.
Figure 436 shows the default configuration for the LibreOffice Basic IDE. This comprises:
• A menu bar.
• Two toolbars (Macro and Standard). The Macro toolbar provides various icons for
editing and testing programs.
• The Object Catalog, enabling selection of the required library container, library,
module, and macro.
• The Editor Window, in which you can edit the LibreOffice Basic program code. The
column on the left side is used to set breakpoints in the program code.
• The Watch Window (located at the left, below the Object Catalog and Editor
Window) displays the contents of variables or arrays during a single step process.
• The Calls Window (located to the right, below the Object Catalog and Editor
Window) provides information about the call stack of procedures and functions
when a program runs.
• A tab control area.
• A status bar.
The LibreOffice Basic IDE provides powerful facilities for the development and debugging
of LibreOffice Basic macros. A fuller description of this facility is beyond the scope of this
document, but more information can be found in the Help system.
7) In the Editor Window, modify the code so that it is the same as that shown in Listing
2.The important addition is the creation of the NumberFive function, which returns the
value 5.
Sub Main
End Sub
Function NumberFive ()
NumberFive = 5
End Function
8) Within the LibreOffice Basic IDE select File > Save on the Menu bar, or click the Save
icon on the Standard toolbar, or press Ctrl+C, to save the modified Module1.
Tip
Function names are not case sensitive. In Figure 437, the function name was
entered as NumberFive() but Calc displays it as NUMBERFIVE() in the Formula
bar.
Function NumberFive_Implementation ()
NumberFive_Implementation = 5
End Function
3) Click the Select Macro button in the Standard toolbar of the LibreOffice Basic IDE to
open the Basic Macros dialog (Figure 442).
Function NumberFive()
If NOT BasicLibraries.isLibraryLoaded("AuthorsCalcMacros") Then
BasicLibraries.LoadLibrary("AuthorsCalcMacros")
End If
NumberFive = NumberFive_Implementation()
End Function
6) Save, close, and reopen the Calc document. This time, if macros are enabled, the
NumberFive() function works as expected.
Function PositiveSum(Optional x)
Dim TheSum As Double
Dim iRow As Integer
Dim iCol As Integer
TheSum = 0.0
If NOT IsMissing(x) Then
If NOT IsArray(x) Then
If x > 0 Then TheSum = x
Else
For iRow = LBound(x, 1) To UBound(x, 1)
For iCol = LBound(x, 2) To UBound(x, 2)
If x(iRow, iCol) > 0 Then TheSum = TheSum + x(iRow, iCol)
Next
Next
End If
End If
PositiveSum = TheSum
End Function
The macro in Listing 5 demonstrates some important techniques:
1) The argument x is Optional. When an argument is not Optional and the function is
called without it, Calc outputs a warning message every time the macro is called. If Calc
calls the function many times, then the error is displayed many times.
2) The function IsMissing checks that an argument was passed before it is used.
3) The function IsArray checks to see if the argument is a single value, or an array. For
example, =PositiveSum(7) or =PositiveSum(A4). In the first case, the number 7 is
Tip
The macro in Listing 5 is careful and checks to see if the argument is an array or a
single argument. The macro does not verify that each value is numeric. You may be
as careful as you like. The more things you check, the more robust the macro is, but
the slower it runs.
Passing one argument is as easy as passing two: add another argument to the function definition
(see Listing 6). When calling a function with two arguments, separate the arguments with a
comma; for example, =TestMax(3, -4).
Listing 6. TestMax accepts two arguments and returns the larger
Function TestMax(x, y)
If x >= y Then
TestMax = x
Else
TestMax = y
End If
End Function
Function SumCellsAllSheets()
Dim TheSum As Double
TheSum = 0
oSheets = ThisComponent.getSheets()
For i = 0 To oSheets.getCount() - 1
oSheet = oSheets.getByIndex(i)
oCell = oSheet.getCellByPosition(0, 1) ' GetCell A2
TheSum = TheSum + oCell.getValue()
Next
SumCellsAllSheets = TheSum
End Function
Tip
A cell object supports the methods getValue(), getString(), and getFormula() to get
the numerical value, the string value, or the formula used in a cell. Use the
corresponding set functions to set appropriate values.
Function SumCellsAllSheets()
Dim TheSum As Double
Dim iRow As Integer, iCol As Integer, i As Integer
Dim oSheets, oSheet, oCells
Dim oRow(), oRows()
TheSum = 0
oSheets = ThisComponent.getSheets()
For i = 0 To oSheets.getCount() - 1
oSheet = oSheets.getByIndex(i)
oCells = oSheet.getCellRangeByName("A2:C5")
oRows() = oCells.getData()
For iRow = LBound(oRows()) To UBound(oRows())
oRow() = oRows(iRow)
For iCol = LBound(oRow()) To UBound(oRow())
TheSum = TheSum + oRow(iCol)
Next
Next
Next
SumCellsAllSheets = TheSum
End Function
Sorting
Consider sorting the data shown in Figure 444. First, sort on column B descending and then on
column A ascending.
Sub SortRange
Dim oSheet ' Calc sheet containing data to sort.
Dim oCellRange ' Data range to sort.
BeanShell macros
BeanShell is a Java-like scripting language that was first released in 1999.
When you select Tools > Macros > Organize Macros > BeanShell on the Menu bar, Calc
displays the BeanShell Macros dialog (Figure 446).
Click the Edit button on the BeanShell Macros dialog to access the BeanShell Debug Window
(Figure 447).
Listing 10 is an example of a BeanShell macro that inserts the text “Hello World from BeanShell”
in cell A1 of the active Calc spreadsheet.
import com.sun.star.uno.UnoRuntime;
import com.sun.star.sheet.XSpreadsheetView;
import com.sun.star.text.XText;
model = XSCRIPTCONTEXT.getDocument();
controller = model.getCurrentController();
sheet = view.getActiveSheet();
textCursor = cellText.createTextCursor();
return 0;
JavaScript macros
JavaScript is a high-level scripting language that was first released in 1995.
When you select Tools > Macros > Organize Macros > JavaScript on the Menu bar, Calc
displays the JavaScript Macros dialog (Figure 448).
Listing 11 is an example of a JavaScript macro that inserts the text “Hello World from JavaScript”
in cell A1 of the first sheet in a Calc spreadsheet.
Listing 11. Sample JavaScript macro
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.sheet.XSpreadsheetDocument);
importClass(Packages.com.sun.star.container.XIndexAccess);
importClass(Packages.com.sun.star.table.XCellRange);
importClass(Packages.com.sun.star.table.XCell);
documentRef = XSCRIPTCONTEXT.getDocument();
allSheets = UnoRuntime.queryInterface(XIndexAccess,
spreadsheetInterface.getSheets());
theSheet = allSheets.getByIndex(0);
Cells = UnoRuntime.queryInterface(XCellRange,theSheet);
cellA1 = Cells.getCellByPosition(0,0);
theCell = UnoRuntime.queryInterface(XCell,cellA1);
Python macros
Python is a high-level, general-purpose programming language that was first released in 1991.
When you select Tools > Macros > Organize Macros > Python on the Menu bar, Calc displays
the Python Macros dialog (Figure 450).
import uno
def HelloWorld():
doc = XSCRIPTCONTEXT.getDocument()
cell = doc.Sheets[0]['A1']
cell.setString('Hello World from Python')
return
Note
The support for VBA is not complete, but covers a large portion of the common
usage patterns.
When VBASupport is enabled, LibreOffice Basic function arguments and return values are the
same as their VBA counterparts. When the support is disabled, LibreOffice Basic functions may
accept arguments and return values different from their VBA counterparts.
Listing 13. Option VBASupport usage
Option VBASupport 1
Sub Example
Dim sVar As Single
sVar = Worksheets("Sheet1").Range("A1")
Print sVar
End Sub
Without the Option VBASupport statement, the code in Listing 13 must be converted to the
LibreOffice Basic of Listing 14.
Listing 14. Converted VBA code
Sub Example
Dim sVar As Single
Dim oSheet as Object
Dim oCell as Object
REM Worksheets(“Sheet1”).
Sub MyProc
MyForm.Show
End Sub
Listing 16. LibreOffice Basic display of a UserForm [Dialog] called “MyForm”
Note
The oDlg variable is visible at the module level to all other procedures that are
accessing controls on the dialog. This means all the procedures manipulating or
accessing controls on this dialog panel are housed in a single module.
Conclusion
This chapter provides an overview of how to create libraries and modules, using the macro
recorder, using macros as Calc functions, writing your own macros without the macro recorder
and converting VBA to LibreOffice Basic. Each topic deserves at least one chapter, and writing
your own macros for Calc could easily fill an entire book. In other words, this is just the beginning
of what you can learn.
Chapter 13
Calc as a Database
A guide for users and macro programmers
Introduction
In many everyday scenarios, Calc spreadsheets can be used to aggregate sets of data and to
perform analyses on them. As the data in a spreadsheet is laid out in a table view, plainly visible
and easily edited or extended, some users may not need the comprehensive relational database
facilities provided by the Base component of LibreOffice. For such users, Calc has sufficient
functionality to act as a simple yet capable database-like platform. This chapter presents an
overview of these capabilities and explains them using LibreOffice Basic macros and user
interface examples.
For those users who initially choose to manage their data in a Calc spreadsheet and
subsequently decide that they need to use a more comprehensive database system, migrating
Calc data to Base is straightforward. See the Base Guide for more information.
Though it was created for macro programmers, this chapter is intended to be accessible for all
users. If you do not want to use macros, simply skip the sections that deal with them. However, if
you are interested in learning more about them, see Chapter 12, Macros, and Andrew Pitonyak’s
book, OpenOffice.org Macros Explained (OOME). Much of the macro information in this chapter
is drawn or adapted from the OOME and LibreOffice’s API reference at
https://api.libreoffice.org/docs/idl/ref/index.html.
A database primer
In a typical database, related data is organized into tables, which are arranged in a grid-like
series of rows and columns similar to a spreadsheet. Each row of a table represents a data
record, while each column represents a field within each record. Each cell in a field contains an
individual data item or attribute, such as a name, while each record consists of related attributes
that correspond to a single entity, like a person. A database table tends to have a fixed number of
fields, but can have an indefinite number of records.
While a table may have hundreds or thousands of rows, individual records can be easily found,
retrieved, and updated using information requests, called queries, that search for records that
meet a specified set of criteria. It is this ease of access that makes a database table more useful
than simply filing away information in an unordered spreadsheet.
To illustrate this concept of a database table, consider the example of a class grading sheet
(Figure 452). In this sheet, each row represents individual students taking the class, while each
column contains their names and grades. With this table, you can quickly look up individual
students’ grades simply by searching for their names, and you can determine which students are
passing the class by filtering out records with failing average scores.
Named ranges
Standard named ranges are created using the Define Name dialog (Figure 453), which is opened
by selecting Sheet > Named Ranges and Expressions > Define on the Menu bar.
As an example, the macro in Listing 17 uses the above methods to check if a range named
MyNRange exists. If it does not exist, then the macro creates a range with the name and sets it
to access the cell range B3:D6.
Listing 17: AddNamedRange creates a new named range that references $Sheet1.$B$3:$D$6
Sub AddNamedRange()
Dim oRange ' The created range.
Dim oRanges ' All named ranges.
Dim sName$ ' Name of the named range to be created.
Dim oCell ' Cell object.
Dim s$
sName$ = "MyNRange"
oRanges = ThisComponent.NamedRanges
If NOT oRanges.hasByName(sName$) Then
REM Setting the base address for relative cell references
Dim oCellAddress As new com.sun.star.table.CellAddress
Note
For more information about absolute and relative references, see Chapter 7, Using
Formulas and Functions.
Sub AddNamedFunction()
Dim oSheet 'Sheet that contains the range oRange.
Dim oCellAddress 'Address for relative references.
sName = "AddLeft"
oRanges = ThisComponent.NamedRanges
If NOT oRanges.hasByName(sName) Then
oSheet = ThisComponent.getSheets().getByIndex(0)
oRange = oSheet.getCellRangeByName("C3")
oCellAddress = oRange.getCellAddress()
oRanges.addNewByName(sName, "A3+B3", oCellAddress, 0)
End If
End Sub
Tip
Listing 18 illustrates another little-known attribute of Calc: named ranges are a
subset of named expressions, which can include formulas as well.
Note
Header cells are not included in the named ranges generated using the Create
Names tool. This is because the labels in each of these cells are used to name the
ranges.
Tip
To generate names from multiple borders, you must call addNewFromTitles for each
header row or column that you wish to use.
The macro in Listing 19 creates three named ranges using headers from the top row of the range
A1:C20 (Figure 457). Figure 458 shows the resulting ranges listed in the Manage Names dialog,
which is accessed by selecting Sheet > Named Ranges and Expressions > Manage on the
Menu bar or pressing Ctrl+F3.
Sub AddManyNamedRanges()
Dim oSheet 'Sheet that contains the named range.
Dim oAddress 'Range address.
Dim oRanges 'The NamedRanges property.
Dim oRange 'Single cell range.
oRanges = ThisComponent.NamedRanges
oSheet = ThisComponent.getSheets().getByIndex(0)
oRange = oSheet.getCellRangeByName("A1:C20")
oAddress = oRange.getRangeAddress()
oRanges.addNewFromTitles(oAddress, com.sun.star.sheet.Border.TOP)
End Sub
Database ranges
Although it can be used like a regular named range, a database range is, unsurprisingly, meant
to be used like a database table, with each row representing a record and each cell a field within
a record. Specifically, a database range differs from a named range in the following ways:
• A database range cannot be a formula expression, only a cell range. This range can be
formatted as a table, with the first row reserved for headings and the last row for
subtotals. Cell formatting can also be preserved for each field in the table.
• Database ranges cannot be referenced relative to a base address within a sheet.
• Database ranges store sorting, filtering, subtotaling, and data import settings in data
structures called descriptors, which can be retrieved and accessed using macros.
• A database range can be linked to an external database source, and can be refreshed by
selecting Data > Refresh Range on the Menu bar. Registering and linking to external
database sources are explained in more detail in Chapter 10, Linking Data.
• Database ranges can be created, modified, and deleted using the Define Database
Range dialog, which is opened by selecting Data > Define Range on the Menu bar
(Figure 459).
Sub AddNewDatabaseRange()
Dim oRange 'DatabaseRange object.
Dim oAddr 'Cell address range for the database range.
Dim oSheet 'First sheet, which will contain the range.
Dim oDoc 'Reference ThisComponent with a shorter name.
oDoc = ThisComponent
If NOT oDoc.DatabaseRanges.hasByName("MyName") Then
oSheet = ThisComponent.getSheets().getByIndex(0)
oRange = oSheet.getCellRangeByName("A1:F10")
oAddr = oRange.getRangeAddress()
oDoc.DatabaseRanges.addNewByName("MyName", oAddr)
End If
oRange = oDoc.DatabaseRanges.getByName("MyName")
oRange.AutoFilter = True
End Sub
Sub SortAverageGrade
Dim oSheet
Dim oRange
Dim oSortFields(0) as new com.sun.star.util.SortField
Dim oSortDesc(0) as new com.sun.star.beans.PropertyValue
oSheet = ThisComponent.Sheets(0)
REM Set the range on which to sort
oRange = oSheet.getCellRangeByName("A1:H11")
Figure 462: Grading sheet after sorting by average grade in descending order
Sub SortByQuizScores
Dim oSheet
Dim oRange
Dim oSortFields(1) as new com.sun.star.util.SortField
Dim oSortDesc(0) as new com.sun.star.beans.PropertyValue
oSheet = ThisComponent.Sheets(0)
Sub DisplaySortDescriptor
On Error Resume Next
Filtering
A filter is a tool that hides or displays records within a sheet based on a set of filtering criteria.
Similar to sorting, filters are useful for narrowing down long lists of data in order to find particular
data items. In Calc, three types of filter exist:
• AutoFilters
• Standard filters
• Advanced filters.
Filters are also described in Chapter 2, Entering, Editing, and Formatting Data.
Standard filters
Standard filters are more complex than AutoFilters, and allow for up to eight filter conditions.
Also, unlike AutoFilters, standard filters use a dialog (Figure 466), which is accessed by selecting
Data > More Filters > Standard Filter on the Menu bar.
For more information on how to use this dialog and its options, see Chapter 2, Entering, Editing,
and Formatting Data.
Sub SimpleSheetFilter()
Dim oSheet ' Sheet that will contain the filter.
Dim oFilterDesc ' Filter descriptor.
Dim oFields(0) As New com.sun.star.sheet.TableFilterField
With oFields(0)
REM You could use the Connection property to indicate
REM how to connect to the previous field. This is
REM the first field, so this is not required.
'.Connection = com.sun.star.sheet.FilterConnection.AND
'.Connection = com.sun.star.sheet.FilterConnection.OR
Note
When the filter method is called on a sheet, every empty row in the sheet is hidden.
When filter is called on a range, only empty rows in the range itself are hidden.
Sub RemoveSheetFilter()
Dim oSheet ' Sheet to filter.
Dim oFilterDesc ' Filter descriptor.
oSheet = ThisComponent.getSheets().getByIndex(0)
oFilterDesc = oSheet.createFilterDescriptor(True)
oSheet.filter(oFilterDesc)
End Sub
Sub SimpleRangeFilter()
Dim oSheet ' Sheet to filter.
Dim oRange ' Range to be filtered.
Dim oFilterDesc ' Filter descriptor.
Dim oFields(1) As New com.sun.star.sheet.TableFilterField
oFilterDesc.setFilterFields(oFields())
oFilterDesc.ContainsHeader = True
oFilterDesc.UseRegularExpressions = True
oRange.filter(oFilterDesc)
End Sub
Figure 468: Grading sheet filtered by Test #1 scores <= 90% and student names
that begin with “B”
Sub AdvancedRangeFilter()
Dim oSheet 'A sheet from the Calc document.
Dim oRanges 'The NamedRanges property.
Dim oCritRange 'Range that contains the filter criteria.
Dim oDataRange 'Range that contains the data to filter.
Dim oFiltDesc 'Filter descriptor.
oFiltDesc = oCritRange.createFilterDescriptorByObject(oDataRange)
oDataRange.filter(oFiltDesc)
Table 21 contains a list of properties that correspond to advanced and standard filter settings.
Table 21: Advanced and standard filter properties
Function Description
ContainsHeader Boolean (TRUE/FALSE) that specifies if the first row or column
contains headers which should not be filtered.
CopyOutputData Boolean that specifies if the filtered data should be copied to another
position in the document.
IsCaseSensitive Boolean that specifies if the case of letters is important when
comparing entries.
Orientation An enumeration that specifies if a range is filtered by column or row:
Column – com.sun.star.table.TableOrientation.COLUMNS
Row – com.sun.star.table.TableOrientation.ROWS
OutputPosition If CopyOutputData is TRUE, this property specifies the position where
filtered data are to be copied.
SaveOutputPosition Boolean that specifies if the OutputPosition position is saved for future
calls.
SkipDuplicates Boolean that specifies if duplicate entries are left out of the result.
UseRegularExpressions Boolean that specifies if the filter strings are interpreted as regular
expressions.
Note
Functions with the suffix -A treat text values as a number with the value of zero.
Blank cells are still ignored by these functions.
Database-specific functions
Some Calc functions are specifically designed for use with a database table. With one exception
(DGET), these functions are specialized forms of commonly-used functions such as COUNT, and
all are denoted with the D- prefix (such as DAVERAGE). A brief list of these functions is given in
Table 22, while more detailed descriptions of all Calc’s functions are presented in the Help
system.
Note
Table 22 uses the following terms interchangeably: row and record; column and field.
Chapter 14
Setting up and Customizing
Introduction
This chapter presents some of the setup options found under Tools > Options on the Menu bar
(LibreOffice > Preferences on macOS). Additional options, and more details about those given
here, are covered in the Help and in Chapters 2 (Setting up LibreOffice) and 14 (Customizing
LibreOffice) in the Getting Started Guide.
This chapter also describes some common customizations to menus, toolbars, and keyboard
shortcuts. Other customizations are made easy by extensions that you can install from the
LibreOffice website or from other providers.
LibreOffice options
This section covers some of the settings that apply to all the components of LibreOffice and are
of particular interest to users of Calc. Other general options are discussed in Chapter 2, Setting
up LibreOffice, in the Getting Started Guide.
1) Choose Tools > Options to open the Options dialog. The list on the left-hand side varies
depending on which LibreOffice component is open. The illustrations in this chapter show
the list as it appears when Calc is open.
2) Click the expansion symbol (+ or triangle) next to LibreOffice. A list of subsections drops
down.
User data
User data is used by templates and wizards in LibreOffice. For example, Calc uses the first and
last name stored here to fill in the Created and Modified fields in the document properties. These
fields may also be used in the footer of a printed spreadsheet or as the name associated with
comments. If you want your name to appear, then fill in the form on the LibreOffice – User Data
page.
View
The options on the LibreOffice – View page affect how the document window looks and behaves,
including the size and style of toolbar and Sidebar icons. Set these options to suit your personal
preferences.
Print
On the LibreOffice – Print page, you can set the print options to suit your default printer and your
most common printing method. You can change these settings at any time, either through this
dialog or during the printing process (through the Print dialog).
Calc-specific print options are described in “Print options” on page 491.
See Chapter 6, Printing, Exporting, E-mailing, and Signing, for more about these options.
Paths
On the LibreOffice – Paths page, you can change the location of files associated with, or used by,
LibreOffice to suit your needs. For example, you might want to store spreadsheets by default on
a shared server. Some items can have at least two paths listed: one to a shared folder (which
might be on a network) and one to a user-specific folder (normally on the user’s personal
computer).
Security
Use the LibreOffice – Security page to choose security options for saving documents and for
opening documents that contain macros.
Note
The Certificate Path option appears only on Linux and macOS systems. On
Windows, LibreOffice uses the default Windows location for storing and retrieving
certificates.
Application colors
On the LibreOffice – Application Colors page (Figure 476), you can specify which user interface
elements are visible and the colors used to display them. Scroll down the list until you find the
section headed Spreadsheet. To change the default color for Grid lines or other on-screen
indicators, click the down-arrow by the color and select a new color from the drop-down list.
If you wish to save your color changes as a color scheme, click Save, type a name in the Name
of color scheme box in the pop-up dialog, and then click OK.
Advanced options
Two items of interest on this page are found under Optional Features:
Enable experimental features (may be unstable)
Selecting this option enables features that are not yet complete or contain known bugs. The
list of these features is different version by version.
Enable macro recording (may be limited)
This option enables macro recording, with some limitations. For more about macro
recording, see Chapter 13, Getting Started with Macros, in the Getting Started Guide, and
Chapter 12, Macros, in this book.
VBA Properties
On the Load/Save – VBA Properties page (Figure 478), you can choose whether to keep any
VBA (Visual Basic for Applications) macros in Microsoft Office documents that are opened in
LibreOffice.
If you choose Load Basic code, you can edit the macros in LibreOffice. The changed code is
saved in an ODF document but is not retained if you save into a Microsoft Office format.
If you choose Save original Basic code, the macros will not work in LibreOffice but are retained
unchanged if you save the file into Microsoft Office format.
If you are importing a Microsoft Word or Excel file containing VBA code, you can select the option
Executable code. Whereas normally the code is preserved but rendered inactive (if you inspect
it with the LibreOffice Basic IDE you will notice that it is all commented), with this option the code
is ready to be executed.
Save original Basic code takes precedence over Load Basic code. If both options are selected
and you edit the disabled code in LibreOffice, the original Microsoft Basic code will be saved
when saving in a Microsoft Office format.
To remove any possible macro viruses from the Microsoft Office document, deselect Save
original Basic code. The document will be saved without the Microsoft Basic code.
Microsoft Office
On the Load/Save – Microsoft Office page (Figure 479), you can choose what to do when
importing and exporting Microsoft Office OLE objects (linked or embedded objects or documents
such as spreadsheets or equations): convert them into or from the corresponding LibreOffice
OLE object or load and save them in their original format.
Select the [L] options to convert Microsoft OLE objects into the corresponding LibreOffice OLE
objects when a Microsoft document is loaded into LibreOffice.
Select the [S] options to convert LibreOffice OLE objects into the corresponding Microsoft OLE
objects when a document is saved in a Microsoft format.
The Character Highlighting options enable a user to select between the two text highlighting
(character background) attributes that Microsoft Office provides, Highlighting or Shading.
Shading is the initial default.
The Create MSO lock file checkbox improves interoperability with Microsoft Office for shared
spreadsheets. When enabled, Calc writes two lock files when opening a Microsoft Office format
file, one LibreOffice lock file and one Microsoft Office lock file. This enables users of both suites
to be made aware that the file is in use. The option is initially disabled by default.
HTML Compatibility
Choices made on the Load/Save – HTML Compatibility page (Figure 480) affect HTML pages
imported into LibreOffice and those exported from LibreOffice. See Chapter 2, Setting up
LibreOffice, in the Getting Started Guide, and HTML documents; importing/exporting in the Help,
for more information.
The main items of interest for Calc users are in the Export section.
LibreOffice Basic
Select this option to include LibreOffice Basic macros (scripts) when exporting to HTML
format. You must activate this option before you create the LibreOffice Basic macro;
otherwise the script will not be inserted. LibreOffice Basic macros must be located in the
header of the HTML document. Once you have created the macro in the LibreOffice Basic
IDE, it appears in the source text of the HTML document in the header.
If you want the macro to run automatically when the HTML document is opened, choose
Tools > Customize > Events. See Chapter 12, Macros, for more information.
Display warning
When the LibreOffice Basic option (see above) is not selected, the Display warning
option becomes available. If the Display warning option is selected, then when exporting
to HTML a warning is shown that LibreOffice Basic macros will be lost.
Print layout
Select this option to export the print layout of the current document as well. The HTML filter
supports CSS2 (Cascading Style Sheets Level 2) for printing documents. These
capabilities are only effective if print layout export is activated.
Copy local images to Internet
Select this option to automatically upload the embedded pictures to the Internet server
when uploading using FTP.
Calc-specific options
Calc must be open in order for the LibreOffice Calc options to be displayed in the Options dialog.
Click the expansion symbol (+ or triangle) by LibreOffice Calc. A list of subsections drops down
(Figure 482).
General
The choices on the LibreOffice Calc – General page (Figure 482) affect the units used for rulers
and other measurements, the default tab stop positions, the updating of links and fields, and
various input settings.
Metrics
Choose the unit of measurement used in spreadsheets and the default tab stops distance.
Defaults
On the LibreOffice Calc – Defaults page you can enter the number of sheets to be opened by
default when you start a new spreadsheet, and either accept the default sheet prefix or type a
new one. After a spreadsheet has been created, you can add new sheets and change the label of
any tab; see Chapter 1, Introduction, for more information.
View
The options on the LibreOffice Calc – View page (Figure 483) affect the way the document
window looks and behaves when viewed onscreen.
Display section
Select various options for the display.
Formulas
Display the content of a cell either as a formula or as the result of that formula.
Zero values
Display a zero in a cell when the cell has a value of zero, or display an empty cell.
Comment indicator
Select this option to show a small symbol in the top right corner of a cell that contains a
comment.
To always display a comment, right-click on the cell and select Show comment in the
context menu.
Value highlighting
Select this option to highlight all values, or results of formulas, in the sheet. Text is
highlighted in black; numbers in blue; and formulas, logical values, dates, and so on, in
green. When this option is active, any colors assigned in the document are not displayed.
Window section
The following elements of the spreadsheet window can be made visible or invisible: column and
row headers, horizontal and vertical scroll bars, sheet tabs, and, if an outline has been defined,
outline symbols.
If the Sheet tabs option is not selected, you can only switch between the sheets by using the
Navigator.
The Summary on search option controls the display of the Search Results dialog, which is
described in detail in Chapter 2, Entering, Editing, and Formatting Data.
Visual Aids section
Grid lines
Grid lines are the borders around the cells of a spreadsheet when viewed onscreen. The
options are: Show, Show on colored cells, or Hide. If grid lines are hidden, tables will be
Note
To print grid lines, choose Format > Page > Sheet > Print > Grid.
Page breaks
Specifies whether to view the page breaks within a defined print area.
Helplines while moving
Specifies whether to view helplines when moving drawings, frames, graphics, and other
objects. These lines help you align objects.
In Figure 485, the graph with the dark background represents the image in its original
location. The lighter area represents the position of the image as it is being moved.
Helplines are the horizontal and vertical dotted lines at the corners of the lighter object.
Objects section
Choose whether to show or hide graphics, charts, and drawing objects.
Zoom section
Select the Synchronize sheets option to apply any selected zoom (magnification) factor to all
sheets in the spreadsheet. If this option is not selected, separate zoom factors can be applied to
individual sheets.
Calculate
Use the LibreOffice Calc – Calculate page (Figure 486) to define the calculation settings for
spreadsheets.
Caution
When calculations involve a range that includes an empty cell, take note of the
setting for Zero values in the LibreOffice Calc > View options. If this option is not
selected, a value of zero will display as an empty cell. Empty cells and the value zero
are treated differently by many functions. For example, COUNT would not include an
empty cell as an item to be counted. The average of eight cells, one of which
contains the value zero, is not the same as the average of seven cells (an empty cell
is not included in determining the average).
Sort lists
View, define, and edit sort lists on the LibreOffice Calc – Sort Lists page. Sort lists are used for
more than sorting, for example filling a series of cells during data entry. They are lists that are
sorted in a particular order but not alphabetically or numerically; for example, days of the week.
In addition to the supplied lists, you can define and edit your own lists, as described in Chapter 2,
Entering, Editing, and Formatting Data.
Changes
On the LibreOffice Calc - Changes page you can specify options for highlighting recorded
changes in spreadsheets. You can assign specific colors for insertions, deletions, and other
changes, or you can let Calc assign colors based on the author of the change; in the latter case,
one color will apply to all changes made by that author. The selections made here are applied
when change recording is enabled under Edit > Track Changes > Record on the Menu bar.
Compatibility
The LibreOffice Calc - Compatibility page provides a quick way to switch between LibreOffice’s
default key bindings and OpenOffice.org’s legacy default key bindings for Calc. Most of the
defaults are identical, but there are some differences.
The actions associated with the two key binding choices are shown in the table below.
Key Binding Default OpenOffice.org legacy
Backspace Opens Delete Contents dialog Immediately deletes contents
Delete Immediately deletes contents Opens Delete Contents dialog
Control+D Fills cell content down within Opens the Selection List
(Command+D on macOS) selection dialog
Alt+DownArrow Select header of range; Increases row height
(Option+DownArrow on no action in empty cell
macOS)
Grid options
The LibreOffice Calc – Grid page defines the grid settings for spreadsheets. Using a grid helps
you determine the exact position of any charts or other objects you may add to a spreadsheet.
You can also set this grid in line with the snap grid.
If you have activated the snap grid but wish to move or create individual objects without snap
positions, you can press the Ctrl key to deactivate the snap grid for as long as needed.
Print options
Use the LibreOffice Calc - Print page to choose defaults for printing spreadsheets. You can
override these for individual print jobs.
AutoCorrect functions
Some people find some of the options in Calc’s AutoCorrect function annoying because they
change what you type when you do not want it changed. Many people find some of the
AutoCorrect functions quite helpful; if you do, then select the relevant options. But if you find
unexplained changes appearing in your document, this is a good place to look to find the cause.
To open the AutoCorrect dialog, click Tools > AutoCorrect Options on the Menu bar. You need
to have a document open for this menu item to appear.
In Calc, this dialog has four tabs, as shown in Figure 493. Options are described in the Help;
many will be familiar to users of other office suites.
Tip
Changes to menus and toolbars can be saved in a template. First, save the
document that was open when these changes were made. Then, save that
document as a template, as described in Chapter 4, Using Styles and Templates.
Menu content
You can add and rearrange menus on the Menu bar or context (right-click) menus; add,
rearrange, and remove commands on menus; and make other changes.
To customize menus, choose Tools > Customize on the Menu bar. On the Customize dialog, go
to the Menus tab (Figure 494) or the Context Menus tab. The following examples focus on the
Menus tab but the Context Menus tab is similar in appearance and behavior.
Creating an accelerator
You can allocate a letter in a custom menu’s name to be used as a keyboard shortcut. (That letter
will become underlined.) When you press Alt+that letter, that menu or command will be invoked.
Existing submenus can also be edited to change the letter which is used to select them using the
keyboard when the menu is open.
To create an accelerator:
1) Select a menu item from the Assigned Commands list.
2) Click the Modify button and select Rename.
3) Add a tilde (~) in front of the letter to use as an accelerator.
4) Click OK to save the change.
If you enter “~Art”, the “A” in the menu item Art is now underlined. Press Alt+A and the Art menu
will open.
Caution
When assigning an accelerator, be careful not to use a letter that is already assigned
to a menu or command associated with a menu item. The same letter-key
combinations can be used for commands associated with different menu items but
not for those associated with the same menu or menu item.
Toolbars
You can customize toolbars in several ways, including choosing which icons are visible and
locking the position of a docked toolbar, as described in Chapter 1, Introducing LibreOffice, of the
Getting Started Guide. This section describes how to create new toolbars and add or delete icons
(commands) on a toolbar.
To get to the toolbar customization dialog (Figure 499), do any of the following:
• On the toolbar, right-click in the toolbar and choose Customize Toolbar.
Notebook bar
By default, Calc’s commands are grouped in cascading menus and in toolbars filled with icons.
The notebook bar provides a different way to organize controls and icons, displaying contextual
groups of commands and contents. You can find more information about the notebook bar in the
Help system, by searching for “notebook bar” in the index.
One of the available notebook bar modes is Tabbed – in this mode, the bar is divided into tabs,
where each tab displays a set of icons grouped by context. The context can also change
depending on the object selected in the document, for example a table or an image.
Checkboxes are provided on the Notebookbar tab of the Customize dialog (Figure 501) to show
and hide the individual options on the various tabs that are provided in the Tabbed mode user
interface.
Keyboard shortcuts
In addition to using the built-in keyboard shortcuts (listed in Appendix A), you can define your
own. You can assign shortcuts to standard LibreOffice functions or your own macros and save
them for use with the entire LibreOffice suite or only for Calc.
Caution
Avoid reassigning your operating system’s predefined shortcut keys.
Note
Shortcut keys that are grayed out in the listing on the Customize dialog, such as F1
and F10, are not available for reassignment.
To adapt shortcut keys to your needs, use the Customize dialog, as described below.
1) Select Tools > Customize on the Menu bar and select the Keyboard tab. (Figure 502).
2) To have the shortcut key assignment available only with Calc, select Calc in the upper
right corner of the page; otherwise select LibreOffice to make it available to every
component.
3) Next select the required function from the Category and Function lists.
4) Now select the desired shortcut keys in the Shortcut Keys list and click the Modify button
at the upper right.
5) Click OK to accept the change. Now the chosen shortcut keys will execute the function
chosen in step 3) above whenever they are pressed.
Note
All existing shortcut keys for the currently selected Function are listed in the Keys
selection box. If the Keys list is empty, it indicates that the chosen key combination is
free for use. If it were not, and you wanted to reassign a shortcut key combination
that is already in use, you must first delete the existing key.
Installing extensions
To install an extension that is listed in the repository, follow these steps:
1) In LibreOffice, select Tools > Extension Manager on the Menu bar, or press Ctrl+Alt+E.
In the Extension Manager dialog, click the Get more extensions online link.
2) A browser window will open. Find the extension you want and download it to your
computer.
3) After the extension is downloaded and saved, return to the Extension Manager dialog and
click Add. Find and select the extension you want to install and click Open. The
extension begins installing. You may be asked to accept a license agreement.
4) When the installation is complete, the extension is listed in the Extension Manager dialog.
To install an extension that is not listed in the repository, download the extension, then continue
with step 3) above.
Updating extensions
Click the Check for Updates button on the Extension Manager dialog to check for updates to
installed extensions.
Note
In some cases, the Remove and Disable buttons may be unavailable – this will be
the case when you have selected one of the extensions that was bundled with your
LibreOffice installation.
Caution
Be careful when reassigning predefined shortcuts. Although you can reset shortcut
keys back to LibreOffice defaults, changing common hotkeys, such as F1 for Help,
can cause confusion and frustration, especially if other users share your computer.
Note
Different Operational Systems may allocate particular keys to operating system
functions and, in such cases, those key presses may not perform the Calc functions
described in this appendix.
For example, the F1 function key may be used to put your Windows computer into a
sleep / hibernation mode and so cannot be utilized to access the Calc Help system.
For some macOS versions, the Cmd+F5 key sequence is used by macOS to display
its VoiceOver dialog and so cannot be used to control the display of Calc’s Sidebar.
Similarly the Shift+F11 key sequence may be used by macOS to show its desktop
and so cannot be used to access Calc’s Save as Template dialog.
Check your computer system’s documentation to determine which key presses are
used by the operating system and hence cannot carry out Calc functions.
The remainder of this chapter is split into two main sections, one listing the keyboard shortcuts
available in the Windows and Linux environments, and the other listing the macOS keyboard
shortcuts.
Table 24: Number key shortcuts for menu and toolbar options
Windows /
Equivalent Menu bar / toolbar option
Linux
Ctrl+1 Format > Cells.
Format > Number Format > Number (use the “1” key on the main keyboard).
Ctrl+Shift+1
Format as Number icon on Formatting toolbar.
Note
The Format > Spacing menu appears to provide shortcuts for Line Spacing: 1.5
(Ctrl+5) and Line Spacing: 2 (Ctrl+2). However these options are never active in
Calc 7.0 and so the shortcuts are not included in Table 24.
Table 25: Letter key shortcuts for menu and toolbar options
Windows /
Equivalent Menu bar / toolbar option
Linux
Format > Text > Bold.
Ctrl+B
Bold icon on Formatting toolbar.
Ctrl+Shift+B Format > Text > Subscript.
Edit > Copy.
Ctrl+C
Copy icon on Standard toolbar.
Ctrl+Shift+C Edit > Track Changes > Record.
Insert > Comment.
Ctrl+Alt+C Sheet > Cell Comments > Edit Comment.
Insert Comment icon on Standard toolbar.
Sheet > Fill Cells > Fill Down.
Ctrl+D
Via drop-down menus on Row or Column icons on Standard toolbar.
Format > Align > Centered.
Ctrl+E
Align Center icon on Formatting toolbar.
Ctrl+Alt+E Tools > Extension Manager.
Ctrl+F Edit > Find.
Edit > Find and Replace.
Ctrl+H
Find and Replace icon on Standard toolbar.
Format > Text > Italic.
Ctrl+I
Italic icon on Formatting toolbar.
Ctrl+J Format > Align > Justified.
Ctrl+Shift+J View > Full Screen.
Insert > Hyperlink.
Ctrl+K
Insert Hyperlink icon on Standard toolbar.
Ctrl+/
Selects the cells in the matrix formula range that contains the cursor.
Copies the contents of the cell above the cursor into the current cell, but
Ctrl+’
remains in cell edit mode so that you can make further changes.
Use the single apostrophe key.
Moves the cursor to the next cell in the selected range, from top to bottom,
Enter then left to right. To specify in which direction the cursor moves, go to Tools >
Options > LibreOffice Calc > General on the Menu bar.
Ctrl+Enter Inserts a manual line break in the current cell while editing a cell.
Creates a matrix in the current range using the information entered on the
Ctrl+Shift+Enter
input line.
Alt+Enter Fills the selected cell range with the formula that you entered on the input line.
Alt+= Equivalent to selecting Select Function > Sum on the Formula bar.
Tip
You can use the Alt key with the arrow keys and plus (+) and minus (-) keys to move
elements with a finer degree of movement for more accuracy.
Shift
Home
End
Delete
Forward Delete (shortened to “Fwd Del” in the tables that follow)
Table 38: Number key shortcuts for menu and toolbar options
macOS Equivalent Menu bar / toolbar option
Cmd+1 Format > Cells.
Format > Number Format > Number (use the “1” key on the main keyboard).
Ctrl+Shift+1
Format as Number icon on Formatting toolbar.
Format > Number Format > Scientific (use the “2” key on the main
Ctrl+Shift+2
keyboard).
Format > Number Format > Date (use the “3” key on the main keyboard).
Ctrl+Shift+3
Format as Date icon on Formatting toolbar.
Format > Number Format > Currency (use the “4” key on the main
Ctrl+Shift+4 keyboard).
Format as Currency icon on Formatting toolbar.
Format > Number Format > Percent (use the “5” key on the main keyboard).
Ctrl+Shift+5
Format as Percent icon on Formatting toolbar.
Ctrl+Shift+6 Format > Number Format > General (use the “6” key on the main keyboard).
Note
The Format > Spacing menu appears to provide shortcuts for Line Spacing: 1.5
(Cmd+5) and Line Spacing: 2 (Cmd+2). However these options are never active in
Calc 7.0 and so the shortcuts are not included in Table 38.
Table 39: Letter key shortcuts for menu and toolbar options
macOS Equivalent Menu bar / toolbar option
Format > Text > Bold.
Cmd+B
Bold icon on Formatting toolbar.
Shift+Cmd+B Format > Text > Subscript.
Edit > Copy.
Cmd+C
Copy icon on Standard toolbar.
Shift+Cmd+C Edit > Track Changes > Record.
Cmd+/ Selects the cells in the matrix formula range that contains the cursor.
Use the forward slash key on the main keyboard or the numeric keypad.
Copies the contents of the cell above the cursor into the current cell, but
Cmd+’
remains in cell edit mode so that you can make further changes.
Use the single apostrophe key.
Moves the cursor to the next cell in the selected range, from top to bottom,
Enter then left to right. To specify in which direction the cursor moves, go to
LibreOffice > Preferences > LibreOffice Calc > General on the Menu bar.
Cmd+Enter Inserts a manual line break in the current cell while editing a cell.
Creates a matrix in the current range using the information entered on the input
Shift+Cmd+Enter
line.
Option+Enter Fills the selected cell range with the formula that you entered on the input line.
Tip
You can use the Option key with the arrow keys and plus (+) and minus (-) keys to
move elements with a finer degree of movement for more accuracy.
Appendix B
Error Codes
Introduction to Calc error codes
Calc provides feedback for errors of miscalculation, incorrect use of functions, invalid cell
references and values, and other user initiated mistakes. The feedback may be displayed within
the cell that contains the error (Figure 506), or on the Status bar (Figure 507), or in both,
depending on the type of error. Generally speaking, if the error occurs in the cell that is selected
(or contains the cursor), the error message is displayed on the Status bar.
As an example, Figure 506 shows the error code returned when a column is too narrow to
display the entire formatted date. The date displayed within the input line, 04/05/1998, would fit
within the cell without a problem, but the format used by the cell produces the date value
Sunday, April 05, 1998.
Tip
You can use the ERRORTYPE() function to find the code number for an error
occurring in a different cell. Refer to the Help system for more detail about this
function.
N/A ### The column is too narrow to display the complete formatted
contents of the cell. This is not really an error value, so there is no
corresponding numerical error code. The solutions to this problem
are to increase the width of the column, or select Format > Cells
> Alignment and click either Wrap text automatically or Shrink to
fit cell size in the Properties area to make the text match the
current column width.
519 #VALUE! The formula within the cell returns a value that does not
correspond to the definition of the formula or functions used. This
error could also mean that the cell referenced by the formula
contains text instead of a number.
524 #REF! The formula within the cell uses a reference that does not exist.
Either a column or row description name could not be resolved, or
the column, row, or sheet that contains a referenced cell is
missing.
Note
Errors described as Internal errors should not be encountered by users under normal
conditions. Errors listed as Not used are not currently assigned to any error condition
and will not occur.
501 Invalid character Character in a formula is not valid. This error is the same
as the Invalid Name error (525) except that it occurs within
a formula. The cell containing the error will display the
#NAME? error reference.
502 Invalid argument Function argument is not valid; for example, a negative
number for the SQRT() function. This error also occurs if
more than one matching cell is found by the DGET()
function.
504 Parameter list error Function parameter is not valid; for example, text instead of
a number, or a domain reference instead of a cell
reference.
510 Missing variable Variable is missing; for example, when two operators are
together "=1+*2".
511 Missing variable Function requires more variables than are provided; for
example, AND() and OR().
512 Formula overflow The total number of internal tokens (that is, operators,
variables, brackets) in the formula exceeds 8192, or the
total number of matrices the formula creates exceeds 150.
This includes basic functions that receive too large an array
as a parameter.
514 Internal overflow Sort operation attempted on too much numerical data (max.
100000) or a calculation stack overflow.
516 Internal syntax error Matrix is expected on the calculation stack, but is not
available.
517 Internal syntax error Unknown error; for example, a document with a newer
function is loaded in an older version of Calc that does not
contain the function.
519 No result (cell Formula yields a value that does not correspond to the
displays #VALUE!) definition, or a cell that is referenced in the formula contains
text instead of a number.
522 Circular reference Formula refers directly or indirectly to itself and the
Iterations option is not selected under Tools > Options >
LibreOffice Calc > Calculate.
524 Invalid references A column or row description name could not be resolved, or
(cell displays #REF!) the column, row, or sheet that contains a referenced cell is
missing.
525 Invalid names (cell An identifier could not be evaluated; for example, no valid
displays #NAME?) reference, no valid domain name, no column/row label, no
macro, incorrect decimal divider, add-in not found.
526 Internal syntax error Obsolete, no longer used, but could come from old
documents if the result is a formula from a domain.
527 Internal overflow References, such as when a cell references a cell, are too
encapsulated or deeply nested. This is an internal error and
should not be displayed in LibreOffice.
540 External content Occurs when a function that requires (re)loading of external
disabled sources is encountered and the user hasn't confirmed
reloading of external sources yet.
Index
Alphabetical Index
3
3D charts................................................................................................................................... 140
3D View dialog........................................................................................................................... 141
A
Absolute hyperlinks.................................................................................................................... 375
Absolute referencing.................................................................................................................. 255
Accepting changes..................................................................................................................... 411
Advanced filters................................................................................................................... 91, 465
Aligning images......................................................................................................................... 214
Alternative Python Script Organizer (APSO) extension..............................................................439
Analysis of Variance (ANOVA) dialog........................................................................................347
Anchoring images...................................................................................................................... 214
Apply Style list........................................................................................................................... 183
Area charts................................................................................................................................ 166
Arguments, passing to macros..................................................................................................429
Arithmetic operators................................................................................................................... 251
Arranging images....................................................................................................................... 214
Array formulas........................................................................................................................... 268
Asian typography.............................................................................................................................
Options on Format Cells dialog...............................................................................................72
AutoCorrect......................................................................................................................... 52, 492
AutoFilters........................................................................................................................... 90, 460
AutoFormat.................................................................................................................................. 75
AutoInput..................................................................................................................................... 54
AutoOutline.................................................................................................................................. 87
Axes of a chart........................................................................................................................... 126
Axis dialog................................................................................................................................. 127
B
Background, formatting for cell....................................................................................................74
Bar charts.................................................................................................................................. 163
Base, launching to edit data sources.........................................................................................392
Basic macro programming......................................................................................................... 417
BeanShell macro programming.................................................................................................435
Borders, formatting for cell........................................................................................................... 73
Bubble charts............................................................................................................................. 172
Button hyperlinks....................................................................................................................... 376
C
Calc options, setting........................................................................................................................
Calculate............................................................................................................................... 485
Changes................................................................................................................................ 489
Compatibility......................................................................................................................... 490
Defaults................................................................................................................................. 483
Formula................................................................................................................................. 488
General................................................................................................................................. 481
Grid....................................................................................................................................... 490
Print...................................................................................................................................... 491
Sort lists................................................................................................................................ 489
View...................................................................................................................................... 483
Calc, list of main features.........................................................................................................8, 16
Index | 529
Calc, new features in this version................................................................................................14
Calculations.....................................................................................................................................
Linking sheets....................................................................................................................... 259
Order of................................................................................................................................. 259
Speeding up.......................................................................................................................... 270
Cell Style dialog......................................................................................................................... 184
Cell styles........................................................................................................................................
Apply Style list....................................................................................................................... 183
Cell Style dialog.................................................................................................................... 184
Fill format mode.................................................................................................................... 182
Hiding and showing...............................................................................................................196
Overview............................................................................................................................... 180
Styles deck............................................................................................................................ 181
Styles menu.......................................................................................................................... 181
Cells................................................................................................................................................
AutoFormat............................................................................................................................. 75
Copying styles......................................................................................................................... 82
Deleting............................................................................................................................. 35, 63
Error codes and messages...................................................................................................525
Formatting background...........................................................................................................74
Formatting borders.................................................................................................................. 73
Inserting fields......................................................................................................................... 68
Merging and splitting...............................................................................................................58
Navigating between.................................................................................................................27
Selecting................................................................................................................................. 31
Validating contents.................................................................................................................. 59
Changes..........................................................................................................................................
Accepting or rejecting............................................................................................................411
Adding comments on............................................................................................................ 409
Editing comments on.............................................................................................................409
Recording / tracking.............................................................................................................. 408
Chart types......................................................................................................................................
3D......................................................................................................................................... 140
Area...................................................................................................................................... 166
Bar........................................................................................................................................ 163
Bubble................................................................................................................................... 172
Changing............................................................................................................................... 114
Column.................................................................................................................................. 162
Column and line.................................................................................................................... 177
Line....................................................................................................................................... 167
Net........................................................................................................................................ 173
Pie......................................................................................................................................... 164
Pivot...................................................................................................................................... 178
Scatter or XY......................................................................................................................... 169
Stock..................................................................................................................................... 174
Chart Wizard....................................................................................................................................
Overview............................................................................................................................... 100
Selecting chart type...............................................................................................................101
Selecting data range.............................................................................................................102
Selecting data series.............................................................................................................103
Selecting elements................................................................................................................ 106
Charts..............................................................................................................................................
Adding drawing objects......................................................................................................... 153
Axes...................................................................................................................................... 126
Background........................................................................................................................... 118
Index | 531
Formulas............................................................................................................................... 249
Pivot charts........................................................................................................................... 312
Pivot tables........................................................................................................................... 284
Spreadsheet............................................................................................................................ 23
CSV file...........................................................................................................................................
Importing............................................................................................................................... 381
Opening.................................................................................................................................. 23
Custom colors, adding...............................................................................................................503
D
Dashes, inserting......................................................................................................................... 53
Data.................................................................................................................................................
Editing and deleting.................................................................................................................63
Entering................................................................................................................................... 49
Finding and replacing.............................................................................................................. 94
Formatting............................................................................................................................... 68
Grouping and outlining............................................................................................................86
Hiding and showing.................................................................................................................83
Data Labels dialog..................................................................................................................... 134
Data Series dialog..................................................................................................................... 120
Data sources...................................................................................................................................
Editing................................................................................................................................... 392
Launching Base.................................................................................................................... 392
Linking to when registered....................................................................................................388
Registering............................................................................................................................ 388
Using in Calc spreadsheets...................................................................................................392
Viewing................................................................................................................................. 390
Database functions.................................................................................................................... 468
Database primer........................................................................................................................ 445
Database ranges.............................................................................................................................
Creating and managing using the Define Database Range dialog........................................453
Creating with macros............................................................................................................455
Overview............................................................................................................................... 453
Selecting using the Select Database Range dialog...............................................................454
Date and time, formatting............................................................................................................ 51
DDE (Dynamic Data Exchange) objects....................................................................................394
Define Database Range dialog..................................................................................................453
Deleting...........................................................................................................................................
Cells........................................................................................................................................ 35
Charts................................................................................................................................... 162
Columns and rows..................................................................................................................34
Data........................................................................................................................................ 63
Page breaks.......................................................................................................................... 231
Pivot charts........................................................................................................................... 314
Pivot tables........................................................................................................................... 308
Sheets..................................................................................................................................... 37
Descriptive Statistics dialog.......................................................................................................345
Detective.............................................................................................................................. 63, 274
Dialogs, choosing LibreOffice or operating system......................................................................11
Dialogs, recognizing common controls........................................................................................12
Digital signing of documents............................................................................................................
Applying signature.................................................................................................................244
Overview............................................................................................................................... 243
Signing macros..................................................................................................................... 246
Signing multiple times with same signature...........................................................................245
Index | 533
AutoFilters............................................................................................................................. 460
Clearing all filters for a sheet using a macro..........................................................................463
Copying advanced filter results to a different location...........................................................467
Data........................................................................................................................................ 88
Multiple columns using a macro............................................................................................463
Standard filters using a macro...............................................................................................461
Standard filters using the Standard Filter dialog....................................................................461
Using regular expressions.................................................................................................43, 89
With regular expressions using a macro...............................................................................463
Find and Replace dialog.............................................................................................................. 94
Find toolbar.................................................................................................................................. 94
Finding and replacing data..........................................................................................................94
Font effects.................................................................................................................................. 70
Fontwork objects....................................................................................................................... 218
Footers and headers.................................................................................................................. 233
Format menu, options when editing a chart................................................................................111
Formatting.......................................................................................................................................
Cell background and borders..................................................................................................73
Conditional.............................................................................................................................. 77
Data........................................................................................................................................ 68
Fonts....................................................................................................................................... 70
Numbers................................................................................................................................. 69
Formatting toolbar....................................................................................................................... 18
Formatting toolbar, options when editing a chart........................................................................112
Formula bar................................................................................................................................. 18
Formulas.........................................................................................................................................
Array..................................................................................................................................... 268
Color coding for input............................................................................................................ 274
Creating................................................................................................................................ 249
Operators in.......................................................................................................................... 249
Order of calculation...............................................................................................................259
Strategies for creating...........................................................................................................269
Value highlighting..................................................................................................................274
Fourier Analysis dialog...............................................................................................................363
Freezing columns and rows......................................................................................................... 37
Function Wizard dialog.............................................................................................................. 266
Functions.........................................................................................................................................
Basic arithmetic..................................................................................................................... 275
Compatibility with other applications.....................................................................................263
Creating with macros............................................................................................................422
Database-like........................................................................................................................ 468
Database-specific.................................................................................................................. 470
Examples.............................................................................................................................. 275
Nested................................................................................................................................... 264
Overview............................................................................................................................... 263
Rounding numbers................................................................................................................ 277
Simple statistics.................................................................................................................... 276
Structure............................................................................................................................... 264
Using regular expressions...............................................................................................43, 278
Using wildcards..................................................................................................................... 278
Functions deck..................................................................................................................... 22, 265
G
Galaxy icon set............................................................................................................................ 11
Gallery deck...................................................................................................................11, 22, 209
Index | 535
Images.................................................................................................................................. 206
Page breaks.......................................................................................................................... 231
Sheets............................................................................................................................. 35, 368
Sheets from another spreadsheet.........................................................................................370
Special characters...................................................................................................................51
Integrated Development Environment (IDE) for Basic macro programming...............................424
J
Java JRE (Java Runtime Environment).......................................................................................13
JavaScript macro programming.................................................................................................437
K
Keyboard shortcuts..........................................................................................................................
Customizing.......................................................................................................................... 500
Loading saved configuration.................................................................................................501
MacOS.................................................................................................................................. 515
Resetting to defaults.............................................................................................................502
Saving to a file...................................................................................................................... 501
That cannot be modified (macOS)........................................................................................522
That cannot be modified (Windows / Linux)..........................................................................514
Using to run macros.............................................................................................................. 502
Windows / Linux.................................................................................................................... 506
Keyboard, using to navigate spreadsheet....................................................................................29
L
Leading zeroes, entering............................................................................................................. 49
LibreOffice.......................................................................................................................................
Licensing of............................................................................................................................. 13
Restarting with default settings.................................................................................................9
Sending feedback on................................................................................................................ 9
LibreOffice Basic macro programming.......................................................................................417
LibreOffice options, setting..............................................................................................................
Advanced.............................................................................................................................. 477
Application colors..................................................................................................................476
Paths..................................................................................................................................... 474
Print...................................................................................................................................... 474
Security................................................................................................................................. 474
User data.............................................................................................................................. 474
View...................................................................................................................................... 474
Line breaks.................................................................................................................................. 68
Line charts................................................................................................................................. 167
Linear programming, solving problems......................................................................................338
Linking images........................................................................................................................... 206
Linking to external data..............................................................................................................381
Linux keyboard shortcuts........................................................................................................... 506
Load Basic code to edit.............................................................................................................440
Loading / unloading macro libraries...........................................................................................427
Loading and saving options.............................................................................................................
General................................................................................................................................. 478
HTML compatibility................................................................................................................480
Microsoft Office..................................................................................................................... 479
VBA properties...................................................................................................................... 478
M
Index | 537
Several formulas simultaneously...........................................................................................333
Two variables........................................................................................................................ 335
Multiple Operations dialog......................................................................................................... 331
N
Name Box.................................................................................................................................... 19
Named expressions................................................................................................................... 259
Named ranges.................................................................................................................................
Creating and managing with the Define Names dialog..........................................................446
Creating from labels using macros........................................................................................451
Creating using column or row headers..................................................................................450
Creating with macros............................................................................................................447
Using relative references.......................................................................................................449
With functions....................................................................................................................... 257
Navigating.......................................................................................................................................
Between cells.......................................................................................................................... 27
Between sheets...................................................................................................................... 28
Using the Enter key.................................................................................................................31
Using the keyboard.................................................................................................................29
Navigator.........................................................................................................................................
Using to link external data.....................................................................................................385
Working with scenarios.........................................................................................................329
Navigator deck............................................................................................................................. 22
Navigator dialog........................................................................................................................... 27
Negative numbers, entering.........................................................................................................49
Net charts.................................................................................................................................. 173
Non-linear programming, solving problems...............................................................................338
Notebookbar, customizing.........................................................................................................499
Numbers, formatting.................................................................................................................... 69
O
ODF (Open Document Format)...................................................................................................25
OLE (Object Linking and Embedding) objects...........................................................................394
Opening...........................................................................................................................................
CSV file................................................................................................................................... 23
Spreadsheet............................................................................................................................ 23
Operators........................................................................................................................................
Arithmetic.............................................................................................................................. 251
Comparative.......................................................................................................................... 251
In formulas............................................................................................................................ 249
Reference............................................................................................................................. 252
Text....................................................................................................................................... 252
Order of calculation.................................................................................................................... 259
Outlining...................................................................................................................................... 86
Oxygen icon set........................................................................................................................... 11
P
Page breaks, inserting and deleting...........................................................................................231
Page Style dialog............................................................................................................... 193, 231
Page styles......................................................................................................................................
Applying................................................................................................................................ 184
Overview............................................................................................................................... 181
Page Style dialog..................................................................................................................193
Printing options..................................................................................................................... 231
Index | 539
Multiple pages per sheet of paper.........................................................................................223
Options for page styles.........................................................................................................231
Repeat printing of rows or columns.......................................................................................229
Selecting what to print........................................................................................................... 223
Using print preview................................................................................................................ 225
Using print ranges................................................................................................................. 225
Using the Print dialog............................................................................................................ 221
Using the Print Directly icon..................................................................................................221
Properties deck................................................................................................................................
Overview................................................................................................................................. 21
Using to change chart properties..........................................................................................107
Using with drawing objects....................................................................................................216
Using with images................................................................................................................. 211
Properties dialog.......................................................................................................................... 41
Python macro programming.......................................................................................................439
R
Ranges............................................................................................................................................
Associating a name...............................................................................................................446
Database............................................................................................................................... 453
Named.................................................................................................................................. 446
Recording macros...................................................................................................................... 417
Reference operators........................................................................................................................
Concatenation....................................................................................................................... 253
Intersection........................................................................................................................... 254
Overview............................................................................................................................... 252
Range................................................................................................................................... 252
References, absolute and relative.............................................................................................255
Referencing.....................................................................................................................................
Other documents...................................................................................................................374
Other sheets......................................................................................................................... 372
Registering data sources........................................................................................................... 388
Regression dialog...................................................................................................................... 354
Regular expressions................................................................................................43, 89, 97, 278
Rejecting changes..................................................................................................................... 411
Relative hyperlinks..................................................................................................................... 375
Relative referencing...................................................................................................................255
Removing personal data............................................................................................................246
Renaming sheets................................................................................................................. 37, 371
Replacing data............................................................................................................................. 65
Resizing...........................................................................................................................................
Charts................................................................................................................................... 154
Drawing objects..................................................................................................................... 217
Images.................................................................................................................................. 212
Restarting LibreOffice with default settings....................................................................................9
Reviewing spreadsheets..................................................................................................................
Accepting or rejecting changes.............................................................................................411
Adding comments to changes...............................................................................................410
Comparing spreadsheets......................................................................................................413
Editing comments on changes..............................................................................................411
Merging spreadsheets........................................................................................................... 413
Preparing a document for review..........................................................................................407
Recording changes...............................................................................................................408
Using (general) comments....................................................................................................410
Rhino JavaScript debugger........................................................................................................438
Index | 541
Functions deck................................................................................................................ 22, 265
Gallery deck.............................................................................................................. 11, 22, 209
Navigator deck.................................................................................................................. 22, 39
Overview................................................................................................................................. 20
Properties deck, overview.......................................................................................................21
Properties deck, using to change chart properties................................................................107
Properties deck, using with drawing objects..........................................................................211
Properties deck, using with images.......................................................................................216
Styles deck...................................................................................................................... 22, 181
Signing documents digitally.............................................................................................................
Applying signature.................................................................................................................244
Overview............................................................................................................................... 243
Signing macros..................................................................................................................... 246
Signing multiple times with same signature...........................................................................245
Smoothing, exponential.............................................................................................................350
Solver dialog.............................................................................................................................. 339
Sort dialog................................................................................................................................... 91
Sorting.............................................................................................................................................
Data........................................................................................................................................ 91
Multiple columns using a macro............................................................................................457
One column using a macro...................................................................................................456
Retrieving sorting information from a range using a macro...................................................458
Using macros........................................................................................................................ 433
Special characters, inserting........................................................................................................51
Splitting cells................................................................................................................................ 58
Splitting the screen (or "window")................................................................................................38
Spreadsheets..................................................................................................................................
Advice to avoid common pitfalls............................................................................................248
Comparing............................................................................................................................ 413
Creating, opening, and saving.................................................................................................23
Emailing................................................................................................................................ 243
Embedding............................................................................................................................ 394
General layout................................................................................................................... 16, 22
Merging................................................................................................................................. 413
Removing personal data.......................................................................................................246
Reviewing............................................................................................................................. 407
Saving versions..................................................................................................................... 414
Sharing with other users.......................................................................................................405
Signing digitally..................................................................................................................... 243
Stacking images........................................................................................................................ 214
Standard (Single Mode) toolbar...................................................................................................18
Standard filters..................................................................................................................... 88, 461
Standard toolbar.......................................................................................................................... 18
Statistics tools..................................................................................................................................
Analysis of variance (ANOVA)...............................................................................................347
Correlation............................................................................................................................ 348
Covariance............................................................................................................................ 349
Descriptive statistics.............................................................................................................. 345
Exponential smoothing..........................................................................................................350
F-test..................................................................................................................................... 359
Fourier analysis..................................................................................................................... 363
Moving average..................................................................................................................... 352
Paired t-test........................................................................................................................... 357
Regression............................................................................................................................ 354
Sampling............................................................................................................................... 343
Index | 543
Customizing.......................................................................................................................... 496
Drawing................................................................................................................................. 215
Drawing Object Properties, options when editing a chart......................................................159
Drawing Object Properties, overview....................................................................................216
Drawing, options when editing a chart...................................................................................153
Find......................................................................................................................................... 94
Formatting, options when editing a chart...............................................................................112
Formatting, overview...............................................................................................................18
Image.................................................................................................................................... 210
Overview................................................................................................................................. 18
Standard................................................................................................................................. 18
Standard (Single Mode)..........................................................................................................18
Tooltips.................................................................................................................................... 9, 18
Tracking changes...................................................................................................................... 408
Trend Line dialog....................................................................................................................... 144
U
Unfreezing columns and rows......................................................................................................38
Updating LibreOffice software......................................................................................................10
URLs and hyperlinks.................................................................................................................. 375
User interface, customizing........................................................................................................493
V
Validating cell contents................................................................................................................ 59
Validity dialog............................................................................................................................... 60
Value highlighting................................................................................................................. 76, 274
VBA (Visual Basic for Applications) loading and saving options.................................................478
VBA macros............................................................................................................................... 440
Option VBASupport statement..............................................................................................441
VBA UserForms......................................................................................................................... 442
Versions, saving........................................................................................................................ 414
W
Wildcards............................................................................................................................. 96, 278
Windows keyboard shortcuts.....................................................................................................506
Wrapping text.............................................................................................................................. 68
X
XML Source dialog.................................................................................................................... 401
XML, importing source data from...............................................................................................400
XY charts................................................................................................................................... 169
Z
Z-test dialog............................................................................................................................... 360
Zooming the Calc window............................................................................................................20
#
# error codes and messages.....................................................................................................524
### displayed in cell..................................................................................................................525
#DIV/0! error...................................................................................................................... 272, 525
#NAME? error............................................................................................................................ 525
#NUM! error............................................................................................................................... 525
#REF! error........................................................................................................................ 273, 525
#VALUE! error.................................................................................................................... 273, 525
Index | 545