CG72 CalcGuide
CG72 CalcGuide
CG72 CalcGuide
This document is Copyright © 2021 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 (https://www.gnu.org/licenses/gpl.html), version 3 or later, or the Creative
Commons Attribution License (https://creativecommons.org/licenses/by/4.0/), version 4.0 or later.
All trademarks within this guide belong to their legitimate owners.
Contributors
To this edition
Steve Fanning Rachel Kartch Kees Kriek
Rafael Lima Felipe Viggiano Zbyszek Zak
To previous editions
John A Smith Jean Hollis Weber Martin J Fox
Andrew Pitonyak Simon Brydon Gabriel Godoy
Barbara Duprey Christian Chenal Peter Schofield
Philippe Clément Pierre-Yves Samyn Laurent Balland-Poirier
Peter Kupfer Andy Brown Shelagh Manton
Iain Roberts Hazel Russman Stephen Buck
Jared Kobos Martin Saffron Barbara M. Tobias
Olivier Hallot Cathy Crumbley Dave Barton
Claire Wood Steve Fanning Kees Kriek
Gordon Bates Leo Moons Zachary Parliman
Drew Jensen Samantha Hamilton Randolph Gamo
Felipe Viggiano Stefan Weigel Annie Nguyen
Vasudev Narayanan
Feedback
Please direct any comments or suggestions about this document to the Documentation Team’s
mailing list: documentation@global.libreoffice.org.
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 online 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 Help > LibreOffice Help from the Menu bar
(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.
10 | Preface
• 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 list under Icon Style.
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
12 | Preface
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.
14 | Preface
This user guide has been updated from Calc Guide 7.1. It covers changes that are visible in the
user interface, including:
• Added details of the Search Commands tool (Preface, Chapter 1, and Appendix A).
• Added details of the global toolbar lock (Chapter 1).
• Updated details of the Properties dialog (Chapter 1).
• Updated details of the selection mode control within the Status Bar (Chapter 1).
• Added menu options to select only visible rows and columns (Chapter 1).
• Updated details of the Sidebar (Chapter 1).
• Updated details of the Standard Filter dialog (Chapters 1, 2, and 13).
• Added details of an optional cursor type that is available when the pointer lies over the
main spreadsheet area (Chapters 1 and 14).
• Added details of user interface variants (Chapters 1, 14, and 15).
• Updated details of the AutoInput tool (Chapter 2)
• Updated details of the Find toolbar (Chapter 2)
• Updated details of the Paste Special dialog (Chapters 2, 7, 10, and 12).
• Updated details of the AutoFilter tool (Chapters 2, 8, and 13; Appendix A).
• Updated details of chart facilities, including Sidebar enhancements, option to display
series name in data labels, option to show leader lines, and selection of regression type
for moving average trend lines (Chapter 3).
• Updated details of the Templates dialog (Chapter 4).
• Added details of QR code generation (Chapter 5).
• Added details of multi-column feature for text boxes (Chapter 5).
• Updated details of the Print dialog (Chapter 6).
• Updated details of the PDF Options dialog (Chapter 6).
• Updated details of the Select Certificate dialog (Chapter 6).
• Added link to the Calc Functions area of The Document Foundation Wiki (Chapter 7).
• Updated details of the Descriptive Statistics tool (Chapter 9).
• Added details of the Solver Status dialog (Chapter 9).
• Updated details of the Regression tool (Chapter 9).
• Updated details of the External Data dialog, to include HTML table captions (Chapter 10).
• Added details of the Tools > Protect > Protect Spreadsheet Structure interaction
(Chapter 10).
• Removed details of shortcut to Edit > Track Changes > Record (Chapter 11 and
Appendix A).
• Added details of the built-in object inspector (Chapter 12).
• Added details of the ScriptForge libraries (Chapter 12).
• Updated details of the preset color schemes supplied with LibreOffice (Chapter 14).
• Minor rewording, updates to terminology, updates to hyperlinks, and replacement figures
in many chapters.
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
By default, Calc’s commands are grouped in menus and toolbars, as described in
this section. In addition, Calc provides other user interface variations, displaying
contextual groups of commands and contents. For more information, see Chapter
15, User Interface Variants.
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 Style, AutoFormat Styles, Align Text.
18 | Chapter 1 Introduction
• 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.
• 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.
The scope of the Menu bar can be daunting for some people and even experienced users can
forget where to look for rarely used functions. To quickly locate and run a command in the Menu
bar, select Help > Search Commands or press Shift+Esc. Calc displays the dialog shown in
Figure 4.
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.
The initial default is for all displayed toolbars to be locked in their docked positions. An individual
toolbar can be unlocked, when a vertical handle is displayed at its left edge, and this handle can
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.
20 | Chapter 1 Introduction
very long formulas, click the Expand Formula Bar icon on the right. To edit inside the
Input line area, click in the area, then type your changes.
You can also directly edit inside the cell by double-clicking on the cell. When you enter new data
into a cell, the Select Function and Formula icons change to Cancel and Accept icons.
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 6) 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.
Sidebar
The Sidebar (Figure 7) is a mixture of toolbar and dialog. When opened (View > Sidebar or
Ctrl+F5), it appears on the right side of the window. When entering or editing data in cells, the
Sidebar 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. These decks are described below. However, the Sidebar is context-sensitive and
the number of decks and the content of each may change when you select objects such as
images or charts.
Properties
The Properties deck includes five content panels. Each panel has a More Options button
that provides additional options. If a dialog opens, it locks the document for editing until it is
closed.
Style: Options for applying, updating, or creating cell and page styles.
Character: Options for formatting the text, such as font name, size, and color. Some
controls, such as superscript, only become active when the text cursor is active in the Input
line of the Formula Bar or the cell.
Number Format: Options for formatting numbers, including decimals, currency, dates, or
numeric text.
Alignment: Options for arranging the text in various ways, including horizontal and vertical
alignment, wrapping, indenting, merging, text orientation, and vertical stacking.
Cell Appearance: Options include background color and border formats, including line
color and style.
Styles
The Styles deck enables you 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.
22 | Chapter 1 Introduction
Figure 7: Sidebar
Gallery
The Gallery deck enables you 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
The Navigator deck can also be opened by selecting View > Navigator from the Menu bar
or pressing F5. See “Using the Navigator” on page 41.
Functions
The Functions 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 bar of the Sidebar open. Click any button in the Tab bar 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.
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. You can
create a new sheet by clicking on the plus sign to the left of the sheet tabs or by clicking in the
blank space to the right of the sheet tabs.
Clicking on a tab makes an individual sheet active. When a sheet is active, the tab is highlighted.
To select multiple sheets, hold 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. In the dialog
that opens, 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 8).
24 | Chapter 1 Introduction
2) Select a color and click OK when finished to apply the color and close the dialog.
To add new colors to this color palette, see “Adding custom colors” in Chapter 14, Setting up and
Customizing.
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.
26 | Chapter 1 Introduction
– US English – numbers formatted in US English are searched for and included
regardless of the system language. A number format is not applied. If there are no US
English entries, the Standard format is applied.
– Hide – the data in the column are not imported.
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,
Emailing, and Signing, for more information.
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.
28 | Chapter 1 Introduction
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 5 on page 20). 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 – to open the Navigator (Figure 22), go to View > Navigator on the
Menu bar, or press F5, or click the Navigator button on the Sidebar. Type the cell
references into the Column and Row fields and press the Enter key.
• 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 32.
• 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.
• Using Home, End, Page Up, and Page Down
– Home moves the cell focus to the start of a row. Ctrl+Home moves the cell focus to the
first cell in the sheet, A1.
– The result of pressing End or Ctrl+End depends on the data contained in the sheet. To
explain these key presses, it is helpful to define Rmax as the highest numbered row in
the sheet that contains any data and Cmax as the rightmost column in the sheet that
contains any data. Press End to move the cell focus along the current row to the cell
in column Cmax. Press Ctrl+End to move the cell focus to the cell at the intersection of
row Rmax and column Cmax. Note that in either case, the newly focused cell may not
contain any data.
– Page Down moves the cell focus down one complete screen display.
– Page Up moves the cell focus up one complete screen display.
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.
30 | Chapter 1 Introduction
Keyboard
Cell navigation
shortcut
Ctrl+→ / If focus is on a blank cell, Ctrl+→ moves focus along the current
Ctrl+← row to the 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
Ctrl+↓ column to the 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 29.
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
Ctrl+Page Up there are more sheets in that direction.
32 | Chapter 1 Introduction
3) Move the mouse to highlight the desired block of cells, then release the left mouse
button.
To select a range of cells without dragging the mouse:
1) Click in the cell which is to be one corner of the range of cells.
2) Move the mouse to the opposite corner of the range of cells.
3) Hold down the Shift key and click.
To select a range of cells using Extending selection mode:
1) Click in the cell which is to be one corner of the range of cells.
2) Click in the Selection mode field on the Status Bar (Figure 6 on page 21) and select
Extending selection.
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.
Tip
You can also select rows and columns using options in the Edit > Select menu
(Select Row, Select Column, Select Visible Rows Only, and Select Visible
Columns Only).
Entire sheet
To select the entire sheet, click on the small box between the column headers and the row
headers (Figure 15), use the key combination Ctrl+A, press Ctrl+Shift+Space, or go to Edit on the
Menu bar and select Select All.
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.
34 | Chapter 1 Introduction
3) The selected tabs will be highlighted. Any actions that you perform will now affect all
highlighted sheets.
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.
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 click OK.
36 | Chapter 1 Introduction
Figure 17: Insert Sheet dialog
Caution
When you move or copy to another spreadsheet or to a new one, a conflict may
occur if formulas are linked to sheets in the previous location.
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 34), 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.
Note
LibreOffice Calc does not let you hide the last visible sheet.
38 | Chapter 1 Introduction
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 37).
• Right-click on a sheet tab and select Rename Sheet in the context menu to open the
Rename Sheet dialog
• 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 a spreadsheet
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.
Viewing a spreadsheet | 39
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.
40 | Chapter 1 Introduction
Figure 21: Split screen bars
42 | Chapter 1 Introduction
– Insert as Hyperlink – hyperlinks the entire item.
– Insert as Link – links the copied item to the original item so that when the original item
is changed, that change will be reflected in the current document.
– Insert as Copy – inserts a copy of the selected item.
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.
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.
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.
CMIS Properties
Only relevant for spreadsheets stored on remote servers. See the Help or the Getting Started
Guide for more information.
44 | Chapter 1 Introduction
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 utilizes the open source Regular Expressions package from the
International Components for Unicode (ICU), see
https://unicode-org.github.io/icu/userguide/strings/regexp.html for further details, including a full
definition of the syntax for ICU Regular Expressions.
Regular expressions appear in three areas of Calc’s functionality, as follows:
Regular expressions | 45
• 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.
46 | Chapter 1 Introduction
Figure 25: Using a regular expression on 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).
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 AND from the first drop-down menu in the Operator column.
7) Select Region from the second drop-down menu in the Field name column.
8) Select = from the second drop-down menu in the Condition column.
9) Type North|East in the second text box in the Value column.
10) If necessary, click the icon to expand the Options area of the dialog.
11) Make sure that the Regular expressions checkbox is checked.
12) Click OK and Calc updates the data displayed in accordance with the specified filter
criteria.
Regular expressions | 47
Figure 26: Using regular expressions on the Standard Filter dialog
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.
48 | Chapter 1 Introduction
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.
Regular expressions | 49
Calc Guide 7.2
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 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 one of these methods to add leading
zeroes.
Method 1
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 minimum number of
characters required. 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.
Method 2
1) Select the cell.
2) On the Sidebar, go to the Properties deck.
3) In the Number Format panel (Figure 29), select Number in the drop-down list, and enter
4 in the Leading zeroes field. Formatting is applied immediately.
Entering data | 51
Figure 28: Format Cells dialog – Numbers tab
Numbers as text
Numbers can also be converted into text using one of the following methods.
Method 1
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.
Tip
If numerical characters do not need to be treated as numbers in calculations (for
example when entering zip codes), you can type an apostrophe (') before the
number, for example '01481. When you move the cell focus, the apostrophe is
removed, the leading zeroes are retained, and the number is converted to left-
aligned 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 30. 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 YYYY-MM-DD 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).
Entering data | 53
2) Make sure the Numbers tab is selected, then select Date or Time in 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 31).
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 31).
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 32).
Entering data | 55
• 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.
Table 4: Inserting dashes
Text that you type Result
A - B (A, space, hyphen, space, B) A – B (A, space, en-dash, space, B)
A -- B (A, space, hyphen, hyphen, space,
A – B (A, space, en-dash, space, B)
B)
A--B (A, hyphen, hyphen, B) A—B (A, em-dash, B)
A-B (A, hyphen, B) A-B (unchanged)
A -B (A, space, hyphen, B) A -B (unchanged)
A --B (A, space, hyphen, hyphen, B) A –B (A, space, en-dash, B)
AutoInput tool
The AutoInput function in Calc automatically completes entries, based on other entries in the
same column.
When text is highlighted in a cell, AutoInput can be used as follows:
• Press Enter to accept the completion and move to the next cell. Press F2 to accept the
completion and move the cursor to the end of the text inside the cell. Clicking outside the
cell will accept the completion and select the clicked cell.
• 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 60 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.
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 33.
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.
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 in 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 38).
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.
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
39).
Criteria options
Specify the validation rules for the selected cells using the Criteria tab of the Validity dialog as
shown in Figure 39. 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
may consist of one column or one row of cells. If you specify a range of columns and
rows, only the first column is used.
– List – allow only values or strings specified in a list. Strings and values can be mixed.
Numbers evaluate to their value, so if you enter the number 1 in the list, the entry
100% is also valid.
– Text length – allow entries whose length matches the condition on the number of
characters that has been set.
– Custom – allow entries that correspond to a formula entered in the Formula box.
• Allow empty cells – in conjunction with Tools > Detective > Mark Invalid Data, this
defines that blank cells are shown as invalid data (disabled) or not shown (enabled).
• Show selection list – shows a list of all valid strings or values to select from. The list can
be opened either by clicking the down arrow at the right of the cell, or by selecting the
cell and pressing Alt+↓.
• Sort entries ascending – sorts the selection list in ascending order and filters duplicates
from the list. If not checked, the order from the data source is taken.
• Source – enter the cell range that contains the valid values or text.
• Entries – enter the entries that will be valid values or text strings.
• Data – select the comparative operator that you want to use from the drop-down list. The
available operators depend on what you have selected in the Data drop-down list. For
example, if you select valid range, the Minimum and Maximum input boxes replace the
Value box.
• Value – enter the value for the data validation option that you selected in the Data drop-
down list.
• Minimum – enter the minimum value for the data validation option that you selected in
the Data drop-down list.
• Maximum – enter the maximum value for the data validation option that you selected in
the Data drop-down list.
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 on
the Delete Contents dialog (Figure 43), 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 44), 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.
Editing data | 65
Deleting cells
This option completely deletes selected cells, columns, or rows. The cells below or to the right of
the deleted cells will fill the space.
1) Select a cell or a range of cells.
2) Select Sheet > Delete Cells on the Menu bar, or right-click inside the selected cells and
choose Delete in the context menu, or press the Ctrl+– keys.
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.
Editing data | 67
Paste Special function
You can use the Paste Special function to paste into another cell selected parts of the data in the
original cell or cell range, for example its format or the result of its formula.
Tip
Instead of steps 5) and 6) above, you can choose one of the four preset options at
the left of the dialog – Values Only, Values & Formats, Formats Only, or
Transpose All. With the Run immediately checkbox ticked, clicking one of these
shortcut buttons actions the requested paste operation and closes the dialog.
Editing data | 69
4) Alternatively, use the Paste Only Text, Paste Only Numbers, or Paste Only Formula
options in the Edit > Paste Special menu on the Menu bar.
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, use one of the following methods
Method 1
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 45).
4) Under Properties, select Wrap text automatically and click OK.
Method 2
1) Select the cell.
2) On the Properties deck of the Sidebar, open the Alignment panel (Figure 46).
3) Select the Wrap text option to apply the formatting immediately.
Formatting data | 71
Shrinking text to fit a cell
The font size of the data in a cell can automatically adjust to fit inside cell borders.
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 45).
4) Under Properties, select Shrink to fit cell size and click OK.
Formatting numbers
Several number formats can be applied to cells by using icons on the Formatting toolbar
(highlighted in Figure 47). 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 52):
• Apply any of the data types in the Category list to the data.
• Select one of the predefined formats in the Format list.
• Control the number of decimal places and leading zeroes in Options.
• Enter a custom format code. This is a very powerful facility that is detailed in the Number
Format Codes page of the Help.
• The Language setting controls the local settings for the different formats such as the date
format and currency symbol.
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 48) and select a font in 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 and Align Right). The Format > Align menu also provides these options in
addition to the Justified alignment.
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 49).
Formatting data | 73
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.
5) Click OK to apply the font effects and close the dialog.
Any font effect changes are applied to the current selection, or to the entire word that contains
the cursor, or to any new text that you type.
Text orientation
To change the text direction within a cell, use the Alignment tab on the Format Cells dialog
(Figure 45 on page 71).
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.
An Asian layout mode checkbox is available on the Alignment tab of the Format Cells dialog
when Asian language support is enabled and the text direction is set to vertical. This option aligns
Asian characters one below the other in the selected cell(s). If the cell contains more than one
line of text, the lines are converted to text columns that are arranged from right to left. Western
characters in the converted text are rotated 90 degrees to the right. Asian characters are not
rotated.
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 in the context
menu, then click on the icon you require and it will be placed on the Formatting
toolbar.
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.
Formatting data | 75
Alternatively, use the icons on the Formatting toolbar to apply default styles to borders:
1) Click the Borders icon and select one of the options displayed in the Borders palette.
2) Click the Border Style icon and select one of the line styles from the Border Style palette.
3) Click the Border Color icon to apply the most recently selected color. Click the down
arrow to the right of the Border Color icon to select another color from the Border Color
palette.
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 on the Tools toolbar, to open the Theme Selection dialog (Figure 53), 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.
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 in 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 55 to 59 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 in the Functions list.
3) Use the cursor to select all your random numbers.
4) Click OK to close the Function Wizard.
Hiding data
Sheets
Select Sheet > Hide Sheet on the Menu bar, or right-click on the sheet tab for the sheet to be
hidden and select Hide Sheet in the context menu. There must always be one sheet that is not
hidden.
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.
Showing data
Sheets
Select Sheet > Show Sheet on the Menu bar, or right-click on any sheet tab and select Show
Sheet in the context menu. Choose which hidden sheets to show from the list on the Show Sheet
dialog. If there are no hidden sheets, the Show Sheet option will not appear in the context menu
and will be grayed on the Menu bar.
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 63).
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 62).
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) On 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
64 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.
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 65 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.
Use the Standard Filter dialog to define the filter conditions to be combined to form the overall
filter criteria. Each filter condition is specified by indicating the type of logical operator, the name
of a field, a logical condition, and a value.
• Operator – for the following arguments, you can choose between the logical operators
AND and OR. No logical operator is specified for the first filter condition in the list.
• Field name – specifies the field names from the current table to set them in the
argument. You will see the column identifiers if no text is available for the field names.
• Condition – specifies the comparative operators through which the entries in the Field
name and Value fields can be linked.
• Value – specifies a value to filter the field. The Value list box contains all possible values
for the specified Field name. Select a value to be used in the filter, including Empty and
Not Empty entries.
• Remove – deletes the associated filter criterion from the Filter Criteria area.
• Case sensitive – distinguishes between uppercase and lowercase letters when filtering
the data.
• Range contains column labels – includes the column labels in the first row of a cell
range.
• Copy results to – select the check box and then select the cell range where you want to
display the filter results. You can also select a named range from the list.
• Regular expressions – select to use regular expressions in the filter definition. If
selected, you can use regular expressions in the Value field of the Standard Filter dialog
if the Condition field is set to “=” (equal) or “<>” (not equal). For more information about
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, click the AutoFilter icon on the Standard
toolbar, or press Ctrl+Shift+L. An arrow button is added to the head of each column in the
database range and the size of these buttons scales according to the sheet’s zoom level.
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 67).
Note
The options for advanced filtering are the same as those used for standard filtering,
see “Applying a standard filter” on page 89 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.
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.
Sorting records | 93
Figure 70: Sort dialog – Sort Criteria tab
Sort options
On the Options tab of the Sort dialog (Figure 69), 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 an 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 72), 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 72), enter the search criteria in the Find box.
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) To place a chart on the spreadsheet as an object (Figure 75) and open the Chart Wizard
dialog (Figure 76), do one of the following.
– 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 75: Example chart automatically created using the Chart
Wizard
The initial chart created using the Chart Wizard is a 2D column chart. A small preview of the
selected variant is highlighted with a surrounding border, as shown in Figure 76. The name of the
variant (Normal in Figure 76) is shown below the preview.
To change chart types and options:
1) Select the type of chart from the list under Choose a Chart Type.
2) If needed, select a chart variant in the preview box by clicking on it. The options available
depend on the type of chart selected. The chart changes instantly to reflect the selection.
3) To use a 3D chart, select the checkbox 3D Look and select the type of 3D view
(Realistic or Simple). This option is available only for column, bar, pie, or area charts.
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.
To select non-adjacent data, do one of the following while in step 1)) above:
• Manually enter the data ranges in the text box with delimiter(s) between them.
• Select the data with the cursor by first clicking the Select data range button to the right
of the Data range box. Place the cursor at the end of the first data range in the text box
(otherwise the first range is selected and then deleted) and enter the delimiter. Then drag
the cursor in the spreadsheet to select the next data range.
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 78).
To organize the data series, select an entry in the Data series list and do one or more of the
following:
• To change the name of the data series, select Name in the Data ranges list on the right.
Edit the cell references in the Range for Name text box below.
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 78. Not all data ranges may need to be filled
in.
The data ranges may include:
Border Color and Fill Color
Border and fill colors for each data point in the data series can be specified here using
numeric values for the RGBA color system. If not specified here, Calc will use default
colors. Conditional formatting can also be used. This enables data point colors to vary,
depending on whether they meet certain conditions or values. For further information, refer
to “Assigning colors” on page 125.
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 108 and 109).
Depending on the type of chart, other data ranges may need to be defined in addition to those
shown in Figure 78.
To add elements to a chart, do one or more of the following on the Chart Elements page (Figure
79):
• Enter a title and subtitle (if desired) in the Title and Subtitle text boxes.
• Enter names to be used in the X axis and Y axis text boxes. The Z axis text box is only
active if creating a 3D chart.
• Select the Display legend checkbox (turned on by default) and choose where to display
the legend – Left, Right, Top, or Bottom. The names in the legend are the data series
names. Specify the names in the Range for Name field on the Data Series page.
• Under Display Grids, select the Y axis or X axis check boxes to display horizontal or
vertical grid lines respectively. For some charts, the axis grids are displayed by default.
Grids are not available for pie charts. The Z axis checkbox is only active when creating a
3D chart. For further information about grids, refer to Grids on page 139.
Figure 81: Properties deck of the Sidebar when chart is selected (left) and when chart is in
edit mode (right)
The contents of the Sidebar depend on whether the chart is selected or is in edit mode. The
Sidebar on the left in Figure 81 shows the Properties deck when a chart is selected (by clicking
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.
Modifying charts
The Chart Wizard establishes basic features of a chart. After using it, you may want to change
data ranges or modify the look of the chart. Calc provides many options for formatting and fine-
tuning the appearance of charts. This includes tools for editing the chart type, chart elements,
data ranges, fonts, colors, and many other options.
Modify charts in one of two ways, depending on what you want to change.
Edit object properties
Click on a chart once to edit its object properties. These include size, position on the page,
alignment, outer borders, copying, exporting, and more. See the sections starting with
“Resizing, moving, and positioning charts” on page 153 for more information.
Use edit mode
Use edit mode to change data selection and chart type as well as elements such as axes,
titles, backgrounds, grids, data series, data labels, trend lines, and more.
Note
The next several sections (until “Resizing, moving, and positioning charts” on page
153) require a chart to be in edit mode.
Insert menu
In edit mode, the Insert menu on the Menu bar displays the options shown in Figure 82.
Format menu
In edit mode, these settings appear on the Format menu (Figure 83) of the Menu bar.
Formatting toolbar
In edit mode, the Formatting bar appears as in Figure 84. 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 and it is displayed in the Select Chart Element area of the
Formatting toolbar.
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 86):
– Click Format > Title and select the desired type of title or the All Titles option.
Figure 86: Titles formatting dialog (after selecting All Titles option)
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 and mean lines when those
are turned on, as shown in Figure 87.
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 104. 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 114.
Formatting legends
For advanced editing of a legend’s appearance, a more extensive Legend dialog (Figure 89) 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 89):
– Click on the Legend icon on the Formatting toolbar.
Legends | 117
– Select 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 103 and “Selecting data series” on
page 104.
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.
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.
In addition to directly assigning colors, you can 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 96 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 96: Using the COLOR function and a conditional formula to specify colors
The chart on the right in Figure 96 shows how the colors change to reflect the conditional
formatting.
Axes
Add or remove axis labels
Use the Axes dialog shown in Figure 98 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 115).
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.
3) Select or deselect the check boxes for axis labels. The Z-axis checkbox is only active
when editing a 3D chart.
4) Click OK to close the dialog. If desired, click outside the chart to leave edit mode.
Axes | 127
It is also possible to align one or more data series to the secondary Y axis. Do this using the Data
Series dialog, described in “Aligning data to secondary Y axis” on page 122.
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 122).
The contents of the Scale tab (Figure 100) 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 shown in the Y axis in
Figure 101.
Axes | 129
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.
Minimum/Maximum
Sets the first/last value for the axis. Automatic must be deselected to set this option
manually.
Major interval
Defines the intervals between major divisions of the axis. These intervals will be used for
interval marks (specified on the Positioning tab of the Axis dialog) and gridlines. Automatic
must be deselected to set this option manually.
Minor interval count
Defines the number of intervals (not the values between intervals) that subdivide the major
intervals. The same as for major intervals, the interval count defined here will be used for
interval marks (specified on the Positioning tab of the Axis dialog) and gridlines. Automatic
must be deselected to set this option manually.
For some types of charts, additional options may be available:
Type
Specifies whether the labels are text, date, or should be detected automatically.
Resolution
For dates, specifies that the interval steps should be days, months, or years.
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 95 on page 125 but
excluding the Icon section.
Axes | 131
Label tab
On the Label tab (Figure 105), 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.
Numbers
Use the Numbers tab (Figure 106) 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.
Axes | 133
Font and Font effects
Use the Font and Font Effects tabs to set the font and font effects for the axis labels. These tabs
are the same as the tabs for specifying fonts and font effects in cells. See Chapter 2, Entering,
Editing, and Formatting Data, for more information.
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.
3) To open the Data Labels dialog (Figure 109), 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 108). The controls on this
dialog are similar to those on the Data Labels tab of the Data Labels dialog, which are
described below.
– 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.
Value as percentage
Displays the percentage value of the data points in each data series. When selected, this
option activates the Percentage format button. Note that the percentage referred to is a
data point’s Y value as a percent of total Y values for a specific X category or value. Thus,
in Figure 110, the February canoe value 9 is 10% of the total February value of 94 (the sum
of 9, 31, and 54).
Percentage format
Opens the Number Format for Percentage Value 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 Number Format for Percentage
Value dialog.
Grids
Grid lines or grids divide the intervals along axes to help estimate data point values. Major and
minor grid lines are shown in Figure 111. The darker lines with numbers are major grid lines while
the lighter lines between them are minor grid lines. Note that the Y-axis major grid line is
activated by default.
Figure 111: Major and minor gridlines for the X and Y axes
Grids are available for all chart types with the exception of pie charts.
Grids | 139
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 112, there is another dialog for formatting grids. To
open the grid formatting 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) Go to Format > Grid on the Menu bar and select the appropriate type of grid to open the
Grid formatting dialog (Figure 113).
Note
Use the Scale tab of the Axis dialog to specify the intervals between grid lines. This
is described in “Defining scales” on page 129.
Formatting 3D view
To make changes to a 3D chart, use the 3D View dialog (Figure 114).
3D charts | 141
3) Make any changes required.
4) Click OK to close the dialog. If desired, click outside the chart to leave edit mode.
This dialog has three tabs, which are explained below.
Appearance
Use the Appearance tab of the 3D View dialog (Figure 115) 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.
Illumination
Use the Illumination tab (Figure 116) of the 3D View dialog to control light sources for the 3D
view.
3D charts | 143
• By default, the second light source is switched on. It is the first of seven normal, uniform
light sources. To activate the others sources, click twice on their respective button.
• 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
Regression through equation y = a ∙ x+b. Intercept b can be forced.
Logarithmic
Regression through equation y = a ∙ ln(x) + b. Only positive x values are used.
Exponential
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
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.
Polynomial
Regression through equation y = Σi (ai ∙ xi). Intercept a0 can be forced. Degree of
polynomial must be given (at least 2).
Tip
It is possible to add multiple trend lines to a single data series. This could be useful
when you want to compare different regression types for your data.
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 119. The
Status bar is normally located at the bottom of the spreadsheet.
Error bars
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.
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.
Callouts
Draws a line that ends in a graphic in which text can be placed. Use a callout to describe or
draw attention to a specific point or area. Double-click the callout to write text in it. In Figure
124, Callouts option 8 creates a default callout while option 13 opens a tool palette of
callout styles.
Clicking the down arrows next to the last six options on the right of the Drawing toolbar (Figure
124) opens tool palettes similar to those shown in Figure 125.
Basic Shapes Symbol Shapes Block Arrows
Figure 125: Tool palettes that can be opened from the Drawing toolbar
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.
Figure 126: Position and Size dialog — Position and Size tab
Rotation
The options for the Rotation tab (Figure 127) are as follows:
Figure 128: 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 124) to select them.
Line Style/Line Width/Line Color
Formats the outer borders of charts.
Area Style/Filling and Fill Color
Colors objects such as arrows, shapes, and callouts. For charts, use the fill options
available in edit mode.
Arrow Style
Specifies the appearance of line arrows and lines. Does not apply to the block arrows
shown in Figures 124 and 125.
Rotate
Rotates the chart around a base point. When selected, places round rotation handles at
each corner. Move these to rotate the chart. Move the small circle in the center of the chart
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.
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.
Deleting charts
To delete a chart, click it once to select it. Square selection handles appear on the borders of the
chart. Then press Delete.
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 131.
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 132 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 142).
• 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
The data range for the chart on the left in Figure 144 includes the cells containing the months.
However, the months do not appear on the chart because only values can be used in XY
(scatter) charts and Calc substitutes them for cardinal numbers.
The data range for the chart on the right does not include the cells containing the months. Calc
assumes that the first row (or column) of data contains values for the X axis. The Y values of the
other data series are paired with each of those X values. This means that there are no data
points for the Japanese yen but each of the other currencies are shown in comparison to the yen,
since it supplies the X values.
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 145 shows how the data ranges can be set for a bubble chart.
Note
Remember that bubble charts require numeric data. If the data series for the X axis
contains text (or dates not formatted as numbers) cardinal numbers will be used for
axis labels.
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 147 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 149: 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 150. 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.
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 122.
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 155).
Figure 152: Stock chart variant 1 showing low, high, and closing prices
Figure 153: Stock chart variant 2 showing low and high prices as well as the
range between opening and closing prices
Figure 155: 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, then all of the other styles, inheriting from it, will change to match.
Styles menu
By default, the Styles menu (Figure 159) 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.
Caution
When Fill Format mode is active, a right-click anywhere in the document cancels the
last Fill Format action. Be careful not to accidentally right-click and thus cancel any
formatting actions you want to keep.
Figure 161: 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 162).
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 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 200 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
the new style. For example, you could make the styles identical except for the font color;
if you later change the font family of the parent style, the new style’s family will also
change.
• Edit Style – enables you to view and edit the properties of the parent style.
• Category – displays the category for 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. Select Hidden Styles if you want that style to appear only in the Styles
list.
• Contains – describes the formatting used in the style.
Numbers tab
• Category – select a category from the list.
• Format – select how you want the contents of the selected cells to be displayed.
When you select Currency as a category, you need to select a currency in 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.
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 166
shows the Font tab of the Cell Style dialog when the Asian and Complex text layout options are
Alignment tab
• Text Alignment – sets the alignment options for the contents of the current cell, or the
selected cells.
– Horizontal – select the horizontal alignment option that you want to apply to the cell
contents:
• Default – aligns numbers to the right and text to the left.
• Left – aligns the contents of the cell to the left.
• Center – horizontally centers the contents of the cell.
• Right – aligns the contents of the cell to the right.
• Justified – aligns the contents of the cell to the left and to the right cell borders.
• Filled – repeats the cell contents (number and text) until the visible area of the cell is
filled. This feature does not work on text that contains line breaks.
• Distributed – aligns contents evenly across the whole cell. Unlike Justified, it also
justifies the very last line of text.
Borders tab
Sets the border attributes for 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 in 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.
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 on 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 164) or the Page Style dialog (Figure 173).
3) Make the necessary changes to the style attributes. For more information on style
attributes, see “Cell style attributes” on page 186 and “Page style attributes” on page 194.
4) Click OK to save the changes and close the dialog.
Renaming styles
You can rename custom styles, but not the styles supplied with Calc.
1) Go to the Styles panel on the Sidebar (Figure 160) 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 in 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 160) 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 in 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 176) 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
204 for more information).
6) Click Save to save the new template.
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 and navigate to the appropriate template folder before clicking the Save
button.
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 (Figure 177). The template opens in Calc.
3) Edit the template as you would edit any other spreadsheet. To save the changes, choose
File > Save on the Menu bar or perform any equivalent action. To save the edited
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
need to use one of the procedures described in “Changing the template assigned to
a document” below.
Installing templates
You can import and add templates to your collection as follows:
1) Find and download the template you want to use, as described in the previous section.
2) Open the Templates dialog and click the Import icon near the bottom right.
3) In the pop-up dialog, select the category where you want to store the template. (You can
change this later, as described in “Moving a template” on page 206.)
4) A file browser opens. Navigate to the location of the downloaded template on your
computer.
5) Select the template and click Open. After import, the template becomes available in the
Templates dialog.
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.
Tip
The location of template folders in LibreOffice depends on the operating system of
your computer. If you want to know where the template folders are located, go to
Tools > Options > LibreOffice > Paths.
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 182), 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 177).
3) A message box appears and asks you to confirm the deletion. Click Yes.
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 Images and 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
When inserting the same image several times in a document, it might appear
beneficial to create links. However, this is not necessary, as LibreOffice embeds only
one copy of the image file in the document. Deleting one or more of the copies does
not affect the other copies of the same file.
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.
Caution
If the application from which the image was copied is closed before the image is
pasted into the target, the image stored on the clipboard could be lost.
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 217.
• Align Objects – 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
217.
• 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 216.
• 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.
• Image Mode – changes the display of the image from color (Default) to grayscale, black
and white, or a watermark. This setting affects only the display and printing of the image;
the original image file remains unchanged.
• Crop Image – places cropping handles around the image. Drag a handle to crop (hide)
the edges of the image.
• Flip Horizontally and Flip Vertically – changes the orientation of the image.
Figure 187:
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 190: Position and Size dialog – Position and Size tab
Arranging images
Each image that you place in a spreadsheet is successively stacked on the preceding image,
whether or not they overlap. Use the arrange commands to change the stacking order of images.
You cannot change the stacking order of text.
1) Select the image you want to change.
2) Go to Format > Arrange on the Menu bar, or right-click on the image and select Arrange
in the context menu, then select one of the available arrangement options.
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).
2) Go to Format > Align Text on the Menu bar, or click the down arrow at the right of the
Align Objects icon on the Image toolbar, or right-click on one of the images and select
Align Objects in the context menu.
3) Select one of the options available for alignment.
Tip
Press the main area of the Align Objects 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 191. 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 192: Drawing Object Properties toolbar – some controls are 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 193) and some are shown in the Properties deck of
the Sidebar (Figure 194).
Additional tools
Some additional tools are available when you right-click on an image or drawing object and open
the context menu.
Description
You can add metadata in the form of a title and description to an image. This information is
used by accessibility tools (such as screen reader software) and as ALT (alternative text)
attributes if you export the document to HTML.
Name
You can add a custom name to be assigned to an image; this will make the image easier to
find in the Navigator. Also, assigning names to images helps identify them when teams of
people are working on the same multi-page spreadsheet.
Rotate or Flip
You can rotate the image or flip it horizontally or vertically.
Assign Macro
Opens the Assign Macro dialog so you can add programmable functionality to the graphic.
Calc has a very good macro functionality. For more information, see Chapter 12, Macros.
Edit Hyperlink
You can define a hyperlink from an image to another location in your spreadsheet, another
document, or a web page. Select Edit Hyperlink in the context menu to open the Hyperlink
dialog. See Chapter 10, Linking Data, for more information on hyperlinks.
Compress
You can compress images to reduce the file size of the spreadsheet. Select Compress in
the context menu to open a Compress Image dialog where you can set the compression
options. (Option not available for drawing objects.)
Edit with External Tool
You can edit an image with an external tool. The dialog that opens will depend on your
computer setup. (Option not available for drawing objects.)
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, Emailing,
and Signing
Printing
Quick printing
To quickly print a spreadsheet, click on the Print Directly icon (not visible by default) 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.
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 200).
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.
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.
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 200), you can choose from the following options:
• Printer
– Select the printer to use, from the list of those available.
– Click 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 227.)
• Page Layout
– Select page layout properties such as paper size, portrait, or landscape orientation;
how many pages are printed per sheet of paper; the order in which the pages are
printed on a sheet of paper; and whether a border is drawn around each page.
Printing | 225
Figure 200: Print dialog – General tab
Tip
To access some of the options on the General tab of the Print dialog, you may need
to click one of the More buttons. For simplicity, these clicks are deliberately omitted
from the descriptions in this chapter.
Printing | 227
3) In the Range and Copies area of the General tab of the Print dialog, choose Print
Selected Sheets in the From which drop-down.
4) Click Print.
To print a selection of cells:
1) In the spreadsheet, select the cells to print.
2) 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.
3) In the Range and Copies area of the General tab of the Print dialog, choose Print
Selected Cells in the From which drop-down.
4) Click Print.
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) In the Defaults section, select Convert colors to grayscale. Click OK to save the
change.
Caution
This changes the print settings for all components of LibreOffice, not just Calc
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 230.
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:
• Row break – inserts a horizontal page break above a selected cell in a row. For
example, if the selected cell is H15, then a row break is created between rows 14 and 15.
• Column break – inserts a vertical page break to the left of the selected cell in a column.
For example, if the selected cell is H15, then a column break is created between columns
G and H.
When a manual break is inserted, it appears as a blue line or as a bold line between the rows or
columns on the display. The actual appearance depends on your computer setup. To see manual
break lines more easily on your display, you can change their appearance. Go to Tools >
Options > LibreOffice > Application Colors and scroll down to the Spreadsheet section where
you can change how page breaks appear.
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 on the Status Bar.
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.
Note:
Selecting the Whole Sheet Export option causes Calc to disregard many of the
other settings on the PDF Options dialog.
Note
Outlines are generally not used in Calc.
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 easily 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 the function 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 224.
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 Result (A=4, B=5)
= Equal A1=B1 FALSE
> Greater than A1>B1 FALSE
< Less than A1<B1 TRUE
>= Greater than or equal to A1>=B1 FALSE
<= Less than or equal to A1<=B1 TRUE
<> Inequality A1<>B1 TRUE
If cell A1 contains the numerical value 4 and cell B1 contains the numerical value 5, the above
examples would yield results of FALSE, FALSE, TRUE, FALSE, TRUE, and TRUE.
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.
When you enter B4:A2, B2:A4, or A4:B2 directly, 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. For more
information on naming cells, see “Named ranges” on page 261.
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 228.
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.
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.
2) In cell E2 type the formula =D2*D1. The result is 7.5, correctly shown.
3) Copy the formula in cell E2 to cell E3. The result is 200, clearly wrong! Calc has copied
the formula using relative addressing: the formula in E3 is =D3*D2 and not what we want,
which is =D3*D1.
4) In cell E2 edit the formula to be =D2*$D$1. Copy it to cells E3 and E4. The results are
now 15 and 22.5 which are correct.
The $ signs before the D and the 1 convert the reference to cell D1 from relative to absolute or
fixed. If the formula is copied to another cell the second part will always show $D$1. The
interpretation of this formula is “take the value in the cell one column to the left in the same row
and multiply it by the value in cell D1”.
Tip
To change references in formulas, highlight the cell and press F4 to cycle through the
four types of references. To cycle only part of the formula select the cells in the
formula bar and cycle with F4. Selecting the menu option Sheet > Cycle Cell
Reference Types is equivalent to pressing the F4 shortcut.
Knowledge of the use of relative and absolute references is essential if you want to copy and
paste formulas and to link spreadsheets.
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 233: 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 follows:
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 234), 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.
Tip
You can find more details about each of the available functions in the Calc Functions
area of The Document Foundation Wiki at
https://wiki.documentfoundation.org/Documentation/Calc_Functions. These wiki
pages are a recent addition to the available documentation and are continuously
undergoing improvement.
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:
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
calculated by a simpler function call or arithmetic operation and then combined following the rules
of calculation. It is possible to visualize each parsed element of the formula and check if the
intermediate results are correct, until the mistake is found.
Functions can be entered into the Input line. After you enter a function on the Input line, press the
Enter key or click the Accept button on the Formula Bar to add the function to the cell and get its
result.
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 242: 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 242), 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
=10*A1:C5 and confirm this entry using the key combination Ctrl+Shift+Enter. The result is a 3 x
5 array in which the individual values in the cell range (A1:C5) are multiplied by a factor of 10.
In addition to multiplication, you can also use other operators on the reference range (an array).
With Calc, you can add (+), subtract (-), multiply (*), divide (/), use exponents (^), concatenation
(&) and comparisons (=, <>, <, >, <=, >=). The operators can be used on each individual value in
the cell range and return the result as an array if the array formula was entered.
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
#REF!
cell is 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
#VALUE! example, double-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
#NUM!
defined value 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 text contents and 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 are in black characters and the numeric contents are 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 in 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 on the Menu bar or press
Shift+F9. Figure 249 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.
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)).
The main disadvantage of using arithmetical operators is that you cannot directly use a range of
cells. In other words, to enter the equivalent of =SUM(A1:A3), you would need to type
=A1+A2+A3.
Otherwise, whether you use a function or an operator is largely up to you—except, of course,
when you are subtracting. However, if you use spreadsheets regularly in a group setting such as
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 divide 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,
and the type of rank (0 for the rank from the highest, or any other value for the rank from
the bottom).
Some of these functions overlap; for example, MIN and MAX are both covered by QUARTILE. In
other cases, a custom sort or filter might give much the same result. Which you use depends on
Figure 250: Tools > Options > 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 251 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
found on the extensions site at https://extensions.libreoffice.org/. Refer to Chapter 14, Setting up
and Customizing, for more details.
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, analyzing, and summarizing 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. Besides, 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 an 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 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.
Introduction | 287
Calc displays the Select Source dialog (Figure 252), where you can choose between using the
selected data cells, a range of cells that has already been named, or a data source that has
already been registered with LibreOffice.
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.
Basic layout
In the Pivot Table Layout dialog (Figure 253) there are four areas that show the layout of the
resulting pivot table:
• Filters
• Column Fields
• Row Fields
• Data Fields
Besides these four areas is another area labeled Available Fields containing the names of the
fields in the source data list. To choose a layout, drag and drop the fields from the Available
Fields area to the other four areas.
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 255).
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 266: Division of the regions for employees (two row fields) without
subtotals
To remove grouping again, click inside the group, then choose Data > Group and Outline >
Ungroup, or press Ctrl+F12.
Given the input data shown in Figure 281, 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 282.
In the updated pivot table result, select Assembly, Production, and Warehouse in the Department
column. Select Data > Group and Outline > Group on the Menu bar or press F12 on the
keyboard. The pivot table updates again to reflect the new group, as shown in Figure 284.
You can change the default names for the groups and the newly created group field by editing
the name in the input field (for example changing Group2 to Technical). The pivot table will
remember these settings, even if you change the layout later on.
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 288: 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 253). Double-click the row or column field you want to sort. In
the Data Field dialog which opens (Figure 264), click Options to display the Data Field Options
dialog (Figure 270).
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 292: 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 293: Filter button in the upper left area of the pivot table
In the Filter dialog (Figure 294), you can define up to three filter options that are used in the same
way as Calc’s Standard 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 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 297: 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 302: Select the chart type through the Chart Wizard when creating a pivot chart
The second step is to select the chart elements and these are similar to those for normal charts
(Figure 303).
Note
When you delete a pivot chart, the associated pivot table is not affected.
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 table deletion.
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 305).
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 in the drop-down list to
the left of the field.
8) Select a function to aggregate your data in 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 settings shown in Figure
306.
Note
If you use the Link to source data option, each source link is inserted into the target
range, then ordered and hidden from view. Only the final results of consolidation are
displayed by default.
Consolidation example
Figures 307, 308, and 309 show a simple example of consolidation using a spreadsheet with the
sheets Year 1, Year 2, and Consolidated Sales. Figure 307 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
310. 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 310: 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 311):
– Select Insert > Function on the Menu bar
– Click the Function Wizard icon on the Formula bar
– Press Ctrl+F2
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 311). 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 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 312).
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 314: Partial outlined view of sales data example with subtotals
Column 1 represents the highest group level, the grand total over all employees. Outline columns
2 to 5 show descending group levels as follows:
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
316).
4) Optionally, add information to the Comment field. The example in Figure 316 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 section 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.
Figure 321: Inputs to Multiple Operations tool for one formula, one
variable
To answer this question:
1) Enter the following formula into B5: =B4*(B1-B2)-B3. This formula represents the
equation Profit = Quantity * (Selling price – Direct costs) – Fixed costs. With this equation,
our initial quantity produces a $6,000 profit, which is higher than the break-even point.
2) In D2:D11, enter a range of alternate quantities from 500 to 5000 in steps of 500.
3) Select the range D2:E11 to define the results table. This range includes the alternate
quantity values (column D) and the empty results cells (column E).
4) Select Data > Multiple Operations on the Menu bar to open the Multiple Operations
dialog.
5) Using the Formulas field, select the cell B5.
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 324: Inputs to Multiple Operations tool for one variable and two
formulas
Figure 325: 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
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 332).
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. If you want to start again, click the Reset All button and the data inserted in the
Solver dialog (Figure 332) will be cleared.
If you are using either the DEPS Evolutionary Algorithm or the SCO Evolutionary Algorithm, Calc
may periodically interrupt execution of the solver engine to display the Solver Status dialog
(Figure 333). This dialog provides diagnostic information about the current status of the engine’s
calculations, which may be of interest to an expert user of the Solver. Click OK to dismiss this
dialog and finish the calculations, or click Continue to allow the engine to carry on processing a
step further, with the diagnostic data on the dialog refreshed at the next break point. The display
of the Solver Status dialog is enabled by default but may be disabled by deselecting the Show
enhanced solver status setting on the Solver Options dialog.
On successful completion, Calc presents a Solving Result dialog (Figure 334). This dialog
includes buttons to save (Keep Result) or discard (Restore Previous) your results.
Solver options
Solver example
Suppose that you have $10,000 that you want to invest in two mutual funds for one year. Fund X
is a low risk fund with an 8% interest rate and Fund Y is a higher risk fund with a 12% interest
rate. How much money should be invested in each fund to earn a total interest of $1,000?
To find the answer using the Solver:
1) Enter the following labels and data into a worksheet:
– Row labels: Fund X, Fund Y, and Total in cells A2, A3, and A4.
– Column labels: Interest earned, Amount invested, Interest rate, and Time period in
cells B1 thru E1.
– Interest rates: 8% and 12% in cells D2 and D3.
– Time period: 1 in cells E2 and E3.
– Total amount invested: $10000 in cell C4.
– Enter an arbitrary value ($0 or leave blank) in cell C2 as the amount invested in Fund
X.
2) Enter the following formulas:
– In cell C3, enter the formula =C4–C2 (total amount – amount invested in Fund X) as
the amount invested in Fund Y.
– In cells B2 and B3, enter the formulas =C2*D2*E2 (B2) and =C3*D3*E3 (B3).
– In cell B4, enter the formula =B2+B3 as the total interest earned. Figure 336 shows
the worksheet at this point.
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 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.
Figure 339 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 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.
Figure 341 shows a small data set comprising student examination results in three subjects.
To illustrate how to use this tool, we use the input data set from Figure 341. Figure 344 shows the
analysis of variance results generated for this data using the settings shown in Figure 343.
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 345).
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 341. Figure 346 shows
the correlation coefficients generated for this input data using the settings shown in Figure 345.
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 347).
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 341. Figure 348 shows
the six covariance values generated for this input data using the settings shown in Figure 347.
Tip
For more information on statistical covariance, refer to the corresponding Wikipedia
article at https://en.wikipedia.org/wiki/Covariance.
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 350. 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 350. Figure 353 shows
the moving averages calculated for this input data using the settings shown in Figure 352.
Figure 353:
Calculated moving
averages
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 performs linear, logarithmic, or power regression analysis of a data set
comprising one dependent variable and multiple independent variables. Select Data > Statistics
> Regression on the Menu bar to access the Regression dialog (Figure 354).
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.
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.
To illustrate how to use this tool, we use the data set shown in Figure 355. This table contains
measurements taken at 1 second intervals.
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 360 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 358. In this case, the data
in columns A and B represent two independent sample sets, referred to as Variable 1 and
Variable 2. Figure 361 shows the F-test results calculated for this input data using the settings
shown in Figure 360.
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 362 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.
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.
Tip
When analyzing the Z-test results, compare the selected Alpha level with the
appropriate calculated P value (depending whether a one-tailed or two-tailed test is
required). If the calculated P value is smaller than the Alpha level, the hypothesis
(which, in the example given, is that the means of the two data sets are the same)
should be rejected.
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.
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 367. 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 366.
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.
Figure 367: Fourier analysis tool - example input data and results
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
368).
Figure 369: Creating a new sheet through the sheet tabs area
The above methods use either the Insert Sheet dialog (Figure 370) or the Append Sheet dialog
(Figure 371).
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.
• Choose the name for a single sheet (the Name field is unavailable if more than one sheet
is to be inserted).
Figure 372: 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.
Renaming sheets
Sheets can be renamed at any time. To give a sheet a more meaningful name:
• Enter the name in the Name box when you create the sheet.
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.
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 381).
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.
Note
HTML (Hypertext Markup Language) files containing links as relative to the file
system that are to be uploaded to a web server require the files be in a file structure
matching that of the web server. Otherwise, the links will point to the wrong folder.
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 will not recognize it as a hyperlink.
When you use the Hyperlink dialog to insert a hyperlink, you can select either a text hyperlink
(Figure 385) or a button hyperlink (Figure 386). In both cases, the visible text can be different
from the linked URL.
Note
This will change the color for all hyperlinks in all components of LibreOffice, which
may not be what you want.
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, do one of the following:
• Ctrl-click with the cursor positioned over the hyperlink. This method only works 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 method only works 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 method only works when the form design
mode is deactivated; the status of this mode is controlled by clicking the Design Mode button on
either the Form Controls toolbar or the Form Design toolbar.
Hyperlink dialog
You can insert and modify hyperlinks using the Hyperlink dialog (Figure 387). 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.
On the left side of the dialog, select one of the four categories of hyperlink:
• Internet. The hyperlink points to a WWW (World Wide Web) or FTP (File Transfer
Protocol) address.
• Mail. The hyperlink points to an email address.
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.
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.
Note
If the source Calc or Microsoft Excel spreadsheet contains no range names or
database ranges, then you cannot use that document as the source file in the
External Data dialog.
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 396). 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.
Note
The Status column on the Edit Links dialog always shows Manual for a link created
using the External Data dialog. The status shown in this column does not reflect the
setting of the Update every … seconds option on the External Data dialog.
Figure 402: Using the Name Box to find a data range name
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 dBASE 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.
Embedding spreadsheets
Spreadsheets can be embedded in other LibreOffice files and vice versa. This is often used in
Writer or Impress documents so that Calc data can be used in a text document or a presentation.
You can embed the spreadsheet as either an OLE (Object Linking and Embedding) or DDE
(Dynamic Data Exchange) object. The difference between a DDE object and a Linked OLE object
is that a linked OLE object can be edited from the document in which it is added as a link, but a
DDE object cannot.
For example, if a Calc spreadsheet is pasted into a Writer document as a DDE object, then the
spreadsheet cannot be edited in the Writer document. But if the original Calc spreadsheet is
updated, the changes are automatically made in the Writer document. If the spreadsheet is
inserted as a Linked OLE object into the Writer document, then the spreadsheet can be edited in
Writer as well as in the Calc document and both documents are in sync with each other.
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 OK. 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
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 associated button to allow updating of 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>
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 421) 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 413.
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 422). 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.
You may want to explain your rationale for the changes. You can do this by adding comments to
the changes you made or by adding general comments to the spreadsheet.
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.
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
If you hover the cursor over a cell that has both a change comment and a general
comment, both comments are shown in the displayed tip.
Note
View > Comments and the Navigator show general comments but not the
comments associated with tracked changes.
Comparing documents
Sometimes reviewers may not record the changes they make. Calc can find the changes by
comparing documents.
To compare documents, you need to have the original document and the one that is edited.
1) Open the edited document that you want to compare with the original document.
2) Select Edit > Track Changes > Compare Document.
3) A file selection dialog opens. Select the original document and click Open.
4) Calc opens the Manage Changes dialog showing the changes identified.
Calc finds and marks the changes as follows:
• All data that occurs in the edited document but not in the original is identified as inserted.
• All data in the original document that is not in the edited document is identified as
deleted.
• All data that is changed is marked as changed.
From this point you can go through and accept or reject changes, as described earlier.
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, Python, JavaScript, and BeanShell). 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 Python, JavaScript, and
BeanShell 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 434 into cells A1:C3 of Sheet1 in the new
spreadsheet.
7) Select the All option in the Paste area and Multiply in the Operations area (both options
are highlighted with a red box in Figure 436), and click OK. The values in cells A1:C3 are
now multiplied by 3 (Figure 437).
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 438 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.
Note
The libraries, modules, and macro names must follow some strict rules. Following the main
rules, the names must:
• Comprise lower case letters (a..z), upper case letters (A..Z), digits (0..9), and
underscore characters (_)
• Begin with a letter or an underscore
• Not contain any other spaces, punctuation symbols, or special characters (including
accents)
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 440).
Sub PasteMultiply
' --------------------------------------------------------------
' define variables
dim document as object
dim dispatcher as object
' --------------------------------------------------------------
' get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
' --------------------------------------------------------------
dim args1(5) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Flags"
args1(0).Value = "A"
args1(1).Name = "FormulaCommand"
args1(1).Value = 3
args1(2).Name = "SkipEmptyCells"
args1(2).Value = false
args1(3).Name = "Transpose"
args1(3).Value = false
args1(4).Name = "AsLink"
args1(4).Value = false
args1(5).Name = "MoveMode"
args1(5).Value = 4
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.
• 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.
Tip
The Option Explicit statement forces all variables to be declared before they
are used. If Option Explicit is omitted, variables are automatically defined at
first use as type Variant.
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+S, to save the modified Module1.
Tip
Function names are not case sensitive. In Figure 446, 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 451).
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 one
Function TestMax(x, y)
If x >= y Then
TestMax = x
Else
TestMax = y
End If
End Function
Function SumCellsAllSheets()
Dim TheSum As Double
Dim i As integer
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 453. 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 455).
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;
Click the Edit button on the JavaScript Macros dialog to access the Rhino JavaScript Debugger
(Figure 458). Rhino is an easy-to-use open source JavaScript engine from the Mozilla
Foundation and more information can be found at https://github.com/mozilla/rhino.
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();
spreadsheetInterface = UnoRuntime.queryInterface(XSpreadsheetDocument,
documentRef);
allSheets = UnoRuntime.queryInterface(XIndexAccess,
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. In
recent years it has grown in popularity and is commonly used by data scientists
When you select Tools > Macros > Organize Macros > Python on the Menu bar, Calc displays
the Python Macros dialog (Figure 459).
import uno
def HelloWorld():
doc = XSCRIPTCONTEXT.getDocument()
cell = doc.Sheets[0]['A1']
cell.setString('Hello World from Python')
return
ScriptForge library
Macro programmers frequently need to perform tasks such as creating and opening files,
accessing form controls, reading data from databases embedded in LibreOffice Base documents,
and so forth. The objective of the ScriptForge library is to simplify the creation of macros by
making it easier to execute such commands without having to learn the required LibreOffice APIs
(Application Programming Interfaces) and commands, which may be difficult for casual
programmers.
The ScriptForge library supports both LibreOffice Basic and Python. It is organized into a set of
services, each of which provides methods and properties related to a specific topic. For example,
the Dialog service provides access to dialogs available in script modules and the Database
service allows execution of SQL commands in Base documents.
Chapter 13, Getting Started with Macros, of the Getting Started Guide contains additional
introductory material about the ScriptForge library and includes a simple example. More detailed
information and many examples can be found in the LibreOffice Help system, by searching for
the term “ScriptForge” in the index.
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
' Worksheets(“Sheet1”).
oSheet = ThisComponent.getSheets().getByIndex(0)
' Range("A1")
oCell = oSheet.getCellByPosition(0, 0)
sVar = oCell.getValue()
Print sVar
End Sub
Option VBASupport may affect or assist in the following situations:
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.
If you are already familiar with the BASIC language (or with one programming language), the
LibreOffice Extensions website (https://extensions.libreoffice.org) has a set of LibreOffice Basic
quick reference cards. These can be located quickly by selecting the Documentation and Macro
tag filters.
Additional detail about Calc’s macro facilities can be obtained from the LibreOffice Help system
(search for “macros” in the index for general information, or search for “VBA Support” to find
some specific VBA Support information), The Document Foundation’s wiki pages
Conclusion | 443
Calc Guide 7.2
Chapter 13
Calc as a Database
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.
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. In the other direction, for Base users who wish to take
advantage of some of Calc’s features to analyze or visualize their data, Base can be used for
creating linked data ranges in Calc files, for pivot table analysis, or as the basis for charts. See
the Base Guide for more information.
Earlier versions of this chapter contained several examples with LibreOffice Basic macros. These
are now available on The Document Foundation’s wiki at
https://wiki.documentfoundation.org/Macros/Calc. Much of the macro information on those pages
is drawn or adapted from Andrew Pitonyak’s book, OpenOffice.org Macros Explained (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 462). 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.
Introduction | 445
component of LibreOffice is a fully featured relational database management system. Calc does
not support the relational database model.
Named ranges
Technically a named range is a named formula expression and its content is always set as a
string. A commonly used type of expression is an absolute cell range like
“$Sheet1.$A$1:$E$15”. However, other expression types are possible. For example, the
expression “$Sheet1.$A$1:$A$4~$Sheet1.$B$1:$B$4” encompasses two separate cell
ranges (the tilde character is a reference concatenation operator). Alternatively a formula
expression such as “PI()*B1*B1” might be defined to calculate the area of a circle, given the
radius. In the remainder of this section we will be concerned only with named ranges defined as
a single matrix-like cell range.
A quick way of creating a new named range is to select the relevant cells in your sheet and then
simply start typing a name in the Name Box, located at the left of the Formula bar. Notice the
“Define Name for Range” tooltip that appears as you type and press the Enter key when you
have finished typing.
Named ranges are also created using the Define Name dialog (Figure 463), which is opened
either by selecting Sheet > Named Ranges and Expressions > Define on the Menu bar or by
clicking the Add button on the Manage Names dialog (Figure 464).
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
Avoid giving multiple rows or columns the same label, as the ranges generated from
them will likewise share the same name, and can end up being overwritten by Calc.
Database ranges
Although it can be used like a regular named range, a database range is intended 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 single rectangular 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, which
is possible with a named range.
• Database ranges store sorting, filtering, subtotaling, and data import settings in data
structures called descriptors, which can be retrieved and accessed using macros. All
descriptors of a database range are updated when a database operation is carried out on
the cell range of the database range.
• Unlike a named range, a database range can be connected to an external data source,
from where you can fetch data into the spreadsheet document.
Database ranges can be created, modified, and deleted using the Define Database Range dialog
(Figure 467).
To create a database range:
1) If you want Calc to automatically determine the full extent of your database table, then
select a single cell within its cell area. If you want to explicitly define the extent of the
database table, then select all relevant cells.
2) Open the Define Database Range dialog by selecting Data > Define Range on the Menu
bar.
3) Type a name for the range in the Name field. Only use letters, numbers, and
underscores; spaces, hyphens, and other characters are not allowed.
4) Click on the expand symbol (usually a plus or a triangle) next to the Options label to
expand this section and view and select the following options:
– Contains column labels – Denotes whether the top row is reserved for field headings.
– Contains totals row – Denotes whether the bottom row is reserved for totals.
– Insert or delete cells – If active, this option will insert new rows and columns into the
database range when new records are added to its source. Only relevant if an
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
If you want to remove any filtering applied to your database table, simply select Data > More
Filters > Reset Filter on the Menu bar.
Filters are also described in Chapter 2, Entering, Editing, and Formatting Data.
AutoFilter
AutoFilters are the most straightforward of the three filter types. They work by providing access to
a combo box through a down-arrow button located at the top of one or more data columns
(Figure 470). To add AutoFilters to all columns of a database table, click on a cell anywhere
within the table area and then select Data > AutoFilter on the Menu bar, click the AutoFilter
icon on the Standard toolbar, or press Ctrl+Shift+L. It is possible to add AutoFilters to individual
columns by selecting those columns before choosing Data > AutoFilter, clicking the AutoFilter
icon, or pressing Ctrl+Shift+L, but this is not normally necessary for a database table. To access
the AutoFilter combo box for a column, click on the down-arrow button in the header cell of that
column.
To remove AutoFilters from all columns of a database table, click on a cell anywhere within the
table area and select Data > AutoFilter on the Menu bar, select Data > More Filters > Hide
AutoFilter on the Menu bar, click the AutoFilter icon on the Standard toolbar, or press
Ctrl+Shift+L. The down-arrow buttons at the tops of columns will disappear.
Tip
Selecting Data > AutoFilter, clicking the AutoFilter icon, and pressing Ctrl+Shift+L
toggle AutoFilters on/off.
Filtering | 453
required for filtering. The example in Figure 470 corresponds to a case where column A
contains cells that have colored backgrounds using either red, green, or yellow.
• The Standard Filter option opens the Standard Filter dialog (Figure 471) and
automatically sets the current field as the field for the first condition in the dialog.
• Check the All box to display or hide all values in the current column.
• Show only the current item and Hide only the current item shortcut buttons are
provided, located adjacent to the All box. In the context of these buttons, the term
“current” refers to the item highlighted in the set of check boxes below the buttons (for
example the “1” in Figure 470).
• If any filter has been applied to a column, use the Clear Filter option to remove all filters
defined for that column.
• The AutoFilter combo box includes check boxes for each unique value in the current
column. If a check box is not ticked, rows of the database table that contain that value in
this column are not displayed. Change the filtering status of a particular value by marking
or removing the mark from the relevant check box.
Standard filters
Standard filters are more complex than AutoFilters, and allow for up to eight filter conditions.
Powerful filters can be set up using regular expressions. Also, unlike AutoFilters, standard filters
use a dialog (Figure 471), which is accessed by selecting Data > More Filters > Standard Filter
on the Menu bar or the Standard Filter option on an AutoFilter combo box.
For more information on how to use this dialog and its options, see Chapter 2, Entering, Editing,
and Formatting Data.
Advanced filters
The criteria for an advanced filter are stored in a sheet rather than entered into a dialog. As a
result, you must first set up a cell range that contains the criteria before you use the Advanced
Filter dialog (Figure 472).
Tip
Although it is possible for the criteria area to contain only the headings for columns
with defined filter criteria, for simplicity you may choose to copy all of your database
table’s headings to the criteria area.
Filtering | 455
After creating a criteria range, set up an advanced filter as follows:
1) Select the cell range that you wish to filter. For a database table you can simply click a
cell within the table area and Calc will automatically select the whole table as it opens the
dialog at step 2).
2) Go to Data > More Filters > Advanced Filter on the Menu bar to open the Advanced
Filter dialog (Figure 472).
3) In the Read Filter Criteria From field, enter the address for the criteria range, either by
selecting a named range from the drop-down box, typing in a reference, or selecting cells
from a sheet. Remember to use the Shrink / Expand button if you need to temporarily
minimize the dialog while selecting cells.
4) Click OK to apply the filter and close the dialog.
Note
For an individual named range, it is possible to tick a Filter checkbox on the Define
Name and Manage Names dialogs (Figures 463 and 464 respectively). Only named
ranges marked for filtering in this way can be selected in the drop-down box in the
Read Filter Criteria From area of the Advanced Filter dialog. Database ranges
cannot be selected in the drop-down box.
Advanced filter options are the same as standard filter options, and are described in further detail
in Chapter 2, Entering, Editing, and Formatting Data.
Figure 473 demonstrates an example criteria range for the grading sheet example in Figure 462.
Tip
When using functions where a search criterion string can be a regular expression,
the first attempt is to convert the criterion string to numbers. For example, ".0" will
convert to 0.0 and so on. If successful, the match will not be a regular expression
match but a numeric match. However, switching to a locale where the decimal
separator is not the dot makes the regular expression conversion work. To force the
evaluation of the regular expression instead of a numeric expression, use some
expression that can not be misread as numeric, such as ".[0]" or ".\0" or "(?i).0".
Note
Calc will treat dates and logical values (such as TRUE or FALSE) as numeric when
calculating with these functions.
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.
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.
Note
The Reset button, located in the lower right of the full Options dialog, has the same
effect on all pages of the dialog. It resets the options to the values that were in place
when you opened the dialog.
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 484.
See Chapter 6, Printing, Exporting, Emailing, 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.
Figure 477: Choosing security options for opening and saving documents
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 479), 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 in the drop-down list.
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.
General
Many of the choices on the Load/Save – General page (Figure 480) are familiar to users of other
office suites. Those of most interest to Calc users are in the Default File Format and ODF
Settings section.
Default File Format and ODF Settings
ODF format version: LibreOffice by default saves documents in OpenDocument Format
(ODF) version 1.3 Extended. You will rarely need to change this for compatibility when
exchanging files with other people.
Document type: If you routinely share documents with users of Microsoft Excel, you might
want to change the Always save as option to one of the Excel formats, including XLSX.
However, you can choose an Excel format when you save any individual file.
We recommend that you always save a working copy in ODS format and only create an
Excel version if necessary for sharing. Also, note that recent versions of Microsoft Excel
can open ODS files, so this may no longer be needed.
VBA Properties
On the Load/Save – VBA Properties page (Figure 481), 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.
Microsoft Office
On the Load/Save – Microsoft Office page (Figure 482), you can choose what to do when
importing or 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.
HTML Compatibility
Choices made on the Load/Save – HTML Compatibility page (Figure 483) affect how LibreOffice
imports or exports HTML pages. 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
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 484).
General
The choices on the LibreOffice Calc – General page (Figure 485) 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 section
Choose the unit of measurement used in spreadsheets and the default tab stops distance.
Update links when opening section
Choose whether to update links when opening a document: Always, On request, or
Never. Spreadsheets that include many or large charts or graphics may load slowly if this
option is set to Always.
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.
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
displayed on a solid background with no grid around cells. The color choice overrides the
selection made in Tools > Options > LibreOffice > Application Colors > Spreadsheet >
Grid lines.
Note
To print grid lines, choose Format > Page Style > Sheet > Print > Grid.
Cursor
When the mouse pointer lies over the grid of cells on a Calc spreadsheet, the default
cursor (“System”) is normally shown, typically as an arrow pointer. However, an alternative
cursor (“Themed”) is available to allow you to switch to using the cursor shape defined in
the icon theme (typically a “fat” cross).
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 488, 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 489) 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 will 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 eight cells, one of which is
empty (an empty cell is not included in determining the average).
Formula
Use the LibreOffice Calc – Formula page (Figure 490) to specify the following formula options.
Formula syntax
Syntax is the format in which formulas are written. Choose the syntax most appropriate for
your work. If you regularly open or save to Microsoft Excel formats, you may wish to use
one of the Excel syntaxes.
To illustrate the differences between syntaxes, assume a spreadsheet contains two sheets.
The cell C4 can be referenced in three ways:
Calc A1 =$Sheet2.C4 – the default syntax for Calc.
Excel A1 =Sheet2!C4 – the default of Microsoft Excel.
Excel R1C1 =Sheet2!R[3]C[2] – the relative row and column addressing used in Excel.
Sort lists
View, define, delete, 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 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 by 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 Immediately deletes
dialog contents
Delete Immediately deletes Opens Delete Contents
contents dialog
Control+D Fills cell content down Opens the Selection List
(Command+D on macOS) within selection dialog
Alt+DownArrow Select header of range; Increases row height
(Option+DownArrow on no action in empty cell
macOS)
Print options
Use the LibreOffice Calc – Print page to choose defaults for printing spreadsheets. You can
override these for individual print jobs.
Tip
Changes to menus and toolbars can be saved in a template. First, save them in a
document; 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 496) 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) On the Customize dialog, select a menu item in 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.
For example. 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 501), do any of the following:
• On the toolbar, right-click in the toolbar and choose Customize Toolbar.
Tabbed interface
By default, Calc’s commands are grouped in cascading menus and in toolbars filled with icons. In
addition, LibreOffice provides other user interface variants, displaying contextual groups of
commands and contents. You can find more information about these variants and how to switch
between them in Chapter 15, User Interface Variants.
Three of LibreOffice’s user interface variants utilize a notebook bar and these are the Tabbed,
Tabbed Compact, and Groupedbar Compact options. In these variants, the area at the top of the
workspace is divided into tabs, where each tab displays a set of icons grouped by context. The
context can change depending on the object selected in the document, for example a table or an
image.
Use the checkboxes on the Notebookbar tab of the Customize dialog (Figure 503) to show and
hide the individual options on the various tabs that are provided in the most recently selected of
the three tabbed user interfaces (with Tabbed being the initial default).
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 504).
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.
Tip
Extensions can be installed from some other places in Calc, such as the Gallery on
the Sidebar, the Templates dialog, the Language Settings > Writing Aids page of the
Tools > Options dialog and the Icon Style section in the View page of the Tools >
Options dialog. In each of these places you will find a small button leading to a
filtered view of the items in the Extensions dialog.
Note
In some cases, the Remove and Disable buttons may be unavailable, for example
when you have selected one of the extensions that was bundled with your
LibreOffice installation.
Chapter 15
User Interface Variants
Introduction
By default, LibreOffice’s commands are grouped in cascading menus and in toolbars filled with
icons and this is the classic user interface described in Chapter 1, Introduction and assumed in
the task descriptions contained in many other chapters throughout this guide.
The classic interface is very flexible, allowing the user to: show, hide, or reposition many of the
user interface components; redefine the commands assigned to toolbars, menus, and context
menus; create new menus and toolbars; redefine the functions assigned to individual shortcuts;
and so on.
A further level of flexibility is provided through six alternative user interface variants which can be
selected to match an individual user’s work flows and preferences. The seven available variants
are:
Standard Toolbar
Standard user interface with menus, toolbars, and collapsed Sidebar. Intended for users
who are familiar with the classic LibreOffice interface.
Tabbed
The Tabbed user interface is the most similar to the ribbons used in Microsoft Office. It
organizes functions in tabs and makes the Menu bar obsolete.
Single Toolbar
Similar to the Standard Toolbar user interface but with a single-line toolbar, intended for use
on smaller screens.
Sidebar
Similar to the Standard Toolbar user interface but with an expanded Sidebar. Expert users
who want to quickly change many different properties are advised to use this variant.
Tabbed Compact
The Tabbed Compact user interface is intended for those with are familiar with the
Microsoft Office user interface, and occupies less space for smaller screens.
Groupedbar Compact
The Groupedbar Compact user interface provides access to functions in groups, with icons
for the most-frequently used features, and drop-down menus for others. This variant favors
vertical space.
Contextual Single
The Contextual Single interface shows functions in a single-line toolbar with context-
dependent content.
Four of these options (Standard Toolbar, Single Toolbar, Sidebar, and Contextual Single) can be
considered as alternative configurations of the components used in the classic interface.
However the other three options (Tabbed, Tabbed Compact, and Groupedbar Compact) are
based on using the notebook bar. The notebook bar uses a different way to organize controls and
icons, displaying contextual groups of commands and contents for quicker use and improved
user experience.
It should be noted that the brief description of each variant above refers to the default setup for
that variant. There are many ways to adjust the configuration of any variant, and even create a
user interface that utilizes different aspects of multiple variants.
If you have activated experimental features (Tools > Options > LibreOffice > Advanced >
Enable experimental features (may be unstable)), several more choices appear on the left-
hand side. These choices are not described here.
Standard interfaces
The Standard Toolbar, Single Toolbar, and Sidebar interfaces are closely related. The following
notes describe the initial default configuration for these options.
Standard Toolbar
This is the classic user interface, selected by default when LibreOffice is installed. It
provides two visible toolbars (Standard and Formatting) and the Sidebar is open, showing
its five tabs on the tab panel.
Single Toolbar
Provides one visible toolbar (Standard (Single Mode)) containing frequently used features.
The Sidebar shows only its Show/Hide button.
Sidebar
Provides one visible toolbar (Standard). The Sidebar is fully opened.
The visibility of elements on each of these three variants can be modified using the View menu
on the Menu bar. The configuration of menus, toolbars, and keyboard shortcuts can be modified
through the tabs on the Tools > Customize dialog. Because these variants are not based on the
notebook bar, there are no configuration options available in the Notebookbar tab of the Tools >
Customize dialog.
Contextual Single
The initial configuration for the Contextual Single interface variant is for the Menu bar to be
visible but for no toolbars to be displayed. Toolbars are automatically shown and hidden,
dependent on the user’s current context. For example, if an image is selected then the Image
Tabbed interface
Introduction
The Tabbed interface (Figure 510) provides a familiar interface for users coming from proprietary
office suites such as Microsoft Office. It includes a Menu bar, an Icon bar, a Tab bar, icons for the
active tab, one or more tab-specific menus, and a Quick menu. On Windows and Linux, the
Menu bar can be hidden or displayed by clicking on the Menu Bar icon in the Icon bar (Figure
511).
1 Icon bar 2 Active tab 3 Tab bar 4 Icons on active tab 5 Tab menus 6 Quick menu
Figure 510: Tabbed interface with Menu bar hidden
In Calc, this user interface variant includes nine fixed tabs that are always visible, and six
additional tabs that are sometimes displayed. Each tab displays a set of icons grouped by
context. The context can change depending on the location of the cursor or the item selected.
Each tab also includes one or more tab-specific drop-down menus at the right-hand end. The
Quick menu is the same for all tabs.
The Tabbed interface can be customized using the Notebookbar tab of the Tools > Customize
dialog to show and hide the individual icons on the various tabs. See Chapter 14, Setting up and
Customizing, for more information. In addition, the size of icons used can be adjusted through
Tools > Options > LibreOffice > View > Icon Size > Notebookbar.
If the icons on a tab do not fit into the width of the Calc window, two right-pointing angle brackets
(>>) appear at the right end of the row. Press the >> button to view additional options that are not
currently visible (see, for example, Figure 514).
Icon bar
The Icon bar (Figure 511) is located at the top left of the tabs.
Quick menu
To the right of the tabs is a Quick menu (Figure 512) containing some commonly used
commands and links. Some of the Quick menu items have submenus, indicated by arrows on the
right.
Fixed tabs
The fixed tabs in Calc are File, Home, Insert, Layout, Data, Review, View, Extension, and Tools.
The nine fixed tabs are shown individually in the following subsections.
Each fixed tab has an associated menu, accessed through a button located at the right end of the
tab. This button is labeled with the same name as the tab. Some options available in the tab
menu may replicate options that are available on the tab; others may be extra options.
The appearance of a tab depends on both the configuration of your computer system and the
setup of your Calc installation. The following points should be noted about the illustrations that
follow:
• To increase readability of this chapter, the screen shots of tabs have been taken using a
relatively small Calc window. This means that the >> icon appears on most of the tabs,
indicating that some options are not visible.
• Left and right ends of the tabs are shown separately, making the illustrations large
enough to see the commands more easily.
File tab
Figure 513 shows the File tab and Figure 514 shows the additional options that are presented
when the >> icon is pressed.
Insert tab
Figure 519 shows the Insert tab and Figure 520 shows the additional options that are presented
when the >> icon is pressed.
Layout tab
Figure 522 shows the Layout tab and Figure 523 shows the additional options that are presented
when the >> icon is pressed.
Data tab
Figure 525 shows the Data tab and Figure 526 shows the additional options that are presented
when the >> icon is pressed.
Review tab
Figure 528 shows the Review tab and Figure 529 shows the additional options that are presented
when the >> icon is pressed.
View tab
Figure 531 shows the View tab and Figure 532 shows the additional options that are presented
when the >> icon is pressed.
Extension tab
The Extension tab contains only the Extension tab menu, which contains the Extension
Manager (Ctrl+Alt+E) option (Figure 534).
Tools tab
Figure 535 shows the Tools tab and Figure 536 shows the additional options that are presented
when the >> icon is pressed.
Additional tabs
Additional tabs appear when an item is selected; they are displayed between the View and
Extension tabs. The additional tabs in Calc are Draw, Form, Image, Media, Object, and Print.
Draw tab
Figure 538 shows the Draw tab and Figure 539 shows the additional options that are presented
when the >> icon is pressed. The Draw tab is displayed when a drawing object is selected.
Form tab
Figure 541 shows the Form tab, which is displayed when a form component is selected in design
mode.
Figure 544:
Image tab -
additional
options
The Image tab has one menu, Image, and this is shown in Figure 545. Save, Area, Line, and
Position and Size icons are located adjacent to the Image menu button.
Media tab
Figure 546 shows the Media tab, which is displayed a media object is selected.
Object tab
Figure 548 shows the Object tab, which is displayed when an object (for example, an OLE
object) is selected.
The Object tab has one menu, Object, and this is shown in Figure 549. Area, Line, and Position
and Size icons are located adjacent to the Object menu button.
Print tab
Figure 550 shows the Print tab, which is displayed when a print preview is selected.
Appendix A
Keyboard Shortcuts
Introduction
You can use Calc without a pointing device, such as a mouse or touchpad, by using keyboard
shortcuts. This appendix provides a comprehensive reference list of the available built-in
shortcuts, which you can browse to find ones that may be useful in your daily work.
When you first install LibreOffice, a default set of Calc keyboard shortcuts is available. These are
described in this chapter, assuming no customization. When using Calc, you can discover
shortcuts for common interactions by observing the key sequences identified on the menu
options and in the tooltips of toolbar icons. You can also explore a more comprehensive list of
shortcuts by viewing the Keyboard tab of the Customize dialog (Tools > Customize).
Further information about many individual key combinations can be found throughout the
chapters of this guide and in the Help system.
You can define your own shortcuts or change existing shortcuts by going to Tools > Customize
> Keyboard on the Menu bar. See Chapter 14, Setting up and Customizing, for further
instructions. Some shortcuts cannot be re-assigned; these are identified in the “Keyboard
shortcuts that cannot be modified” sections on pages 526 (Windows / Linux) and 534 (macOS).
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 operating systems may allocate particular keys to operating system
functions and, in such cases, those keys 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 used 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 in two main sections, one listing the keyboard shortcuts available
in the Windows and Linux environments, and the other listing the macOS keyboard shortcuts.
Table 20: Number key shortcuts for menu and toolbar options
Windows / Linux Equivalent Menu bar / toolbar option
Ctrl+1 Format > Cells.
Format > Number Format > Number (use the “1” key on the main
Ctrl+Shift+1 keyboard).
Format as Number icon on the Formatting toolbar.
Table 21: Letter key shortcuts for menu and toolbar options
Windows / Linux Equivalent Menu bar / toolbar option
Format > Text > Bold.
Ctrl+B
Bold icon on the Formatting toolbar.
Ctrl+Shift+B Format > Text > Subscript.
Edit > Copy.
Ctrl+C
Copy icon on the Standard toolbar.
Insert > Comment.
Ctrl+Alt+C Sheet > Cell Comments > Edit Comment.
Insert Comment icon on the Standard toolbar.
Sheet > Fill Cells > Fill Down.
Ctrl+D Via drop-down menus on Row or Column icons on the Standard
toolbar.
Format > Align > Centered.
Ctrl+E
Align Center icon on the Formatting toolbar.
Ctrl+Alt+E Tools > Extension Manager.
Ctrl+F Edit > Find.
Edit > Find and Replace.
Ctrl+H
Find and Replace icon on the Standard toolbar.
Format > Text > Italic.
Ctrl+I
Italic icon on the Formatting toolbar.
Ctrl+J Format > Align > Justified.
Ctrl+Shift+J View > Full Screen.
Insert > Hyperlink.
Ctrl+K
Insert Hyperlink icon on the Standard toolbar.
Format > Align > Left.
Ctrl+L
Align Left icon on the Formatting toolbar.
Data > AutoFilter.
Ctrl+Shift+L
AutoFilter icon on the Standard toolbar.
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 34: 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
Ctrl+Shift+1 keyboard).
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
Ctrl+Shift+3 keyboard).
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
Ctrl+Shift+5 keyboard).
Format as Percent icon on Formatting toolbar.
Format > Number Format > General (use the “6” key on the main
Ctrl+Shift+6
keyboard).
Table 35: Letter key shortcuts for menu and toolbar options
macOS Equivalent Menu bar / toolbar option
Format > Text > Bold.
Cmd+B
Bold icon on the Formatting toolbar.
Shift+Cmd+B Format > Text > Subscript.
Edit > Copy.
Cmd+C
Copy icon on the Standard toolbar.
Insert > Comment.
Option+Cmd+C Sheets > Cell Comments > Edit Comment.
Insert Comment icon on the Standard toolbar.
Cmd+D Sheet > Fill Cells > Fill Down.
Format > Align > Centered.
Cmd+E
Align Center icon on the Formatting toolbar.
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 559), or on the Status bar (Figure 560), 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 559 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.
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.
540 | Index
data labels 134 spreadsheet 25
data range and data series 103, 119 cross cursor 24, 477
default colors 484 CSV file
deleting 159 importing 382
edit mode 109 opening 25
error bars 149 cursor selection 24, 477
exporting images 160 custom colors, adding 495
grid lines 139
leader lines 137 D
legend 116 dark color scheme, preset 470
mean value lines 148 dashes, inserting 56
moving 153 data
moving elements 114 editing and deleting 65
overall appearance 158 entering 51
pivot 314 finding and replacing 95
resizing 153 formatting 70
selecting elements 113 grouping and outlining 88
selecting multiple 157 hiding and showing 85
Sidebar, using to specify options 108 Data Labels dialog 134
title and subtitle 115 Data Series dialog 120
trend lines 144 data sources
chi-square test of independence 362 editing 392
clipboard, inserting image from 211 launching Base 392
color coding for input 278 linking to when registered 388
color schemes, preset 470 registering 388
colors, adding custom 495 using in Calc spreadsheets 393
column and line charts 176 viewing 391
column charts 161 database primer 445
columns database ranges
deleting 35 creating and managing 449
freezing 39 linking to external data source 451
inserting 35 overview 449
maximum number of 17 refreshing data 451
repeat printing 233 selecting 451
selecting 33 databases
comments filtering 453
editing 411 sorting 452
finding 411 date and time, formatting 53
formatting 411 DDE (Dynamic Data Exchange) objects 394
inserting 410 Define Database Range dialog 449
comparative operators 255 deleting
comparing spreadsheets 413 cells 36
compatibility of functions with other applications 267 charts 160
conditional formatting columns and rows 35
example 84 data 65
managing 83 page breaks 234
setting up 79 pivot charts 317
types of 82 pivot tables 311
Consolidate dialog 319 sheets 38
Contextual Single user interface 499 Descriptive Statistics dialog 346
copying charts 159 Detective 65, 278
copying sheets 37 dialogs
Correlation dialog 349 choosing LibreOffice or operating system 11
Covariance dialog 350 Create Names 448
Create Names dialog 448 Define Database Range 449
Create Scenario dialog 328 Manage Names 447
creating Paste Names 447
formulas 253 QR Code Generator 223
pivot charts 315 recognizing common controls 12
pivot tables 287 Search Commands 10, 19
Index | 541
Select Database Range 451 fill tool 57
Solver Status 341 filtering
Sort 452 advanced filters 455
digital signing of documents AutoFilters 453
applying signature 247 by color 453
overview 247 data 89
signing macros 249 standard filters 454
signing multiple times with same signature 249 using regular expressions 45, 90
direct formatting, removing 181 Find and Replace dialog 95
direction of text 74 Find toolbar 95
document properties 43 finding and replacing data 95
Drawing Object Properties toolbar 158, 219 font effects 73
drawing objects Fontwork objects 221
adding text to 214 footers and headers 236
additional tools in context menu 221 Format menu, options when editing a chart 111
grouping and ungrouping 221 formatting
including in charts 152 cell background and borders 75
resizing 220 conditional 79
setting the properties of 219 data 70
Drawing toolbar 152, 218 fonts 72
Dynamic Data Exchange (DDE) objects 394 numbers 72
Formatting toolbar 19
E Formatting toolbar, options when editing a chart 112
edit mode, for a chart 109 Formula bar 20
editing data 65 formulas
emailing spreadsheets 247 array 272
embedding images 209 color coding for input 278
embedding spreadsheets 394 creating 253
Enter key, using to navigate and customizing 32 operators in 253
entering data 51 order of calculation 263
Error Bars dialog 150 strategies for creating 273
error codes and messages 276, 536 value highlighting 278
errors, finding and fixing 275 Fourier Analysis dialog 363
Exponential Smoothing dialog 351 freezing columns and rows 39
exporting charts 159 Function Wizard dialog 270
exporting to formats other than PDF 246 functions
exporting to PDF, using the Export Directly as PDF basic arithmetic 279
icon 239 compatibility with other applications 267
exporting to PDF, using the PDF Options dialog 239 creating with macros 421
extensions database-like 461
Alternative Python Script Organizer (APSO) 438 database-specific 456
disabling 494 examples 279
Galaxy icon set 12 nested 268
installing 494 overview 267
legacy Gallery backgrounds 12 rounding numbers 281
overview 494 simple statistics 280
Oxygen icon set 12 structure 268
removing 494 using regular expressions 45, 282
Tango icon set 12 using wildcards 282
updating 494 wiki pages 267
External Data dialog 382 Functions deck 23, 269
external data, linking to 382
G
F Galaxy icon set 12
F-test dialog 359 Gallery deck 12, 23, 212
FAQs (frequently asked questions) 13 GETPIVOTDATA function 311
feedback, sending about LibreOffice 10 Goal Seek dialog 338
fields, inserting 70 graphs - see charts 101
fill format mode, using to apply cell styles 184 Groupedbar Compact user interface 514
fill series 58 grouping and ungrouping
542 | Index
data 88 Java JRE (Java Runtime Environment) 14
drawing objects 221 JavaScript macro programming 436
images 218
K
H keyboard shortcuts
headers and footers 236 customizing 492
Help menu 9 loading saved configuration 493
help, getting 9 macOS 527
hiding data 85 resetting to defaults 493
highlighting values 79 saving to a file 493
HTML import, finding the required data 387 that cannot be modified (macOS) 534
HTML loading and saving options 472 that cannot be modified (Windows / Linux) 526
Hyperlink dialog 377 using to run macros 493
hyperlinks Windows / Linux 518
absolute and relative 375 keyboard, using to navigate spreadsheet 30
buttons and text 376
changing color 377 L
creating 376 leader lines 137
editing 381 leading zeroes, entering 51
Hyperlink dialog 377 LibreOffice
modifying 381 licensing of 13
opening 377 restarting with default settings 10
removing 381 sending feedback on 10
LibreOffice Basic macro programming 417
I LibreOffice options, setting
icon sets 12 advanced 470
illustrations, appearance of 11 application colors 469
Image toolbar 213 paths 467
images print 467
adding text to 214 security 467
additional tools in context menu 221 user data 467
aligning 217 view 467
anchoring 217 line breaks 70
arranging (stacking) 216 line charts 166
embedding and linking 210 linear programming, solving problems 339
grouping and ungrouping 218 linking images 209
inserting from clipboard 211 linking to external data 381
inserting from file 209 Linux keyboard shortcuts 518
inserting from Gallery deck 212 load Basic code to edit 441
inserting from scanner 212 loading / unloading macro libraries 426
modifying 213 loading and saving options
moving 215 general 470
resizing 215 HTML compatibility 472
importing XML source data 400 Microsoft Office 472
independence test (chi-square) 362 VBA properties 471
Input line locking toolbars 19
extending 53
overview 20 M
Insert menu, options when editing a chart 110 macOS
inserting keyboard shortcuts 527
columns and rows 35 using LibreOffice on 12
images 209 macro examples
page breaks 234 accessing cells directly 430, 431
sheets 36, 368 Beanshell 435
sheets from another spreadsheet 370 JavaScript 437
special characters 54 Python 439, 441
Integrated Development Environment (IDE) for Basic recorded macro 421
macro programming 423 sorting 432
writing your own functions 425, 427, 428, 429
J macros
Index | 543
accessing cells with 430 using to link external data 385
assigning to events 493 working with scenarios 331
creating your own functions 421 Navigator deck 23
deleting 429 Navigator dialog 29
loading and unloading libraries 426 negative numbers, entering 51
passing arguments 428 net charts 172
recording 417 non-linear programming, solving problems 339
security warnings 425 notebookbar
sorting with 432 customizing 491
using the ScriptForge library 439 user interfaces 498
writing in Beanshell 434 numbers, formatting 72
writing in JavaScript 436
writing in LibreOffice Basic 417 O
writing in Python 438 object inspector 439
main window, recognizing components of 17 ODF (Open Document Format) 27
Manage Names dialog 447 OLE (Object Linking and Embedding) objects 394
manual formatting, removing 181 opening
mathematical optimization, solving problems 339 CSV file 25
maximum numbers of sheets, rows, and columns spreadsheet 25
17 operators
Menu bar 18 arithmetic 255
menus comparative 255
customizing 485 in formulas 253
Format, options when editing a chart 111 reference 256
Help 9 text 256
Insert, options when editing a chart 110 order of calculation 263
Styles 182 outlining 88
merging Oxygen icon set 12
cells 60
spreadsheets 413 P
Microsoft Office loading and saving options 472 page breaks, inserting and deleting 234
modifying images 213 Page Style dialog 194, 235
moving page styles
chart elements 114 applying 185
charts 153 overview 182
images 215 Page Style dialog 194
sheets 37 printing options 235
Moving Average dialog 353 Paired t-test dialog 357
multi-threading 275 parallel processing 275
multiple lines of text 70 password protection 29
multiple operations Paste Names dialog 447
one formula and one variable 332 Paste Special dialog 68
overview 332 PDF Options dialog 239
several formulas simultaneously 334 PDF, exporting to
two variables 336 using the Export Directly as PDF icon 239
Multiple Operations dialog 332 using the PDF Options dialog 239
personal data, removing 249
N pie charts 163
Name Box 20 pivot charts 177
named expressions 262 creating 315
named ranges deleting 317
creating and managing 446 differences from other charts 315
creating using column or row headers 448 editing 316
with functions 261 filtering 316
navigating overview 314
between cells 29 refreshing / updating changed data 316
between sheets 30 Pivot Table Layout dialog
using the Enter key 32 additional options 290
using the keyboard 30 column and row field options 295
Navigator data field options 292
544 | Index
defining the layout of the pivot table 288 concatenation 257
filter field options 299 intersection 257
pivot tables overview 256
cell formatting of results 310 range 256
changing layout 299 references, absolute and relative 258
creating 287 referencing
data sources 287 other documents 374
database preconditions 286 other sheets 372
deleting 311 registering data sources 388
drilling 307 Regression dialog 354
filtering 308 regular expressions 45, 90, 97, 282
GETPIVOTDATA function 311 rejecting changes 411
grouping columns or rows 300 relative hyperlinks 375
grouping date / time values 302 relative referencing 258
grouping scalar values 301 removing personal data 249
grouping without intervals 303 renaming sheets 39, 370
refreshing / updating changed values 310 replacing data 67
showing details (drilling) 307 resizing
sorting results 305 charts 153
styles 310 drawing objects 220
Position and Size dialog 154, 215 images 215
positioning images 215 restarting LibreOffice with default settings 10
preview before printing 228 reviewing spreadsheets
Print dialog 225 accepting or rejecting changes 411
print ranges adding comments to changes 410
defining 229 comparing spreadsheets 413
editing 229 editing comments on changes 411
named 231 merging spreadsheets 413
removing 233 preparing a document for review 407
viewing 230 recording changes 408
printing using (general) comments 410
default settings for LibreOffice 225 Rhino JavaScript debugger 436
grayscale on a color printer 228 rows
multiple pages per sheet of paper 226 deleting 35
options for page styles 235 freezing 39
repeat printing of rows or columns 233 inserting 35
selecting what to print 227 maximum number of 17
using print preview 228 repeat printing 233
using print ranges 229 selecting 33
using the Print dialog 225
using the Print Directly icon 225 S
Properties deck Sampling dialog 344
overview 22 save original Basic code 441
using to change chart properties 108 saving spreadsheet 27
using with drawing objects 219 scanner, using to insert image 212
using with images 214 scatter charts 168
Properties dialog 43 scenarios
protecting spreadsheet structure 374 creating 328
Python macro programming 438 modifying properties and cell values 330
overview 328
Q using the Navigator 331
QR Code Generator dialog 223 screen, splitting 40
ScriptForge library 439
R Search Commands dialog 10, 19
ranges Search Results dialog 98
associating a name 446 searching
database 449 using regular expressions 45, 97
named 446 security warnings for macros 425
recording macros 417 Select Database Range dialog 451
reference operators Select Function icon 20
Index | 545
selecting comparing 413
cells, columns, rows, and sheets 32 creating, opening, and saving 25
chart elements 113 emailing 247
multiple charts 157 embedding 394
selection lists 60 general layout 17, 24
selection modes 21 merging 413
shared spreadsheets protecting structure 374
list of disabled features 406 removing personal data 249
opening 406 reviewing 407
overview 405 saving versions 413
saving 406 sharing with other users 405
setting up 405 signing digitally 247
sharing content between sheets 61 stacking images 216
sheet tabs 24 Standard (Single Mode) toolbar 20
sheets standard filters 89, 454
default settings for new sheets 367 Standard toolbar 19
inserting as a link 370 Standard Toolbar user interface 499
inserting from a different spreadsheet 370 statistics tools
inserting new 368 analysis of variance (ANOVA) 348
inserting, moving, copying, renaming, and correlation 349
deleting 36 covariance 350
linking in calculations 263 descriptive statistics 346
maximum number of 17 exponential smoothing 351
navigating between 30 F-test 359
referencing other sheets 372 Fourier analysis 363
renaming 370 moving average 353
selecting 34 paired t-test 357
sharing content between 61 regression 354
showing hidden data 87 sampling 344
shrinking text to fit 72 test of independence (chi-square) 362
Sidebar z-test 360
Functions deck 23, 269 Status bar
Gallery deck 12, 23, 212 error codes and messages 536
Navigator deck 23, 41 overview 21
overview 22 stock charts 173
Properties deck, overview 22 styles
Properties deck, using to change chart properties cell 181
108 copying for cell 84
Properties deck, using with drawing objects 214 creating custom styles 185
Properties deck, using with images 219 deleting 197
Styles deck 22, 182 filtering the list of 197
Sidebar user interface 499 hiding and showing cell styles 197
signing documents digitally modifying 196
applying signature 247 page 182
overview 247 pivot table cells 310
signing macros 249 renaming 197
signing multiple times with same signature 249 Styles deck 22, 182
Single Toolbar user interface 499 Styles menu 182
smoothing, exponential 351 subtotals
Solver dialog 340 using the SUBTOTAL function 322
Solver Status dialog 341 using the Subtotals dialog 324
Sort dialog 93, 452 system cursor 24, 477
sorting
data 92 T
using macros 432 t-test, paired 357
special characters, inserting 54 Tabbed Compact user interface 513
splitting cells 61 Tabbed user interface 500
splitting the screen (or "window") 40 Tango icon set 12
spreadsheets templates
advice to avoid common pitfalls 252 adding from other sources 202
546 | Index
categories 205 U
creating 200 unfreezing columns and rows 40
default, setting and resetting 204 UNO object inspector 439
deleting 206 updating LibreOffice software 11
editing 201 URLs and hyperlinks 375
exporting 207 user interface
moving between categories 206 Contextual Single 499
organizing 205 customizing 485
overview 198 Groupedbar Compact 514
Start Center, using to create a spreadsheet 199 selecting 498
Templates dialog, using to create a spreadsheet Sidebar 499
198 Single Toolbar 499
using to update styles 202 Standard Toolbar 499
Test of Independence (Chi-Square) dialog 362 Tabbed 500
text Tabbed Compact 513
adding to drawing objects 214
adding to images 214 V
automatic wrapping 70 validating cell contents 62
changing direction 74 Validity dialog 62
hyperlinks 376 value highlighting 79, 278
inserting manual line break 71 VBA (Visual Basic for Applications) loading and
operators 256 saving options 471
shrinking to fit 72 versions, saving 413
Text Import dialog 25, 383
themed cursor 24, 477 W
themes 78 wiki, Calc functions 267
Tip-of-the-Day 10 wildcards 97, 282
Title bar 18 Windows keyboard shortcuts 518
toolbars wrapping text 70
customizing 488
Drawing 218 X
Drawing Object Properties, options when editing XML Source dialog 401
a chart 158 XML, importing source data from 400
Drawing Object Properties, overview 219 XY charts 168
Drawing, options when editing a chart 152
Find 95 Z
Formatting, options when editing a chart 112 z-test dialog 360
Formatting, overview 19 zooming the Calc window 22
Image 213
locking 19 #
overview 19 # error codes and messages 536
Standard 19 ### displayed in cell 537
Standard (Single Mode) 20 #DIV/0! error 276, 537
tooltips 10, 20 #NAME? error 537
tracking changes 408 #NUM! error 537
Trend Line dialog 144 #REF! error 277, 537
#VALUE! error 277, 537
Index | 547
Calc Guide
Wo r k i n g W i t h S p r e a d s h e e t s
About this book:
This book is for beginners to advanced users of Calc, the spreadsheet component of
LibreOffice. It covers the main features of Calc, including:
Entering, editing, and formatting data
Functions and formulas to perform complex calculations on data
Statistic analysis, pivot tables and goal seek for decision making
Database functions to arrange, store, and filter data
A wide range of 2D and 3D charts
Macros
And much more
About the authors:
This book was written by volunteers from the LibreOffice community. Profits from
sales of the printed edition will be used to benefit the community.
A PDF version of this book can be downloaded free from:
https://documentation.libreoffice.org
About LibreOffice:
LibreOffice is the free, libre, and open source personal productivity suite from The
Document Foundation. It runs on Windows, macOS, and GNU/Linux. Support and
documentation is free from our large, dedicated community of users, contributors
and developers.
You too can get involved with volunteer work in many areas: development, quality
assurance, documentation, translation, user support, and more.
You can download LibreOffice Community from:
https://libreoffice.org/download/
For commercial/enterprise use: The LibreOffice Enterprise class of applications may
look and behave differently from the Community edition described in this book. For
guides to Enterprise editions of LibreOffice, please refer to the professional partners
that produced them.
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: