CG248-CalcGuide
CG248-CalcGuide
This document is Copyright © 2025 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.
Book 1
Contributors
To this edition
Dione Maddern Lisa Samy Ed Olson
B. Antonio Fernández Claire Wood Olivier Hallot
To previous editions
Skip Masonsmith flywire Kees Kriek
Steve Fanning Jenna Sargent Olivier Hallot
Pulkit Krishna Jean Hollis Weber Dan Lewis
Peter Schofield Jochen Schiffers Robert Großkopf
Jost Lange Martin Fox Hazel Russman
Steve Schwettman Alain Romedenne Andrew Pitonyak
Jean-Pierre Ledure Drew Jensen Randolph Gamo
Feedback
Please direct any comments or suggestions about this document to the Documentation Team’s
forum at https://community.documentfoundation.org/c/documentation/loguides/ (registration is
required) or send an email to: [email protected].
Note
Everything you send to a forum, including your email address and any other
personal information that is written in the message, is publicly archived and
cannot be deleted. Emails sent to the forum are moderated.
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.
Preface | 9
• 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: Breeze, Colibre, Elementary,
Karasa Jaga, Sifr, and Sukapura; some of these are also available in dark, SVG (Scalable
Vector Graphics), and SVG+dark versions. 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 Theme.
Note
The Galaxy, Oxygen, and Tango icon sets are no longer included as part of the
standard installation package. They can be added back by downloading and
installing the following extensions:
https://extensions.libreoffice.org/extensions/galaxy-icon-theme
https://extensions.libreoffice.org/extensions/oxygen-icon-theme
https://extensions.libreoffice.org/en/extensions/show/tango-icon-theme-for-libreoffice
Some of the previously included gallery backgrounds are now only available as an
extension from:
https://extensions.libreoffice.org/extensions/legacy-gallery-backgrounds
Preface | 11
What are all these things called?
The terms used in LibreOffice for most parts of the user interface (the parts of the program you
see and use, in contrast to the behind-the-scenes code that actually makes it work) are the
same as for most other programs.
A dialog is a special type of window. Its purpose is to inform you of something, or request input
from you, or both. It provides controls to use to specify how to carry out an action. The technical
names for common controls are shown in Figure 2. In most cases the technical terms are not
used in this book, but it is useful to know them because the Help and other sources of
information often use them.
In most cases, you can interact only with the dialog (not the document itself) as long as the
dialog remains open. When you close the dialog after use (usually, clicking OK or another button
saves your changes and closes the dialog), then you can again work with your document.
Some dialogs can be left open as you work, so you can switch back and forth between the
dialog and your document. An example of this type is the Find and Replace dialog.
Note
If you want to use LibreOffice features that require Java it is important that the
correct 32 bit or 64 bit edition matches the installed version of LibreOffice.
How can I contribute to LibreOffice?
You can help with the development and user support of LibreOffice in many ways, and
you do not need to be a programmer. To start, check out this webpage:
https://whatcanidoforlibreoffice.org.
May I distribute the PDF of this book, or print and sell copies?
Yes, as long as you meet the requirements of one of the licenses in the copyright
statement at the beginning of this book. You do not have to request special permission.
We request that you share with the project some of the profits you make from sales of
books, in consideration of all the work we have put into producing them.
Donate to LibreOffice: https://www.libreoffice.org/donate/.
Preface | 13
What's new in this guide
Information about the LibreOffice 24.8 Community release can be found in this announcement:
https://wiki.documentfoundation.org/ReleaseNotes/24.8
This book has been updated from Calc Guide 24.2. It covers changes that are visible in the Calc
user interface.
Changes in chapters
• Chapter 3: has been moved to Chapter 6 “Creating Charts and Graphs“ and the section
on chart type became Chapter 7 “Gallery of Charts Types”.
– Added new chart types: “Bar of Pie” and “Pie of Pie”.
• Chapter 4: is now “Styles and Templates”.
• Chapter 5: is now “Using Graphics”.
• Chapters 8 to 19 were renumbered accordingly.
– Several parts rewritten for clarity.
• Chapter 15 “Calc as a Database”: added a section on “Referencing in a Calc Database
Table”.
• Chapter 19 “Macros”:
– Removed section on JavaScript debugger, not available anymore.
– Changes in macro listings formatting.
• Appendix B: Added section on Calc error handling functions.
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 "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 17, 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 16, 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.
Chapter 1 Introduction | 17
• 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
be used to drag the toolbar to a new screen position. To lock / unlock all toolbars at once, select
View > Toolbars > Lock Toolbars (LibreOffice must be restarted to apply this change).
You can choose the single-toolbar alternative to the default double toolbar arrangement. It
contains the most-used commands. To activate it, enable View > User Interface > Single
Toolbar. Other variations are also available through View > User Interface.
For additional information on toolbars, see the Getting Started Guide.
The default set of icons (sometimes called buttons) on toolbars provides a wide range of
common commands and functions. You can also remove or add icons to toolbars. See
Chapter 16, Setting up and Customizing, for more information.
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.
Tip
The Alt+= keyboard shortcut is equivalent to clicking the Select Function icon and
selecting the Sum option.
• Formula – inserts an equals (=) sign in the selected cell and the Input line, allowing a
formula to be entered.
• Input line – displays the contents of the selected cell (data, formula, or function) and
allows you to edit the cell contents. To turn the Input line into a multi-line input area for
very long formulas, click the Expand Formula Bar icon on the right or Click and drag
between the Formula Bar and top of the Column Headers (when mouse pointer turns into
a double arrow) to extend downwards. To edit inside the Input line area, click in the area,
then type your changes. The height of the formula bar will be saved in your document.
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 9, Using Formulas and Functions, for more information.
Chapter 1 Introduction | 19
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 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. A font is temporarily applied on selected cells
when hovering or navigating in the Font Name drop-down list.
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.
Chapter 1 Introduction | 21
Figure 7: Sidebar
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.
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 43.
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.
Spreadsheet layout
Individual cells
The main section of the screen displays the cells in the form of a grid, with each cell located at
the intersection of a column and a row.
At the top of the columns and the left end of the rows are a series of header boxes containing
letters and numbers. The column headers use alphabetic characters that start with A and
increase to the right. The row headers use numerical characters that start at 1 and increase
down.
These column and row headers form the cell references that appear in the Name Box on the
Formula Bar (Figure 5). If the headers are not visible on the spreadsheet, go to View > View
Headers on the Menu bar.
When the mouse pointer lies over the grid of cells, the system default pointer is normally shown
(typically an arrow pointer). However, a configuration option is available to switch to using the
pointer shape defined in the icon theme (typically a fat cross). See Chapter 16, Setting up and
Customizing for more information.
The active cell is always indicated by highlighting its corresponding column and row header
cells. An option is available to highlight the entire row and column of the active cell using a
transparent color (Figure 8). This is enabled/disabled using the Tools > Options > LibreOffice
Calc > View > Column/Row highlighting and View Column/Row Highlighting options.
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.
Chapter 1 Introduction | 23
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 9).
Using templates
Calc documents can also be created from templates. For information on how to create and use
templates, see Chapter 4, Using Styles and Templates, in this guide.
Chapter 1 Introduction | 25
• Separated by – separates data into columns based on the separator defined here. Select
Other to specify another character used to separate data into columns. This custom
separator must also be contained in the data.
• Merge delimiters – combines consecutive delimiters and removes blank data fields.
• Trim spaces – removes starting and trailing spaces from within fields.
• String delimiter – select a character to delimit text data.
Tip
CSV files can identify the separator to use by including a first row of sep=X or
“sep=X” where X is the separator character. Set From row to 2 to import correctly.
Other options
• Format quoted field as text – when this option is enabled, fields or cells whose values
are entirely within quotes are imported as text.
• Detect special numbers – when this option is enabled, Calc will automatically detect all
number formats, including special number formats such as dates and times. Scientific
notation will also be detected as the adjacent Detect scientific notation option must be
enabled at the same time. The selected language influences how such special numbers
are detected, since different languages and regions many have different conventions for
such special numbers.
When this option is disabled, Calc will detect and convert only numbers in decimal
notation. Detection of numbers in scientific notation will depend on the adjacent Detect
scientific notation option. The rest will be imported as text. A decimal number string can
have digits 0-9, thousands separators, and a decimal separator. Thousands separators
and decimal separators may vary with the selected language and region.
• Evaluate formulas – when this option is enabled, fields that begin with an equals sign (=)
will be imported and evaluated as a formula instead of as data.
• Detect scientific notation – when this option is enabled, Calc will automatically detect
numbers with scientific notation, such as “5E2” for 500. The selected language
influences how scientific notation is detected, since different languages and regions
many have different decimal separator.
This option can be disabled only if the Detect special numbers option is disabled. When
this option is disabled, Calc will detect and convert only numbers in decimal notation and
the remainder will be imported as text. A decimal number string can have digits 0-9,
thousands separators, and a decimal separator. Thousands separators and decimal
separators may vary with the selected language and region.
Fields – shows how your data will look when it is separated into columns.
Column type – select a column in the preview window and select the data type to be
applied to the imported data.
– Standard – Calc determines the type of data.
– Text – imported data are treated as text.
– Date – imported data are treated as dates in the selected format – “DMY”, “MDY”, or
“YMD”.
– 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.
Saving spreadsheets
For information on how to save files manually or automatically, see 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 8, Printing, Exporting, Emailing, and Signing, for more
information.
Chapter 1 Introduction | 27
Figure 12: Confirm File Format dialog
If you select Text CSV format (*.csv), the Export Text File dialog (Figure 13) opens. Here you can
select the character set, field delimiter, string delimiter, and so on to be used for the CSV file.
Note
Once you have saved a spreadsheet in another format, all changes you make to the
spreadsheet will now occur only in the format you are using because you have
changed the name and file type of your document. If you want to go back to working
with an *.ods version, you must save the file as an *.ods file.
Tip
To have Calc save documents by default in a file format other than the default ODF
format, go to Tools > Options > Load/Save > General. In the section named
Default File Format and ODF Settings, next to Document type, select Spreadsheet,
then next to Always save as, select your preferred file format, for example one of the
available Microsoft Excel options.
Password protection
To protect a spreadsheet and restrict who can open, read, and make changes to it, you have to
use password protection. Password protection is common to all LibreOffice modules; for more
information, see 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 uses your system’s highlight
color.
• 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 19). 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 24), 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.
Chapter 1 Introduction | 29
Sheet navigation
Each sheet in a spreadsheet is independent of the other sheets, though references can be
linked from one sheet to another. There are four ways to navigate between different sheets in a
spreadsheet.
• Using the Navigator – when the Navigator is open (Figure 24), double-clicking on any of
the listed sheets selects the sheet.
• Using the keyboard – using key combinations Ctrl+Page Down moves one sheet to the
right and Ctrl+Page Up moves one sheet to the left. Ctrl+Tab is equivalent to
Ctrl+Page Down, while Ctrl+Shift+Tab is equivalent to Ctrl+Page Up. These
interactions operate in a cyclic manner. For example, if currently on the first sheet tab,
then Ctrl+Page Up moves to the last sheet tab.
• Using the mouse – clicking on one of the sheet tabs at the bottom of the spreadsheet
selects that sheet.
• Using the menu – go to Sheet > Navigate > To Previous Sheet / To Next Sheet to
navigate to previous or next sheet. These interaction operate in the same cyclic manner
as described above for their equivalent keyboard shortcuts. Sheet > Navigate > Go to
Sheet brings up a dialog box that allows you to select a sheet or to search for a sheet by
name.
If there are many sheets in the spreadsheet, some of the sheet tabs may be hidden. If this is the
case, use the four buttons to the left of the sheet tabs to move the tabs into view (Figure 14).
Note
The sheet tab arrows that appear on the left in Figure 14 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 shortcut Cell navigation
→ or← Moves cell focus right or left one cell.
↑or↓ Moves cell focus up or down one cell.
Ctrl+→ or Ctrl+← If focus is on a blank cell, Ctrl+→ moves focus along the current
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.
Chapter 1 Introduction | 31
Keyboard shortcut Cell navigation
Ctrl+↑ or Ctrl+↓ If focus is on a blank cell, Ctrl+↑ moves focus up the current
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 or Moves focus to the top left cell of the sheet (usually cell A1) or
Ctrl+End moves focus to the last used cell in sheet (usually in the bottom
right of the sheet).
Alt+Page Down or
Alt+Page Up Moves focus one screen to the right or left (if possible).
Ctrl+Page Down or Moves focus to the next sheet to the right or left in sheet tabs.
Ctrl+Tab or These interactions operate in a cyclic manner. For example, if
Ctrl+Page Up or currently on the first sheet tab, then Ctrl+Page Up moves to the
Ctrl+Shift+Tab last sheet tab.
Tab or Shift+Tab Moves focus to the next cell on the right or left.
Enter or Moves focus down/up one cell (unless you have changed this
Shift+Enter action, as described in the following subsection).
Chapter 1 Introduction | 33
Tip
Make sure to change back to Standard selection mode or you may find yourself
extending a cell selection unintentionally.
To select a range of cells without using the mouse:
1) Select the cell that will be one of the corners in the range of cells.
2) While holding down the Shift key, use the cursor arrows to select the rest of the range.
To select a range of cells using the Name Box:
1) Click in the Name Box on the Formula Bar (Figure 5 on page 19).
2) Enter the cell reference for the upper left-hand cell, followed by a colon (:), and then the
lower right-hand cell reference, then press the Enter key. For example, to select the
range that would go from A3 to C6, enter A3:C6.
Entire sheet
To select the entire sheet, click on the small box between the column headers and the row
headers (Figure 16), 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.
All sheets
Right-click a sheet tab and choose Select All Sheets in the context menu, or select Edit >
Select > Select All Sheets on the Menu bar.
Tip
You can also select sheets using the Select Sheets dialog, accessed by selecting
Edit > Select > Select Sheets on the Menu bar.
Chapter 1 Introduction | 35
Working with columns and rows
Inserting columns and rows
When you insert columns or rows, the cells take the formatting of the corresponding cells in the
column to the left or the row above.
Tip
For a visible indication of hidden rows and columns, enable the option from the Menu
bar, View > Hidden Row/Column Indicator (Figure 17).
Chapter 1 Introduction | 37
• Highlight the required columns or rows by holding down the left mouse button on the
header of the first one and then dragging across the required number of headers. Then
right-click on one of the selected column or row headers and select Delete Columns or
Delete Rows in the context menu.
Deleting cells
1) Select the cell or cells you want to delete.
2) Select Sheet > Delete Cells, press Ctrl+-, or right-click on one of the selected cells
and select Delete in the context menu.
3) Select the option you require from the Delete Cells dialog and click OK.
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.
Chapter 1 Introduction | 39
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. If the sheet is not empty,
then Calc displays a confirmation dialog – click Yes to confirm the deletion.
To delete multiple sheets, select the sheets (see “Selecting sheets” on page 35), 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. If any of the selected sheets is not empty, then Calc displays a
confirmation dialog stating the number of sheets to be deleted – click Yes to confirm the deletion.
Note
LibreOffice Calc does not let you hide the last visible sheet.
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 19 on page 38).
• 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 the Getting Started Guide.
Unfreezing
To unfreeze rows or columns, go to View on the Menu bar and click Freeze Rows and
Columns to toggle it off. The heavier lines indicating freezing will disappear.
Chapter 1 Introduction | 41
Splitting horizontally or vertically
There are two ways to split a screen horizontally or vertically:
Method One:
1) Click on the row header below the rows where you want to split the screen horizontally or
click on the column header to the right of the columns where you want to split the screen
vertically.
2) Go to View on the Menu bar and select Split Window or right-click and choose Split
Window in the context menu. A thick line appears between the rows or columns
indicating where the split has been placed. An example of a split line is shown below
Row 2 in Figure 22.
Method Two:
For a horizontal split, click on the thick black line at the top of the vertical scroll bar (Figure 23)
and drag the split line below the row where you want the horizontal split positioned.
Similarly, for a vertical split, click on the thick black line at the right of the horizontal scroll bar
(Figure 23) and drag the split line to the right of the column where you want the vertical split
positioned.
Chapter 1 Introduction | 43
• Toggle – toggles the contents view. Only the selected category and its objects are
displayed. Click the icon again to restore all elements for viewing.
• Scenarios – displays all available scenarios. See Chapter 11, Data Analysis, for more
information about scenarios. Double-click a name to apply that scenario and the result is
shown in the sheet. If the Navigator displays scenarios, you can access the following
commands when you right-click a scenario entry:
– Delete – deletes the selected scenario.
– Properties – opens the Edit Scenario dialog, where you can edit the scenario
properties.
• Drag Mode – opens a submenu for selecting which action is performed when dragging
and dropping an object from the Navigator into a document. Depending on the mode you
select, the icon indicates whether a hyperlink, a link, or a copy is created.
– 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.
Description
LibreOffice supports the Dublin Core Metadata Element Set, a standardized set of metadata
elements used to describe physical and electronic documents.
• 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.
Chapter 1 Introduction | 45
• Contributor – enter the name of a person or organization that has contributed to the
spreadsheet.
• Coverage – enter details of the scope of the spreadsheet.
• Identifier – enter a reference that identifies the spreadsheet.
• Publisher – enter the name of a person or organization that makes the spreadsheet
available.
• Relation – enter details of a related resource.
• Rights – enter details of any rights that are held in or over the spreadsheet.
• Source – enter details of any related resource that has been used in deriving the
spreadsheet.
• Type – enter the nature or type of the spreadsheet.
• 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 red “X” button at the end of an entry
to delete the custom property.
Security
Enables two password-protected security options.
• Open file read-only – select to allow this document to be opened only in read-only
mode. This file sharing option protects the document against accidental changes. It is still
possible to edit a copy of the document and save that copy with the same name as the
original.
• Record changes – select to require that all changes be recorded. To protect the
recording state with a password, click Protect and enter a password. This is similar to
Edit > Track Changes > Record on the Menu bar. However, while other users of this
document can apply their changes, they cannot disable change recording without
knowing the password.
• Protect or Unprotect – protects the change recording state with a password. If change
recording is protected for the current document, the button is named Unprotect. Click
Unprotect to disable the protection.
Font
When Embed fonts in the document is selected, any fonts used in the spreadsheet will be
embedded into the document when it is saved. This may be useful if you are creating a PDF of
the spreadsheet and want to control how it will look on other computer systems.
Only embed fonts that are used in documents – If fonts have been defined for the
spreadsheet (for example, in the template), but have not been used, select this option to not
embed them.
Font scripts to embed – You can choose which types of fonts are embedded: Latin, Asian,
Complex. See the Getting Started Guide for more information.
Chapter 1 Introduction | 47
Calc Guide 24.8
Chapter 2
Entering and Editing 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.
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 26).
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 27), select Number in the drop-down list, and enter
4 in the Leading zeroes field. Formatting is applied immediately.
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 26).
2) Make sure the Numbers tab is selected, then select Text from the Category list.
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
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 28. 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 > Languages and Locales > General > 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 26).
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.
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
By default, Calc automatically applies many changes during data input using AutoCorrect. You
can undo any AutoCorrect changes by selecting Edit > Undo on the Menu bar, pressing the
keyboard shortcut Ctrl+Z, or manually going back to the change and replacing the
autocorrection with what you actually want to see.
To change the AutoCorrect options, go to Tools > AutoCorrect Options on the Menu bar to
open the AutoCorrect dialog (Figure 31).
• Replace – edit the replacement table for automatically correcting or replacing words or
abbreviations.
• Exceptions – specify the abbreviations or letter combinations that you do not want
corrected automatically.
• Options – select the options for automatically correcting errors as you type.
• Localized Options – specify the AutoCorrect options for quotation marks and for options
that are specific to the language of the text.
• Reset – reset modified values back to their previous values.
Inserting dashes
Calc provides text shortcuts so that you can quickly insert dashes into a cell and these shortcuts
are shown in Table 4.
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, B) A – B (A, space, en-dash, space, 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.
• When multiple matches continue with the same letters they will appear in the cell after
what has already been typed. Press → to accept the partial completion and move the
cursor to the end of the text inside the 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 61 for more information.
When typing formulas using characters that match function names, a Help tip will appear listing
the available functions that start with matching characters.
AutoInput ignores the case sensitivity of any data you enter. If, for example, you have written
“Total” in a cell, you cannot then use AutoInput to enter “total” in another cell of the same column
without first deactivating AutoInput or entering “total” manually.
By default, AutoInput is activated in Calc. To turn it off, go to Tools on the Menu bar and deselect
AutoInput.
Fill tool
You can use the Fill tool in Calc to duplicate existing content or create a series in a range of cells
in the spreadsheet as shown by the examples in Figure 32.
1) Select the cell containing the contents you want to copy or start the series from.
2) Drag the mouse pointer 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.
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.
Tip
Use the Tab and Shift+Tab keys to jump forward and backward between text boxes
of the Data Form dialog. In addition, you can use the form’s scroll bar to move
between records.
Tip
Move to the last record before entering a new record, otherwise the current record
will be edited.
Caution
Merging cells can lead to calculation errors in formulas used in the spreadsheet.
Tip
You can select sheets with the mouse, as described in the “Selecting sheets” section
of Chapter 1, Introduction.
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 40).
Criteria options
Specify the validation rules for the selected cells using the Criteria tab of the Validity dialog as
shown in Figure 40. For example, you can define criteria such as numbers between 1 and 10, or
texts that are no more than 20 characters.
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 44), 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 45), then select Paste all or Formats and click OK.
Modifying 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.
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.
Editing data
Sometimes it is necessary to edit the contents of a cell without removing all of the data from the
cell. For example, changing the phrase “Sales in Qtr. 2” to “Sales rose in Qtr” can be done as
follows.
Tip
Each time you select a cell, the contents are displayed in the Input line on the
Formula Bar. Using the Input line may be easier when editing data.
Tip
Instead of steps 5) and 6) above, you can 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.
Tip
The fields are refreshed when the spreadsheet is saved or recalculated when using
the Ctrl+Shift+F9 shortcut.
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
46 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.
Ungrouping
To ungroup any groups of rows or columns:
1) Make sure the grouped rows or columns are displayed and click on a cell within the
group.
2) Go to Data > Group and Outline > Ungroup on the Menu bar, or use the keyboard
combination Ctrl+F12.
3) If only rows or only columns are grouped, they are ungrouped. If both rows and columns
are grouped, select either Rows or Columns on the Ungroup dialog and click OK.
Caution
Any hidden groups of rows or columns must be displayed. If they are hidden, then
the grouped rows or columns are deleted from the spreadsheet.
Note
If there are nested groups, only the last group of rows or columns created is
ungrouped.
AutoOutline
If a selected cell range contains formulas or references, Calc can automatically outline the
selection. For example, in Figure 47 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.
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 49).
4) Select one or more values or enter a string to be used as the filter criteria in the Search
items box. After clicking OK only the records matching the filter criteria will be visible.
Rows affected by the AutoFilter will have their numbers displayed in blue. Columns
where filtering conditions were created will display the arrow button in blue.
Filtering by color
You can filter data by the background or font colors used in the cells of a column of interest.
• The AutoFilter drop-down provides a Filter by Color menu containing an entry for each
background color used. In the example shown in Figure 50, the menu provides three
entries indicating that some cells have a light green background, others have a yellow
background, and the remainder have no background color set (“No Fill”).
• The Filter by Color menu on the AutoFilter drop-down also contains an entry for each
font color used. In the example shown in Figure 50, the menu provides three entries
indicating that some cells have a black font, others have a blue font, and the remainder
have a red font. In this case there are no cells that utilize the automatically assigned font
(“Automatic”). The colors presented in this menu include those assigned through custom
number format codes.
Note
It is not possible to filter by a combination of different colors.
Filtering by condition
The AutoFilter drop-down provides a Filter by Condition menu containing five entries:
• Empty. Filter data to show only rows with empty cells in the relevant column.
• Not Empty. Filter data to show only rows with non-empty cells in the relevant column.
• Top 10. Displays the ten rows of the cell range that contain the largest values in the cells
of the current column. If these values are unique then no more than ten rows will be
visible, but if the values are not unique then it is possible for more than ten rows to be
shown.
• Bottom 10. Displays the ten rows of the cell range that contain the smallest values in the
cells of the current column. If these values are unique then no more than ten rows will be
visible, but if the values are not unique then it is possible for more than ten rows to be
shown.
• Standard Filter. Displays the Standard Filter dialog (see Figure 48).
Sorting records
Sorting within Calc arranges the cells in a sheet using the sort criteria that you specify. Several
criteria can be used and a sort applies each criteria consecutively. Sorts are useful when you are
searching for a particular item and become even more useful after you have filtered data.
Also, sorting is useful when you add new information to a spreadsheet. When a spreadsheet is
long, it is usually easier to add new information at the bottom of the sheet, rather than adding
rows in their correct place. After you have added information, you can then sort the records to
update the spreadsheet.
Sort dialog
To sort cells in a spreadsheet using the Sort dialog:
1) Select the cells, rows, or columns to be sorted.
2) Go to Data > Sort on the Menu bar, or click the Sort icon on the Standard toolbar, to
open the Sort dialog.
3) On the Options tab (Figure 53), choose options including whether to sort on rows or
columns. See “Sort options” on page 80 for details.
4) On the Sort Criteria tab (Figure 54), select the criteria in the drop-down lists. The
selection lists are populated from the selected cells.
5) Select either Ascending order (A-Z, 0-9) or Descending order (Z-A, 9-0).
6) Headers – omits the first column/row in the selection from the sort.
7) Direction – select Top to bottom (sort rows) to sort rows by the values in the active
columns of the selected range or select Left to right (sort columns) to sort columns by
the values in the active rows of the selected range.
8) Click OK and the sort is carried out on 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.
Sort options
On the Options tab of the Sort dialog (Figure 53), 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.
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.
If your data table has an AutoFilter applied, then you can quickly sort using the Sort Ascending,
Sort Descending, and the Sort by Color menu options on the AutoFilter drop-down (Figure 55).
Using the Sort by Color menu, you can sort data by the background or font colors used in the
cells of a column of interest. The color selected in this menu appears at the top of the sorted list.
The options provided in the Sort by Color menu are similar to those in the Filter by Color menu
of the AutoFilter drop-down (see Figure 50) and it is not possible to sort by a combination of
different colors.
Find toolbar
Replacing
1) In the Find and Replace dialog enter the search criteria in the Find box.
2) Select basic options from those located directly under the Find box.
3) Enter the replacement contents in the Replace box.
4) If necessary, click on Other options to increase the number of search filters.
5) To step through the cells and choose whether to replace the contents:
a) Click Find Next to locate the first instance of the search criteria.
b) If necessary, click Replace to replace the search criteria with the contents of the
Replace box.
c) Repeat as required.
6) Or, to locate and replace all instances of the search criteria without stopping at each one,
click Replace All. A Search Results dialog will pop up, listing the affected cells.
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.
Figure 60: Using a regular expression on the Find and Replace dialog
Suppose we want to filter the same spreadsheet (Figure 59) 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 61).
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.
Tip
The online help describes many more regular expressions and their uses.
Note
If interoperability with Microsoft Excel is important for your spreadsheet, then you
may not be able to fully utilize Calc’s regular expression facilities because Excel
does not provide equivalent facilities. Hence, when you export a Calc spreadsheet to
Excel format, information relating to regular expressions will not be usable within
Chapter 3
Formatting Data
Make your data shine
Introduction
As with any modern spreadsheet program, cell formatting is an important feature of Calc. Calc
formatting resources use an extensive set of attributes to enhance the visual display of relevant
information of your spreadsheet. Manual and style formatting, as well as conditional formatting,
are addressed in this chapter.
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. Formatting can be defined as part of a cell style
so that it is automatically applied, or it can be applied manually to the cell. The Format Cells
dialog can be used for more control and extra options, over a selected cell or cell range. 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 63).
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 64).
3) Select the Wrap text option to apply the formatting immediately.
Method 3
1) Select the cell.
2) Click on the toolbar Wrap Text tool.
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 67) and select a font in the drop-down list. A font is temporarily
applied on selected cells by hovering or navigating in the Font Name drop-down list.
The font can also be changed using the Font tab on the Format Cells dialog.
Note
To specify the language used in the cell, open the Font tab on the Format Cells
dialog. Changing language in a cell allows different languages to exist within the
same document. For more changes to font characteristics, see “Font effects” below.
Tip
To choose whether to show the font names in their font or in plain text, go to Tools >
Options > LibreOffice > View and select or deselect the Show preview of fonts
option in the Font Lists section. For more information, see Chapter 16 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 68).
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.
Changes are applied to selected text, the word containing the cursor, or to any new text you
type.
Text orientation
To change the text direction within a cell, use the Alignment tab on the Format Cells dialog
(Figure 63 on page 93):
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.
If Asian language support is enabled and the text direction is set to vertical, then an Asian layout
mode becomes available.. This option, which can be enabled using a checkbox on the
Alignment tab of the Format Cells dialog, 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 > Languages and Locales >
General > Default Languages 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 required icon to place it on the Formatting toolbar.
Asian typography
If Asian language support is enabled, then an Asian Typography tab is included on the Format
Cells dialog (Figure 69). This tab enables setting of typographic options for cells in Asian
language documents. To enable Asian language support, navigate through Tools > Options >
Languages and Locales > General > Default Languages for Documents > Asian.
Note
When entering borders with the border icons on the Formatting toolbar, you have two
choices: either left-click the required icon to add a border to the present borders or
Shift+click to add a border and remove the present borders.
Note
Autoformatting does not use cell styles. It applies direct formatting to the selected
range. The new Autoformat is stored in the user profile and is not part of the
spreadsheet document. This means that you can reuse the new AutoFormat in
another spreadsheet document using your profile. However, under a different profile
or different user, the new AutoFormat will not be listed. See Chapter 4, Using Styles
and Templates.
Value highlighting
Sometimes, your spreadsheet can contain data of different types in the same column, row or
range. For example, a column with dates can have a string (text) written in the same format as
the default date format for the column. Because strings and numbers are treated differently in
some important functions, such as AVERAGE for example, the spreadsheet can display incorrect
results if your data has mixed types.
Value highlighting displays cell contents in different colors depending on the type of content. An
example of value highlighting is shown in Figure 72:
• Text is shown in black.
• Formulas are shown in green.
• Numbers (including date and time) are shown in blue.
Tip
If the font color does not change when applied to a cell, check if the Value
highlighting is active.
Note
To use conditional formatting, the AutoCalculate feature must be enabled and styles
must be used. See Chapter 4, Using Styles and Templates, for more information.
Tip
Although each condition type 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 77 to 81 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.
Cell value
Applies the selected style to the cell or cell range controlled by the condition set in the drop
down list. The formatting is applied to each cell individually and the condition may depend on
other cells values of the selected range. Valid conditions are described in tables 5, 6 and 7.
Table 5: Conditions for number and text in cells
Condition Applies the selected style to the cell...
...when the cell value equals the user defined value in text box in the
is equal to
right. Use text inside quotes if you compare text values.
the cell value is not equal (different) to the user defined value in the text
is not equal to
box in the right. Use text inside quotes if you compare text values.
is duplicate Applies the selected style to the cell when at least one other cell in the
range has equal contents.
is error Tip
A cell that references another cell with an error
condition is not in error itself.
When the cell is not in an error condition defined in the right text box.
is not error
See Appendix B "Error Codes".
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 or gradient.
Data Bar
Data bars provide a graphical representation of data in the spreadsheet. The graphical
representation is based on the values of data in a selected range. Click on More Options in the
Conditional Formatting dialog to define how the data bars will look. Data bars can only be used
when All Cells has been selected for the condition.
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 operators in the drop down
menu include equal to, less than, greater than, less than or equal to, greater than or equal to,
and not equal to (Figure 17). The icon sets available include colored arrows, gray arrows,
colored flags, colored signs, symbols, bar ratings, and quarters (Figure 82 and Figure 83). Icon
Date
Date applies a defined style depending on a date range chosen in the drop-down menu. Date
range options are formed by applying the adjectives This, Last, and Next to the available
periods for Day, Week, Month, or Year with. Last 7 days is another option available. Examples
include Tomorrow (the word for next day), Last 7 days, This week, Next month, Last year.
Note
The start and end of the week is locale dependent (set in Tools > Options >
Languages and Locales > General).
Formula is
Applies the selected style to the cell when the formula expression in the text box in the right is
not zero.
The formula is expressed similar to a test condition evaluating to TRUE or FALSE.
Figure 86 shows different cell styles applied based on conditions for dates before and after the
current date. The formulae are expressed in Table 8.
Figure 86: Conditions to set current, past, and future dates using formulas
Table 8: Current, past and future deadlines with formulas
Deadlines Formula is Style applied
Current date F3 = TODAY() "Neutral"
Past date F3 < TODAY() "Bad"
Future date F3 > TODAY() "Good"
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.
Tip
To enable/disable a visual indicator of hidden columns and rows, go to View >
Hidden Row/Column Indicator.
Cells
Hiding individual cells is more complicated. First, you need to define the cells as protected and
hidden; then you need to protect the sheet:
1) Select the cells you want to hide.
2) Go to Format > Cells on the Menu bar, or right-click and select Format Cells in the
context menu, or press Ctrl+1, to open the Format Cells dialog (Figure 88).
3) Click the Cell Protection tab and select an option for hiding and printing the cells.
4) Click OK to save the changes and close the dialog.
5) Go to Tools > Protect Sheet on the Menu bar, or right-click on the sheet tab and select
Protect Sheet in the context menu, to open the Protect Sheet dialog (Figure 89).
6) Select Protect this sheet and the contents of protected cells.
7) Create a password and then confirm the password. The dialog provides a password
strength meter to indicate the strength of the entered password. This incorporates a
colored bar to reflect password strength, with red indicating a weak password and green
indicating a strong password. In addition, the longer the colored bar, the greater the
strength of the password.
8) Select or deselect the options in the Allow all users of this sheet to area so that users can
select protected or unprotected cells.
9) Click OK to save the changes and close the dialog.
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 89).
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 88).
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.
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, shapes, 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 drawing and 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 15, Setting
up and Customizing, for instructions.
Drawing styles
Drawing styles in Calc are similar to the graphic styles used in LibreOffice Draw and can be
applied to shapes and comments. If the same area fill, lines, borders, and other relevant
attributes are to be applied to a set of such objects, this repetitive process can be simplified by
using drawing styles.
Two drawing styles (Default and Note) are supplied with Calc and these can be modified or used
as the basis for new custom drawing styles, but cannot be deleted.
• When a shape is added to a spreadsheet, the Default drawing style is initially applied to
that shape. Shapes may be inserted using several methods – for example by going to
the Insert > Shape menu on the Menu bar or by clicking icons on the Drawing toolbar.
• When a comment is inserted into a spreadsheet, the Note drawing style is initially
applied to that comment. Comments may be inserted using several methods – for
example by going to the Insert > Comment option on the Menu bar or by clicking the
Insert Comment icon on the Standard toolbar.
Tip
You can select the comment drawing object and apply another drawing style, and
have notes in different background colors, fonts and font sizes, for example.
Page styles
Page styles in Calc are applied to sheets. Although one sheet may print on several pages, only
one page style can be applied to a sheet. If a spreadsheet file contains more than one sheet,
then a different page style can be applied to each sheet. For example, a spreadsheet might
contain some sheets to be printed in landscape orientation and other sheets to be printed in
portrait orientation.
Two page styles are supplied with Calc: Default and Report. Page styles allow you to set page
size and orientation, page margins, headers and footers, borders and backgrounds, and the
sequence for printing sheets.
Styles menu
By default, the Styles menu (Figure 90) 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 92: 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 93).
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, drawing, or page styles,
including any custom styles that you have created. See Chapter 15, 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” for more
information.
5) Go to the Styles deck on the Sidebar (Figure 91).
6) To create a new cell style, click the Cell Styles icon; or to create a new drawing style,
click the Drawing Styles icon; or to create a new page style, click the Page Styles icon.
7) Right-click in the Styles deck and select New in the context menu to open either the Cell
Style dialog, the Drawing Style dialog, or the Page Style dialog.
8) Use the various tabbed pages on the dialogs to set the attributes for the new style. See
“Cell style attributes”, “Drawing style attributes”, and “Page style attributes” for more
information.
9) Click OK to close the dialog and save the new style.
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;
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.
• Options – specify the options for the selected format:
– Decimal places – enter the number of decimal places that you want to display.
– Leading zeroes – enter the maximum number of zeroes to display in front of the
decimal point.
– Negative numbers red – select to change the font color of negative numbers to red.
– Thousands separator – select to insert a separator between thousands. The type of
separator (for example, a comma or a space) depends on your language settings.
• Format code – displays the number format code for the selected format. You can also
enter a custom format.
• Add – adds the number format code that you entered to the user-defined category.
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 97
shows the Font tab of the Cell Style dialog when the Asian and Complex text layout options
are selected in the Default Languages for Documents area of the Tools > Options >
Languages and Locales > General page. The layout of the Font and Font Effects tabs are
modified if either of these two options is deselected.
• Font – select an installed font in the list.
• Style – select the formatting you want to apply, for example bold, Italic, or underline.
• Size – select or enter the font size that you want to apply. For scalable fonts, you can
also enter decimal values. If you are creating a style that is based on another style, you
can enter a percentage value or a point value (for example, 2 pt or 5 pt).
• Language – sets the language that the spelling checker is to use. The spelling checker
works only when you have installed the corresponding language module. A language
entry has a check mark in front of it if the spelling checker is activated for that language.
• Features – some fonts offer special features such as Discretionary Ligatures and
Horizontal Kerning. Click this button to access the Font Features dialog (not shown) to
select those features.
• Preview – displays a preview of the current selection.
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.
• Line Arrangement – select a preset border style or define your own combination by
clicking in the diagram.
• Line – select the line style, thickness, and color that you want to apply. The style is
applied to the borders selected in the preview.
• Padding – specify the amount of space that you want to leave between the border and
the contents of the cell. You can set each distance (left, right, top, bottom) individually or
select Synchronize to apply the same padding to all four borders when you enter a new
value.
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.
– Format – select a predefined paper size, or create a custom format by entering the
dimensions for the paper in the Height and Width boxes.
– Width – displays the width of the selected paper format. To define a custom (user)
format, enter a width here.
– Height – displays the height of the selected paper format. To define a custom (user)
format, enter a height here.
– Orientation – Portrait displays and prints the spreadsheet with the paper oriented
vertically. Landscape displays and prints the spreadsheet with the paper oriented
horizontally.
– Text direction – select the text direction that you want to use in your document. The
"right-to-left (vertical)" text flow direction rotates all layout settings to the right by 90
degrees, except for the header and footer. This option is only available if Complex
text layout is selected at Tools > Options > Languages and Locales > General.
– Preview Field – displays a preview of the current selection.
– Paper tray – select the paper source for your printer. You can assign different paper
trays to different page styles. For example, you can assign a different tray for the first
page style in the spreadsheet and load the tray with your company letterhead paper.
• Margins – specify the amount of space to leave between the edges of the paper and the
spreadsheet contents.
– Left/Inner – the space between the left edge of the page and the spreadsheet. If you
are using Mirrored page layout, enter the space between the inner edge of the paper
and the spreadsheet. You may want to have a wider space as the left/inner margin if
you will be punching or binding the pages.
– Right/Outer – the space between the right edge of the paper and the spreadsheet. If
you are using Mirrored page layout, enter the space between the outer edge of the
paper and the spreadsheet.
– Top – enter the space between the upper edge of the paper and the spreadsheet.
Using themes
Using spreadsheet 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 106), 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.
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 95), or the Drawing Style dialog (Figure 104), or the Page
Style dialog (Figure 105).
3) Make the necessary changes to the style attributes. For more information on style
attributes, see “Cell style attributes”, Drawing style attributes, and “Page style attributes”.
4) Click OK to save the changes and close the dialog.
Note
The Modify command is unavailable if one or more sheets are protected, even if the
cell style to be modified is being used in an unprotected sheet.
Renaming styles
You can rename custom styles, but not the styles supplied with Calc.
1) Go to the Styles panel on the Sidebar (Figure 91) 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, the Drawing Style 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 91) and click the icon for the type of style
you want to delete.
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, drawing, 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 112) 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” for more
information).
6) Click Save to save the new template.
Note
Although the Save as Template dialog shows no document type when saving a new
template of any type, the template will appear on the correct tab (Spreadsheets, in
this case) when you return to the Templates dialog. It is unnecessary to save or do
anything further with the spreadsheet file you have been using to create the new
template. It can be safely closed without saving.
Note
You can also save a template through the Save As dialog, accessed by a variety of
interactions including selecting File > Save As on the Menu bar or pressing
Ctrl+Shift+S. Select the ODF Spreadsheet Template option in the Save as type
menu 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. You can also manage templates from the
Start Center.
2) Navigate to the spreadsheet template that you want to edit. Right-click to open the
context menu and choose Edit (Figure 113). The template opens in Calc.
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 button in the Manage menu.
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” below.)
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.
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) Right-click the template you want to move and select the Move option from the context
menu, select the destination category from the popup dialog (Figure 117), 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 113).
3) A message box appears and asks you to confirm the deletion. Click Yes.
Note
Moving or deleting a template has no impact on any document that was created from
that template. The spreadsheet will retain the style definitions that it inherited from
the moved or deleted template. The Template field on the File > Properties >
General page can continue to show the name of a template that no longer exists.
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
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.
Tip
If you wish to use gallery images from earlier versions of LibreOffice, go to
https://extensions.libreoffice.org/ and search for items with a tag filter of “Gallery” or
click on the Add more galleries via extension button, on the bottom right of the
Gallery to open the Extensions: Gallery dialog.
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” below.
• 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” below.
• 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” below.
• 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.
• Rotate – places rotation handles around the image.
Adding text
You can add text to an image or drawing object. That text will move with the image when the
image is re-positioned. 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.
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.
3) Alternatively, click on one of the six arrangement icons on the Image toolbar to quickly
move the image up or down the stacking order.
The arrangement options are as follows:
• Bring to Front – moves the selected image to the top of the stacking order, so that it is
in front of other images.
• Forward One – moves the selected image up one level, so that it is closer to top of the
stacking order.
• Back One – moves the selected image down one level, so that it is closer to the bottom
of the stacking order.
• Send to Back – moves the selected image to the bottom of the stacking order, so that it
is behind the other images.
• To Foreground – moves the selected image in front of text.
• To Background – moves the selected image behind text. To select a background image
so that you can modify or replace it, you have to use the Navigator. Other methods of
selection, such as clicking or double-clicking, do not work.
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.
Tip
Use Fit to Cell Size in the graphic (image) context menu to resize the image to the
cell dimensions. You may want to adjust the row height and column width
accordingly.
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.
Note
When grouping images, the resulting image is anchored To Page. You can change
the anchor as usual.
To ungroup images:
1) Select the image group you want to ungroup.
2) Go to Format > Group > Ungroup on the Menu bar, or right-click on one of the selected
images and select Ungroup in the context menu.
To edit an image in a group:
1) Select the image group where you want to edit an image within the group.
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 125. 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 from the context menu.
Figure 128: Position and Size dialog – Position and Size tab
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.
Generating a QR or Barcode
The QR and Barcode generation feature allows you to encode any text string or URL as a
barcode or QR code and insert it into your spreadsheet as an image.
Chapter 6
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 136) and open the Chart
Wizard dialog (Figure 137), 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.
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 mouse pointer by first clicking the Select data range button to
the right of the Data range box. Place the pointer 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 pointer 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 139).
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.
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 169 and 170).
Depending on the type of chart, other data ranges may need to be defined in addition to those
shown in Figure 139.
Figure 142: Sidebar Properties deck with chart selected (left) and 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 142 shows the Properties deck when a chart is selected (by clicking
on it once). When a chart is in edit mode (by clicking on it twice), the Properties deck on the right
in Figure 142 appears.
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.
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 218 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
218) 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 143.
Format menu
In edit mode, these settings appear on the Format menu (Figure 144) of the Menu bar.
Formatting toolbar
In edit mode, the Formatting bar appears as in Figure 145. 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 pointer. 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 pointer 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 147):
– Click Format > Title and select the desired type of title or the All Titles option.
– Click on the element in the chart, right-click, and select Format Title (or appropriate
element) from the context menu.
– Click on the element in the chart or select it in the Select Chart Element drop-down list
on the Formatting toolbar. Then select Format > Format Selection on the Menu bar
or click on the Format Selection icon on the Formatting toolbar.
3) Format titles or names as needed. The options are self-explanatory or easily researched.
4) Click OK to close the dialog. If desired, click outside the chart to leave edit mode.
Legends
When a legend is displayed, it shows data series names along with their graphical
representations, such as bars, lines, or points. It will also show trend and mean lines when those
are turned on, as shown in Figure 148.
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 167. 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 176.
Formatting legends
For advanced editing of a legend’s appearance, a more extensive Legend dialog (Figure 150)
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 150):
– Click on the Legend icon on the Formatting toolbar.
– 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 166 and “Selecting data series” on
page 167.
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.
Note
Data ranges for border color and fill can only be specified for column, bar, pie,
bubble, and column and line charts.
Figure 157: Using the COLOR function and a conditional formula to specify colors
The chart on the right in Figure 157 shows how the colors change to reflect the conditional
formatting.
Axes
Add or remove axis labels
Use the Axes dialog shown in Figure 159 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
177).
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.
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 184).
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 156 on page 188
but excluding the Icon section.
Note
Problems may arise in displaying labels if the chart is too small. Avoid this by either
enlarging the chart or decreasing the font size.
Text flow
Determines how text flows in axis labels.
– Overlap – allows axis labels to overlap.
– Break – allows text breaks, enabling text to wrap into new lines in the available space.
Text Orientation
Defines the direction and orientation of label text.
– Vertically stacked – Stacks characters vertically so that text is read from top to
bottom.
Numbers
Use the Numbers tab (Figure 167) 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 3, Formatting Data, as well as the online Help.
Asian Typography
Sets the Asian typographic options for axis labels. This tab is the same as that for specifying
Asian typographic options for cells. See Chapter 3, Formatting Data, for more information.
Data labels
Data labels display information next to data points on the chart. They can be quite useful for
highlighting specific data when presenting detailed information, but be careful not to create a
chart that is too cluttered to read easily.
Note
If no data series is selected, then all data series on the chart will be labeled.
3) To open the Data Labels dialog (Figure 170), 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 169). The controls on this
Tip
Select a data series by clicking once on a column, bar, or other graphic
representation of the data series. Select a single data point by pausing, then clicking
again.
Most of the tabs in the Data Labels dialog are used in other dialogs and can be readily
understood or easily researched. The exception is the Data Labels tab (Figure 170), which
contains the following options:
Value as number
Displays the numeric value of a data point. When selected, this option activates the
Number format button.
Number format
Opens the Format Number dialog, which is the same as the Numbers tab of the Format
Cells dialog discussed in Chapter 3, Formatting Data. Deselect Source format to
activate options on the Format Number dialog.
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.
Note
The nature and volume of data shown on a chart, and the type of chart, may not be
suitable for displaying a usable chart data table. In such cases, the chart data table
can simply be removed.
Tip
The content of the chart data table inherits the formatting of the chart’s source data.
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 175. 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 175: Major and minor grid lines for the X and Y axes
Grids are available for all chart types with the exception of pie charts.
Note
In the Formatting toolbar, the Horizontal Grids icon and the Vertical Grids icon set
grid lines for the Y axis and X axis, respectively. This can be misleading because
both the Y axis and the X axis can be horizontal or vertical, depending on the type of
chart. Thus, for a bar chart, click the Horizontal Grids icon to control the vertical
grids.
Formatting grids
In addition to the Grids dialog shown in Figure 176, 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 177).
Note
Use the Scale tab of the Axis dialog to specify the intervals between grid lines. This
is described in “Defining scales” on page 192.
3D charts
Setting 3D look
Column, bar, pie, and area charts can be displayed as 3D charts. The setting to make a chart 3D
is on the first page of the Chart Wizard. If the chart has already been created, do the following to
give it a 3D look:
1) Select the chart by double-clicking on it to enter edit mode. The chart should now be
surrounded by a gray border.
Formatting 3D view
To make changes to a 3D chart, use the 3D View dialog (Figure 178).
Appearance
Use the Appearance tab of the 3D View dialog (Figure 179) to modify some aspects of the
appearance of the data in a 3D chart.
First select a rendering scheme from the Scheme drop-down list – Realistic (default) or Simple.
The scheme selected sets the options and light sources. Depending on the scheme selected,
not all options may be available. To create a custom scheme, select or deselect a combination of
Shading, Object borders, and Rounded edges.
Some hints:
• Select Shading to use the Gouraud method for rendering the surface. Otherwise, a flat
method is used. The flat method sets a single color and brightness for each polygon. The
edges are visible but soft gradients and spotlights are not possible. The Gouraud method
applies gradients for a smoother, more realistic look. See the Draw Guide for more
information on the use of shading.
• Select Object borders to draw lines along the edges.
• Select Rounded edges to smooth the edges of box shapes.
Illumination
Use the Illumination tab (Figure 180) of the 3D View dialog to control light sources for the 3D
view.
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).
Moving Average
Simple moving average for n previous y-values, with n being the period. No equation is
available for this trend line. The type of moving average regression curve is selected as
Prior, Central, or Averaged Abscissa.
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.
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.
Most of these options are self-evident or can be readily researched, especially by referring to the
Draw Guide. Clicking on the icon for an option changes the pointer’s appearance, depending on
the option. Click and drag the pointer to create the desired drawing object in the chart.
Information that may be helpful for charts follows.
Insert Line
Draws a straight line where dragged.
Note
If you draw a line in the spreadsheet (outside any chart), you can hold down Shift
while dragging to constrain angles of the line to multiples of 45 degrees. This facility
is not applicable when inserting a line on a chart.
Write on the line by double-clicking the line and typing or pasting text. If the text is too
low, press Enter to raise it above the line.
Insert Text Box
Draws a text box with horizontal text direction. To place the text at an angle, click once
on the text box to select it, right-click, and select Position and Size from the context
menu. Specify the angle on the Rotation tab.
Figure 189: Basic Shapes Figure 190: Symbol Shapes Figure 191: Block Arrows
Figure 192: Flowcharts Figure 193: Callouts Figure 194: Stars and Banners
Changing interactively
Resizing
To resize a chart interactively:
1) Click once on the chart to select it. Square selection handles appear around the border
of the chart.
2) Click and drag one of the selection handles. The pointer indicates the direction to
increase or decrease the chart size. Clicking and dragging a corner handle preserves the
horizontal to vertical size ratio.
3) 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.
To resize or move a chart using the Position and Size dialog:
1) Right-click on the chart and select Position and Size in the context menu to open the
Position and Size dialog (Figure 195).
2) Select the desired options on the Position and Size, Rotation, and Slant & Corner Radius
tabs on this dialog. See below for further information about the options on these tabs.
3) Click OK to close the dialog and save changes.
4) When finished, click outside the chart to leave selection mode.
When positioning or resizing, click one of the points in the Base point graphic corresponding to
the location to use for anchoring either the position of the chart or its size.
Note that either the position or the size can be protected from unwanted changes by clicking the
appropriate box in the Protect section. Either or both option(s) selected will remain active after
the dialog is closed. By contrast, Calc resets the base point to the default position after the
dialog is closed.
Rotation
The options for the Rotation tab (Figure 196) are as follows:
Figure 197: Position and Size dialog – Slant and Corner Radius tab
Figure 198: Drawing Object Properties toolbar that appears when chart is selected
1. Anchor 7. To Foreground 13. Fill Color
2. Align Objects 8. To Background 14. Arrow Style
3. Bring to Front 9. Line Style 15. Rotate
4. Forward One 10. Line Width 16. Points
5. Back One 11. Line Color 17. Group
6. Send to Back 12. Area Style/Filling
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 12, 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.
Chapter 7
Gallery of Chart Types
Introduction
While data can be presented using a variety of charts, focus on the message of the chart to
determine which type of chart to use. The following sections present examples of the chart types
that Calc provides, with some notes on the uses of each one.
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 200.
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 201 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 in Chapter 6 – Creating Charts and Graphs).
• 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.
Pie charts
A pie chart shows values as circular sections of a circle. The area of each section is proportional
to its value.
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
By custom, if one of the variables is either controlled by an experimenter or it
changes consistently (such as time) it is considered an independent variable and
plotted on the X axis.
XY chart variants
Bubble charts
A bubble chart is a variation of a scatter chart that can show three variables in two dimensions.
The data points are shown with bubbles. Two variables are plotted along the X and Y axes, while
the third variable is represented by the relative size of the bubbles. These charts are often used
to present financial data or social/demographic data.
One or more data series can be included in a single chart. The data series dialog for a bubble
chart has an entry to define the data range that determines the size of the bubbles.
It may be necessary to build a bubble chart manually in the data series page of the Chart
Wizard. Figure 215 shows how the data ranges can be set for a bubble chart.
Net charts
Net charts are also known as spider, polar, or radar charts. They display data values as points
on radial spokes, with each spoke representing a variable. They compare data that are not time
series, but show different circumstances, such as variables in a scientific experiment. They are
especially useful for displaying clusters and outliers.
Figure 217 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 219: 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 220. 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 “Chapter 6: Aligning data to secondary
Y axis”.
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 225).
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 10, Using Pivot Tables.
Figure 228: Stacked column chart and box plot with whiskers
5) Minimum of the data series 8) The median of the data series
6) The first quartile of the data series 9) The third quartile of the data series is also
7) Bottom of the box to be formed the top of the shapes box
10) The maximum of the data series
Sparklines
Sparklines are small, simple, cell-sized charts that convey the general shape of data variation
within a dataset. Typically, sparklines are used to show variation over time and are usually drawn
without axes or coordinates.
Tip
Calc’s sparklines are compatible with Microsoft Excel’s version of sparklines and can
be both imported from and exported to Excel.
Creating a sparkline
To create a sparkline:
1) Select the row or column of source data.
2) Either right-click on the selected data and choose Sparklines > Sparkline from the
context menu, or go to Insert > Sparkline on the Menu bar.
3) Calc displays the Sparkline Properties dialog, configured for sparkline creation (Figure
230).
4) Select a single cell as the Output range.
5) Complete the remainder of the Sparkline Properties dialog, as required for the new
sparkline. The available options are described below.
6) Click OK to close the Sparkline Properties dialog and create the sparkline.
Note
A sparkline is limited to one cell. To increase the size of the sparkline, increase the
size of the cell. If the sparkline cell is merged into other cells, the sparkline will
remain the same size as in the original cell but the option to modify the sparkline’s
formatting will be lost until the cell is unmerged.
Types of sparkline
There are three types of sparkline – line, column, and stacked.
Line
Straight lines are drawn connecting data values.
Tip
If the OK button in the Sparkline Properties dialog is unavailable, it is because the
number of cells in the Output range does not match the number of rows or columns
selected in the Input range. Update these dimensions to match and the OK button
will become available.
Modifying a sparkline
Updating a sparkline’s data range
To update a sparkline’s data range:
1) Right-click on the sparkline and choose Sparklines > Edit Sparkline from the context
menu.
2) Calc displays the Sparkline Data Range dialog (Figure 234).
3) Update the Data range as required.
4) Click OK to close the Sparkline Data Range dialog.
Sparkline groups
Sparklines are defined for one cell, but multiple sparklines can be linked together into a group.
The group shares the same formatting properties for rendering the sparkline. The unique data
that is defined for each sparkline is the data range that will be used.
Deleting sparklines
To delete a single sparkline, do one of the following:
• Select the sparkline and press Delete.
• Select the sparkline and go to Format > Sparklines > Delete Sparkline on the Menu
bar.
• Right-click the sparkline and choose Sparklines > Delete Sparkline from the context
menu.
Chapter 8
Printing, Exporting,
Emailing, and Signing
Printing
Quick printing
To quickly print a spreadsheet, click the Print Directly icon (not visible by default) on the
Standard toolbar to send the entire spreadsheet to your default printer.
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 use the Ctrl+P key combination to open the Print dialog (Figure 236).
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 15, 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 that 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 236), you can choose from the following options:
• Printer
– Select an available printer from the list of installed printers.
– 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” below.)
• 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.
Figure 238: Printing more than one spreadsheet page per sheet of paper
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.
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
use the Ctrl+P key combination to open the Print dialog.
2) Click the Properties button 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” below.
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
If an appropriate cell (right of a column break or below a row break) has not been
selected, then the Column Break or Row Break options are grayed out.
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.
Reduce/enlarge printout – specifies a scaling factor to scale all printed pages. Enter
the scaling factor as a percentage in the box, in the range 10% to 400%. Factors less
than 100% reduce the pages, while higher factors enlarge the pages.
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
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 overrides many of the other settings on
the PDF Options dialog.
• Export automatically inserted blank pages: Not available in Calc.
• Use reference XObjects: Reference XObjects enable one PDF file to import content
from another. More information can be found in the ISO 32000 standard that defines the
core specifications of PDF files. If you are not familiar with reference XObjects, leave this
box unchecked.
Note
Outlines are generally not used in Calc.
Note
Permissions settings are effective only if the user’s PDF viewer respects the settings.
Emailing spreadsheets
LibreOffice provides several ways to quickly and easily send a document as an email attachment
in OpenDocument format (LibreOffice default format), other spreadsheet formats, or as a PDF
file. You can also email a document to several recipients. For more information, see the Getting
Started Guide.
To send the spreadsheet as an email attachment:
1) Go to File > Send on the Menu bar and select from the following options. LibreOffice
opens your default email program (if set) with the spreadsheet attached in the selected
format.
– Email Document: the spreadsheet is sent in its current format.
– Email as OpenDocument Spreadsheet: the spreadsheet is sent in the ODF format
(.ods).
– Email as Microsoft Excel: the spreadsheet is sent in the Excel format (.xlsx).
– Email as PDF: The PDF Options dialog opens. Select the parameters to be used for
the PDF file. See “Controlling PDF content and quality” above.
2) In your email program, enter the recipient, subject, and any text you want to add, then
send the email.
Note
Avoid the Send via Bluetooth option, which is non-operational in this software build.
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 9
Using Formulas and
Functions
Introduction
In earlier chapters, we focused on entering two basic types of data into spreadsheet cells:
numbers and text. However, there are times when the content of a cell isn't straightforward and
depends on the values in other cells. To address this, we use a third type of data: formulas.
Formulas are equations that combine numbers and variables to calculate a result. In
spreadsheets, the variables are cell references containing the data needed for the calculation.
In addition to formulas, spreadsheets also offer functions, which are predefined calculations
designed to help analyze or manipulate data efficiently. By providing the required inputs, called
arguments, the function performs the calculation automatically. Functions simplify the process of
creating complex formulas, making it easier to achieve the results you need.
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:
• Choose the right kind of input.
• Include documentation.
• Incorporate a system of error-checking.
The points above are explained further below.
Formula inputs
Many users create lengthy and complex formulas by directly typing fixed values into them. For
example, when converting one currency to another, the formula requires the current exchange
rate. Suppose you enter a formula in cell C1 as =0.75*B1 to calculate the value in euros for the
dollar amount in cell B1. If the exchange rate changes from 0.75 to another value, you’ll need to
manually update the formula.
A better approach is to use an input cell for the exchange rate and reference that cell in your
formulas. This makes it easy to adjust calculations when the exchange rate changes. For
example, you can test different scenarios—such as an exchange rate of 0.70 or 0.80—without
editing the formula, and it becomes clear which rate is being used.
Additionally, breaking complex formulas into smaller, more manageable parts (as explained
below) reduces errors and makes troubleshooting much easier.
Creating formulas
You can enter formulas in two ways:
1) Using the Function Wizard or the Functions section in the Sidebar.
2) Typing directly into the cell or the Input line.
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 261.
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 9.
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.
Operator types
The following operator types may be used:
arithmetic
comparative
text
reference
Each of these types are described in the sections that follow.
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 10: 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 11: 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
Text operators
Spreadsheets often include text data. To allow flexibility in how this data is displayed, text from
different cells or sources can be combined into a single string. This process is known as
concatenation. For example, you can join pieces of text from various cells to create a single
message or label. Figure 262 illustrates this concept.
Reference operators
A single cell in a spreadsheet is identified by its column letter (found at the top of the columns)
and its row number (found along the left side of the rows). For spreadsheets read from left to
right, the upper-left cell is referenced as A1.
While a reference typically points to one cell, it can also refer to a range of cells in a rectangle
(e.g., A1:B5) or even a cuboid range in 3D references across sheets. References can also
include lists of non-contiguous cells or ranges. To create these more complex references, you
use reference operators.
Reference range operator
The range operator is written as a colon. An expression using the range operator has the
following syntax:
reference upper left : reference lower right
The range operator builds a reference to the smallest range including both the cells referenced
with the left reference and the cells referenced with the right reference.
In the upper left corner of Figure 263 the reference A1:D12 is shown, corresponding to the cells
included in the drag operation with the mouse to highlight the range.
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” below.
Reference concatenation operator
The concatenation operator is written as a tilde. An expression using the concatenation operator
has the following syntax:
reference left ~ reference right
The result of such an expression is a reference list, which is an ordered list of references. Some
functions can take a reference list as an argument, SUM, MAX, or INDEX for example.
The reference concatenation is sometimes called 'union'. But it is not the union of the two sets
'reference left' and 'reference right' as normally understood in set theory. COUNT(A1:C3~B2:D2)
returns 12 (=9+3), but it has only 10 cells when considered as the union of the two sets of cells.
Notice that SUM(A1:C3,B2:D2) is different from SUM(A1:C3~B2:D2) although they give the
same result. The first is a function call with 2 parameters, each of them is reference to a range.
The second is a function call with 1 parameter, which is a reference list.
The reference concatenation also applies to whole rows and whole columns. For example
SUM(A:B~D:D) is the sum of all cells in columns A and B and the column D.
Tip
Always put the part that is to be calculated first in parentheses.
Relative referencing
An example of a relative reference will illustrate the difference between a relative reference and
absolute reference using the spreadsheet from Figure 265.
1) Type the numbers 4 and 11 into cells C3 and C4 respectively of that spreadsheet.
2) Copy the formula in cell B5 (=B3+B4) to cell C5. You can do this by using a simple copy
and paste or click and drag B5 to C5 as shown below. The formula in B5 calculates the
sum of values in the two cells B3 and B4.
3) Click in cell C5. The formula bar shows =C3+C4 rather than =B3+B4 and the value in C5
is 15, the sum of 4 and 11 which are the values in C3 and C4.
In cell B5 the references to cells B3 and B4 are relative references. This means that Calc
interprets the formula in B5, applies it to the cells in the B column, and puts the result in the cell
holding the formula. When you copied the formula to another cell, the same procedure was used
to calculate the value to put in that cell. This time the formula in cell C5 referred to cells C3 and
C4.
Absolute referencing
You may want to multiply a column of numbers by a fixed amount. A column of figures might
show amounts in US Dollars. To convert these amounts to Euros it is necessary to multiply each
dollar amount by the exchange rate. $US10.00 would be multiplied by 0.75 to convert to Euros,
in this case Eur7.50. The following example shows how to input an exchange rate and use that
rate to convert amounts in a column from USD to Euros.
1) Input the exchange rate Eur:USD (0.75) in cell D1. Enter amounts (in USD) into cells D2,
D3 and D4, for example 10, 20, and 30.
2) In cell E2 type the formula =D2*D1. The result is 7.5, correctly shown.
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.
Named ranges
You can assign names to individual cells or ranges of cells to improve formula readability and
simplify spreadsheet management. For example, instead of using the formula =SUM(B1:B10) to
sum weights in the range B1:B10, you can name the range "Weight" and write the formula as
=SUM(Weight). This makes your formulas more intuitive and easier to understand.
An additional benefit of named ranges is that they dynamically update in all associated formulas
when the range’s location or size changes. For instance, if the "Weight" range moves to
P10:P30, you only need to update the named range definition. The formulas referencing
"Weight" will automatically adjust without further changes.
To define a named cell or range:
1) Select the cell or range.
2) Navigate to Sheet > Named Ranges and Expressions > Define in the menu.
3) In the dialog (as shown in Figure 9), specify the name and scope for the named range.
Order of calculation
The order of calculation refers to the sequence in which operations are performed in a formula.
For an overview of these rules, see the Wikipedia article on orders of operations at
https://en.wikipedia.org/wiki/Order_of_operations .
In spreadsheets, division and multiplication are performed before addition and subtraction. A
common misconception is that calculations occur strictly from left to right, as one might read an
equation in English. However, Calc evaluates the entire formula based on established
precedence rules, prioritizing multiplication and division over addition and subtraction.
To ensure your formula produces the expected result, it's a good practice to test it thoroughly. If
necessary, use parentheses to clarify the order of operations and make your intent explicit. The
following example demonstrates how the order of calculation is applied in practice.
Table 14: Order of calculation
Left To Right Calculation Ordered Calculation
1+3*2+3 = 11 =1+3*2+3 result 10
1+3 = 4, then 4x2 = 8, then 8+3 = 11 3*2 = 6, then 1+6+3 = 10
Another possible intention could be: The program resolves the multiplication of 3 x
1+3*2+3 = 20 2 before dealing with the numbers being
added.
1+3 = 4, then 2+3 = 5, then 4x5=20
If you intend for the result to be either of the two possible solutions on the left, order the formula
as:
((1+3) * 2)+3 = 11 (1+3) * (2+3) = 20
Note
Use parentheses to group operations in the order you intend; for example,
=B4+G12*C4/M12 might become =((B4+G12)*C4)/M12.
Understanding functions
Calc includes over 500 functions to help you analyze and reference data. Many of these
functions are for use with numbers, but others are used with dates and times or even text. A
function may be as simple as adding two numbers together or finding the average of a list of
numbers, or it may be as complex as calculating the standard deviation of a sample or a
hyperbolic tangent of a number.
Typically, the name of a function is an abbreviated description of what the function does. For
instance, the FV function gives the future value of an investment, while BIN2HEX converts a
binary number to a hexadecimal number. In Calc, functions can be entered either in upper, lower
or mixed cases.
A few basic functions are somewhat similar to operators. Examples:
+ (plus) This operator adds two numbers together for a result. SUM() on the other hand
adds groups of contiguous ranges of numbers together.
* (star) This operator multiplies two numbers together for a result. PRODUCT() does the
same for multiplying that SUM() does for adding.
Each function has a number of arguments used in the calculations. These arguments may or
may not have their own name. Your task is to enter the arguments needed to run the function. In
some cases, the arguments have predefined choices, and you may need to refer to the text on
the Function Wizard and the Functions deck, or the Help, to understand them. More often,
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.
Structure of functions
All spreadsheet functions share a similar structure. While using tools like a Function Wizard can
simplify function entry, understanding the structure is valuable for troubleshooting.
Here’s an example of a function to count cells matching specific criteria:
=DCOUNT(Database, Database field, Search criteria)
Key points about function structure:
• Functions are part of formulas: A function cannot stand alone. It must always be
included in a formula, which begins with an = sign. Even if the function is the entire
formula, the = is required.
• Function name: The function starts with its name, such as DCOUNT in the example
above.
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.
EMEA_Sales A named range, previously defined.
Nested functions
Functions can also be used as arguments within other functions. These are called nested
functions.
=SUM(2,PRODUCT(5,7))
To get an idea of what nested functions can do, imagine that you are designing a self-directed
learning module. During the module, students do three quizzes, and enter the results in cells A1,
A2, and A3. In A4, you can create a nested formula that begins by averaging the results of the
quizzes with the formula =AVERAGE(A1:A3). The formula then uses the IF function to give the
student feedback that depends upon the average grade on the quizzes. The entire formula
would read:
=IF(AVERAGE(A1:A3)>85, “Congratulations! You are ready to advance to the next
module”, “Failed. Please review the material again. If necessary, contact your
instructor for help”)
Depending on the average, the student would receive the message for either congratulations or
failure.
Notice that the nested formula for the average does not require its own equal sign. The one at
the start of the equation is enough for both formulas.
If you are new to spreadsheets, the best way to think of functions is as a scripting language. We
have used simple examples to explain the concept more clearly, but, through nesting of
functions, a Calc formula can quickly become complex.
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.
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 282: Source array (yellow), resulting array (green), with array formula in Formula Bar
To multiply the values in the individual cells by 10 in the above array (Figure 282), 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.
Comparison operators in an array formula treat empty cells in the same way as in a normal
formula, that is, either as zero or as an empty string. For example, if cells A1 and A2 are empty
the array formulas {=A1:A2=""} and {=A1:A2=0} will both return a 1 column 2 row array of
cells containing TRUE.
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.
This equation models the position of an object undergoing linear, translational motion, with
constant acceleration. The position (x) depends on time (t), and the equation also contains
constant values for initial position (xi), initial velocity (vi), and acceleration (a).
For ease of presentation, it is good practice to set up a spreadsheet in a manner similar to that
shown in Figure 284. In this example, the individual variables are input into cells on the sheet
and no editing of the formula is required.
You can take several broad approaches when creating a formula. In deciding which approach to
take, consider how many other people will need to use the sheets, the life of the sheets, and the
variations that could be encountered in use of the formula.
If people other than yourself will use the spreadsheet, make sure that it is easy to see what input
is required and where. Explanation of the purpose of the spreadsheet, basis of calculation, input
required and output generated are often placed on the first sheet.
Optimizing calculations
Spreadsheets are often used to process raw data, generate meaningful summaries, consolidate
information, and present it in a format that aids decision-making or serves as the basis for
reports. Raw data may come from various sources, such as physical measurements or business
transactions.
Large spreadsheets with thousands or even hundreds of thousands of rows and multiple
columns are common in fields like finance and research. Performing computations on such
datasets can be time-consuming, taking minutes, hours, or even days.
One common mistake is inserting formulas into every cell, resulting in thousands of formula
interpretations and calculations. This significantly slows down processing. To improve
performance, consider the recommendations below for speeding up calculations.
Multi-threading
Multi-threading is enabled by default to take advantage of the parallel processing power of
modern computers. While disabling multi-threading is not recommended, the setting can be
found in the CPU Threading Settings section of the Tools > Options > LibreOffice Calc >
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
vague 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.
While error messages are not intuitive, they do provide clues that can help the user to correct
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 17.
Table 17: Common error messages
Code Meaning
#NAME? Instead of displaying Err:525. No valid reference exists for the argument.
Instead of displaying Err:524. The column, row, or sheet for the referenced cell
#REF!
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 example,
#VALUE!
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 defined
#NUM!
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 and Editing 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
Examples of functions
For beginners, functions can be one of the most intimidating aspects of LibreOffice Calc. While
new users quickly recognize that functions are a key feature of spreadsheets, the sheer number
of available functions—many requiring specialized knowledge or specific inputs—can feel
overwhelming. Thankfully, Calc offers a wide range of functions that are simple and accessible,
even for novice users.
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
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.
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.
By default, regular expression searches within Calc functions are case insensitive,
irrespective of the setting of the Case sensitive checkbox. However, for some
functions regular expressions can include a flag option “(?-i)” to switch to a case
sensitive match. Functions that support this facility are: AVERAGEIF, AVERAGEIFS,
COUNTIF, COUNTIFS, HLOOKUP, LOOKUP, MATCH, SEARCH, SUMIF, SUMIFS,
and VLOOKUP.
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 13, 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.
Chapter 10
Using Pivot Tables
Introduction
Many spreadsheet support requests stem from using overly complex formulas to address
simple, everyday tasks. For a more efficient and effective approach, consider using pivot tables.
These tools simplify the process of combining, comparing, analyzing, and summarizing large
datasets.
With pivot tables, you can:
• Generate different summaries of your source data.
• Drill down into specific details of interest.
• Create detailed reports, regardless of your skill level—beginner, intermediate, or
advanced.
Additionally, pivot charts can be created from pivot tables to provide a clear graphical
representation of the data.
Database preconditions
To use a pivot table, you need a list of raw data structured like a database table, with rows
representing data sets and columns representing data fields. The field names should be in the
first row above the data.
The data source can come from an external file or database. If the data is already within a Calc
spreadsheet, simpler sorting functions may suffice without the need for a pivot table.
Tip
To make sure that Calc automatically recognizes a list correctly, check that there are
no empty rows or empty columns within the list.
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 common source of errors occurs when a list is unintentionally defined and then sorted. For
example, selecting multiple cells—such as an entire column—can result in sorting that misaligns
data that should remain together within rows.
Beyond these technical considerations, maintaining the logical structure of the list is equally
crucial.
Note
Calc lists must have the normal form; that is, they must have a simple linear
structure.
When entering data, avoid adding outlines, groups, or summaries. Here are common mistakes
often made by inexperienced spreadsheet users:
• Creating unnecessary sheets: For example, using separate sheets for each group of
items. This limits analyses to individual groups and makes cross-group analysis difficult.
• Using multiple columns for similar data: For instance, in a sales list, creating separate
columns for each employee's sales instead of a single column for all amounts. This
structure complicates data grouping and prevents effective analysis with pivot tables. To
enable proper analysis, all related data should be in the same column.
• Including summary rows in chronological data: For example, adding a total row at
the end of each month. This prevents the list from being sortable by different criteria
since pivot tables treat summary rows as regular data. Instead, use the pivot table's built-
in features to quickly generate monthly summaries.
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 12, 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 frequently use pivot tables in Calc, navigating through the built-in menu paths might feel
inconvenient.
To streamline your workflow, consider the following options:
• Built-in keyboard shortcuts: Some shortcuts are predefined, such as the F12 key,
which groups a selected data range. Refer to Appendix A, Keyboard Shortcuts, for a full
list.
• Toolbar icons: The standard toolbar includes icons for tasks like inserting or editing
pivot tables, making these actions more accessible.
Additionally, you can create custom keyboard shortcuts and toolbar icons to suit your needs. For
instructions, see Chapter 16, Setting up and Customizing.
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
The Pivot Table Layout dialog (Figure 295) organizes the resulting pivot table into four key areas:
• Filters
• Column Fields
• Row Fields
• Data Fields
Additionally, there is an Available Fields area that lists the fields from the source data. To design
the layout, simply drag fields from the Available Fields area and drop them into the desired
section.
The Data Fields area must include at least one field, though advanced users can add multiple
fields. Fields in this area use an aggregate function by default. For example, dragging the Sales
Value field into the Data Fields area will initially display it as Sum – Sales Value.
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
Expanding the options section of the Pivot Table Layout dialog reveals the following options for
working with pivot table layouts:
• Ignore empty rows
• Identify categories
• Total columns
• Total rows
• Add filter
• Enable drill to details
• Show expand/collapse buttons
Each of these options is shown in Figure 297 and described in the sections that follow.
Ignore empty rows
If the source data is not in the recommended form, this option tells the pivot table to
ignore empty rows.
Identify categories
With this option selected, if the source data has missing entries in a list and does not
meet the recommended data structure (as in Figure 298 for example), the pivot table
adds it to the listed category above it. If this option is not chosen, then the pivot table
inserts (empty).
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.
Enable drill to details
With this option enabled, if you double-click on a single data cell in the pivot table result,
including a cell produced from Total columns or Total rows, a new sheet opens giving a
detailed listing of the individual entry. If you double-click on a cell in either a row or
column field area, the Show Detail dialog opens (Figure 334). If this function is disabled,
the double-click will keep its usual edit function within a spreadsheet. For more
information, see “Drilling” below.
Show Expand / Collapse buttons
Inserts toggle buttons to field labels to make pivot tables with compact layout more
usable. Such buttons are also available if other layouts are used.
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 302: Example choices for Base field and Base item
Table 18 lists the possible types of displayed value and associated base field and base item,
together with notes on usage.
Figure 308: Division of the regions for employees (two row fields) without subtotals
Note
Before you can group, you have to produce a pivot table with ungrouped data. The
time needed for creating a pivot table depends mostly on the number of columns and
rows and not on the size of the basic data. Through grouping, you can produce the
pivot table with a small number of rows and columns. The pivot table can contain a
lot of categories, depending on your data source.
To remove grouping again, click inside the group, then choose Data > Group and Outline >
Ungroup, or press Ctrl+F12.
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 332: Arrow color change and indicator square on column heading
Note
In Calc, a cell must be fully selected (highlighted) to be moved, not just have the
cursor in it. The background of a selected cell is visibly highlighted.
To select a single cell:
Click the cell, then hold Shift and click it again.
Alternatively, click and drag across two cells, then drag back to the first cell before releasing the
mouse.
To select multiple cells:
Click one cell to select it.
Hold Shift or Ctrl and click additional cells to add them to the selection.
Sort automatically
To sort automatically, right-click within the pivot table and choose Properties. This will open the
Pivot Table Layout dialog (Figure 295). Double-click the row or column field you want to sort. In
the Data Field dialog which opens (Figure 306), click Options to display the Data Field Options
dialog (Figure 312).
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.
Drilling
Use drilling to show the related detailed data for a single, compressed value in the pivot table
result. This facility is available only if you selected the Enable drill to details option on the Pivot
Table Layout dialog.
To activate a drill, double-click on the cell or choose Data > Group and Outline > Show
Details. There are two possibilities:
1) The active cell is a row or column field. In this case, drill means an additional breakdown
into the categories of another field. For example, double-click on the cell with the value
Golf. In this instance, the values that are aggregated within Golf can be subdivided using
another field.
Figure 336: 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.
Note
The Filter button is available only if the Add filter option on the Pivot Table Layout
dialog is selected.
Figure 337: Filter button in the upper left area of the pivot table
In the Filter dialog (Figure 338), 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 and Editing
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 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. The
customizable pivot table styles include:
• Pivot Table Category
• Pivot Table Corner
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.
Calc applies the number format from the source list to the data field in the pivot table. For
example, if the source values are in currency format, the corresponding cells in the pivot table
will also use the currency format.
However, this can cause issues if the result is a fraction or percentage, as the pivot table doesn’t
automatically adjust the format. Such results should either have no unit or be displayed as
percentages. While you can manually fix the number format, the changes will reset after the
pivot table is updated.
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 341: The value that you really want to use is 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.
Pivot charts
A pivot chart provides a visual representation of the information in a pivot table. You can create a
pivot chart from the output of a pivot table and, if the pivot table gets changed, so does the pivot
chart.
Pivot charts are a special case of the more general Calc charts described in Chapter 3, Creating
Charts and Graphs. The main differences between pivot charts and other charts in Calc are as
follows:
• A pivot chart tracks the changes in the data issued from a pivot table and Calc
automatically adjusts the data series and data range of the pivot chart accordingly.
• Pivot charts include special buttons not found on Calc’s standard charts. These buttons
represent the layout and fields of the underlying pivot table:
– Filter field buttons: Displayed at the top of the pivot chart.
– Row field buttons: Shown at the bottom of the pivot chart.
– Column field buttons: Stacked in the legend on the right side of the chart.
These buttons also allow you to filter the data displayed in the pivot chart.
Figure 345: 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 346).
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 11
Data Analysis
Using Scenarios, Goal Seek, Solver, Statistics, others
Introduction
Once you are familiar with functions and formulas described in the previous chapter, the next
step is to learn how to use Calc’s automated processes to quickly perform useful analysis of your
data.
Besides formulas and functions, Calc offers various tools for data processing. These tools
include features for copying and reusing data, creating subtotals, conducting what-if analysis,
and performing statistical analysis. You can find them under the Tools and Data menus on the
Menu bar. While not essential for using Calc, these tools can save you time and effort when
managing large data sets or preserving your work for future review.
Note
A related tool, the Pivot Table, is not discussed here due to its complexity, which
warrants a dedicated chapter. For more information, refer to Chapter 10, Using Pivot
Tables.
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
348).
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 14, Calc as a Database.
Consolidation settings
In the Consolidate dialog, expand the Options section to access the settings shown in Figure
349.
Consolidation example
Figures 350, 351, and 352 show a simple example of consolidation using a spreadsheet with the
sheets Year 1, Year 2, and Consolidated Sales. Figure 350 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
353. 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 and Editing
Data.
Figure 353: 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 354):
– 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 and Editing
Data. Filtered-out cells are always excluded by the SUBTOTAL function.
Table 19: SUBTOTAL function numbers
Function index Function index
Function
(includes hidden values) (ignores hidden values)
1 101 AVERAGE
2 102 COUNT
3 103 COUNTA
4 104 MAX
5 105 MIN
6 106 PRODUCT
7 107 STDEV
5) Click on the Range field, then type a reference to the Sales Value range or select the
cells with your mouse (Figure 354). 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 355).
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.
Subtotal outline
When you use the Subtotals tool, Calc inserts an outline to the left of the row number column.
This outline represents the hierarchical structure of your subtotals, and can hide or show data at
different levels in the hierarchy using the numbered column indicators at the top of the outline or
the group indicators, denoted by plus (+) and minus (-) signs.
This feature is useful if you have many subtotals, as you can simply hide low-level details, such
as individual entries, to produce a high-level summary of your data. For more information on how
to use outlines, see Chapter 2, Entering and Editing Data.
Figure 357: 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:
• Column 2 represents the grand total over all categories.
• Column 3 represents the total for each employee.
• Column 4 represents the total for each category for an individual employee.
• Column 5 shows individual entries.
Using scenarios
Scenarios are cell ranges that have been saved and named. They can be used 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.
Tip
When naming a new scenario, use a unique name that clearly identifies and
distinguishes it from other scenarios. The default name suggested by Calc may not
be the best choice, especially if you have a large set of scenarios.
4) Optionally, add information to the Comment field. The example in Figure 359 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 which calculations are dependent on your scenarios, use Tools >
Detective > Trace Dependents on the Menu bar after highlighting your scenario
cells. For more information about the Detective tool, see Chapter 8, Using Formulas
and Functions.
Scenario settings
The Settings section of the Create Scenario dialog (Figure 360) 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.
Copy entire sheet
Creates a copy of the sheet with the new active scenario. The sheet is named after this
scenario. Note that changing scenario values in the copy sheet will not affect the active
scenario, even if it has Copy back enabled.
Prevent changes
Prevents changes to a scenario with Copy back enabled when the sheet is protected but
the cells are not. Also prevents changes to the scenario’s settings while the sheet is
protected. This option and its effects are more fully explained in the next section.
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 365: Results of Multiple Operations tool for one formula and one variable
6) Using the Column input cell field, select the cell B4 to set the quantity as the variable for
our calculations. Figure 364 shows the worksheet and Multiple Operations dialog at this
point.
Figure 366: XY (Scatter) plot of profit over quantity of toys sold (visualization example)
Note
The Multiple Operations tool only accepts formulas arranged in a single row or
column, depending on how your results table is oriented. If the table is column-
oriented – that is, the way it is in our sales data example – then your formulas must
be arranged in a row. If the table is row-oriented, then your formulas must be in a
column.
Caution
Be careful not to add empty cells between formulas, as they will create gaps in the
results table and may cause some results not to appear if you don't select enough
rows or columns for the table.
Figure 367: Inputs to Multiple Operations tool for one variable and two formulas
7) Click OK. Now the profits are listed in column E and the annual profit per item in column
F.
Figure 368: Results of Multiple Operations tool for one variable and two formulas
Tip
Since column headings are in a row at the top of the table, they correspond to the
Row input cell field. Likewise, row headings are in a column, so they correspond to
the Column input cell field.
Note
If you use two variables, the Multiple Operations tool will not work with multiple
formulas. It will allow you to enter the extra formulas, but will not generate the
expected results for any formula beyond the first.
Note
Only one argument can be altered at a time in a single goal seek. If you need to test
multiple arguments, then you must run a separate goal seek on each one.
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.
Caution
As the LibreOffice Swarm Non-Linear Solver is an experimental tool, it may not be
supported in future versions of Calc, and we recommend that you do not use it
unless you are familiar with non-linear programming concepts.
The DEPS and SCO Evolutionary Algorithms are designed for solving non-linear problems. To
use them, you must have a Java runtime environment installed on your computer and enable the
Tools > Options > LibreOffice > Advanced > Use a Java runtime environment setting. If
available, the DEPS Evolutionary Algorithm is the default solver; otherwise, the LibreOffice
CoinMP Linear Solver is used by default.
These options offer flexibility, allowing you to select the algorithm that best fits your specific
problem—whether linear or non-linear—and your performance needs. For more detailed
information on the available algorithms and their configuration, refer to the Help system.
Note
Calc saves solver settings to the ODS file and each tab can have its own model. To
support interoperability, the mechanism to save/load solver configurations is
compatible with Microsoft Excel.
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 375).
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.
– Operator – defines a parameter for a constraint. Available options include <= (less
than or equal to), = (equal to), => (greater than or equal to), Integer (values without
decimals), and Binary (only 0 or 1).
– Value – enter a value or a cell reference to a constraint formula.
– Remove button – deletes the currently-defined constraint.
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.
After setting up the Solver, click the Solve button to begin adjusting values and calculating
results. Depending on the complexity of the problem, this process may take some time. To
restart, click the Reset All button, which clears the data entered in the Solver dialog (Figure
375).
If you are using the DEPS or SCO Evolutionary Algorithm, Calc may occasionally pause the
solver engine to display the Solver Status dialog (Figure 376). This dialog provides diagnostic
information about the engine’s current progress, which can be useful for advanced users. Click
OK to close the dialog and complete the calculations, or click Continue to process one more
step, with updated diagnostic information appearing at the next pause. By default, the Solver
Status dialog is enabled, but you can disable it by unchecking the Show enhanced solver
status option in the Solver Options dialog.
Solver options
Sampling tool
Selecting Data > Statistics > Sampling on the menu bar opens the Sampling dialog shown in
Figure 34. The Sampling tool creates a target table with data sampled from a source table. It can
pick samples randomly or periodically. Sampling is done by rows, with whole rows of the source
table copied into rows of the target table.
Tip
The Shrink / Expand buttons in the upper-right corner of the dialog may be used to
shrink the dialog using the mouse.
Figure 383 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 382.
Tip
For more information on descriptive statistics, refer to the corresponding Wikipedia
article at https://en.wikipedia.org/wiki/Descriptive_statistics.
Tip
For more information on analysis of variance, refer to the corresponding Wikipedia
article at https://en.wikipedia.org/wiki/Analysis_of_variance.
Tip
For more information on statistical correlation, refer to the corresponding Wikipedia
article at https://en.wikipedia.org/wiki/Correlation_and_dependence.
Covariance tool
Selecting Data > Statistics > Covariance on the Menu bar opens the Covariance dialog (Figure
391).This tool measures how much two sets of numeric data vary together.
Tip
For more information on statistical covariance, refer to the corresponding Wikipedia
article at https://en.wikipedia.org/wiki/Covariance.
Tip
For more information on exponential smoothing, refer to the corresponding Wikipedia
article at https://en.wikipedia.org/wiki/Exponential_smoothing.
Tip
For more information on the moving average, refer to the corresponding Wikipedia
article at https://en.wikipedia.org/wiki/Moving_average.
Regression tool
Selecting Data > Statistics > Regression on the Menu bar opens the Regression dialog (Figure
398).This tool performs linear, logarithmic, or power regression analysis of a data set comprising
one dependent variable and multiple independent variables.
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 a valid cell range has not
been entered in the Independent variable(s) (X) range field. In this circumstance, the
OK button is disabled until the error is corrected.
To illustrate how to use this tool, we use the data set shown in Figure 399. This table contains
measurements taken at 1 second intervals. Figure 400 shows the regression outputs calculated
for this input data using the settings shown in Figure 398.
F-test tool
Clicking Data > Statistics > F-test on the Menu bar opens the F-test dialog shown in Figure 404
and define the required inputs to the tool.This tool calculates the F-test of two data samples to
test the hypothesis that the variance of two populations are equal.
Tip
For more information on F-tests, refer to the corresponding Wikipedia article at
https://en.wikipedia.org/wiki/F-test.
Z-test tool
Clicking Data > Statistics > Z-test on the Menu bar opens the Z-test dialog shown in Figure 406
and define the required inputs to the tool.This tool calculates the Z-test of two data samples. It
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 than the Paired t-test tool for large samples
(n > 30).
Variable 1 range
Specifies the cell range containing the first set of input data.
Variable 2 range
Specifies the cell range containing the second set of input data.
Results to
Specifies the top left cell of the results area. When you run the tool, it will generate the Z-
test table starting at this cell. Be careful, Calc will replace any data that is in the range of
the table to be created.
Columns / Rows
Specifies whether the data to be analyzed is organized in columns or rows.
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 chi-square tests, refer to the corresponding Wikipedia article
at https://en.wikipedia.org/wiki/Chi-squared_test.
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 a valid cell range has not been entered
in the Results to field. In this circumstance, the OK button is disabled until the error is
corrected.
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 411. 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 410.
Note
The Fourier Analysis tool uses different algorithms depending on the length of the
input sequence. If the sequence length is an even power of 2, a radix-2 decimation-
in-time FFT algorithm is applied. For sequences of other lengths, Bluestein’s FFT
algorithm is used. This detail may be of interest to those with a technical background
in algorithms.
Tip
For more information on Fourier analysis, refer to the corresponding Wikipedia article
at https://en.wikipedia.org/wiki/Fourier_analysis.
Chapter 12
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
412).
Figure 413: Creating a new sheet through the sheet tabs area
The above methods use either the Insert Sheet dialog (Figure 414) or the Append Sheet dialog
(Figure 415).
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).
The From file option is described in “Inserting sheets from a different spreadsheet” below.
Figure 416: From file area of Insert Sheet dialog, with file path and available sheet names
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” (below). 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 143, 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.
• Double-click on the relevant sheet tab and replace the existing name through the
Rename Sheet dialog (Figure 417).
• Right-click on the relevant sheet tab, select Rename Sheet in the context menu, and
replace the existing name through the Rename Sheet dialog.
• Left-click on the relevant sheet tab to select it, select Sheet > Rename Sheet on the
Menu bar, and replace the existing name through the Rename Sheet dialog.
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.
Your sheet tab area should now look like this.
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 425).
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:
• Select the cell or text within a cell that you want to use for your hyperlink text, or place
the text cursor at the point where you want to insert a hyperlink. 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” below.
• 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://, ftp or www.; 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 429) or a button hyperlink (Figure 430). 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 the Writer Guide.
Opening hyperlinks
To open a text hyperlink, do one of the following:
• Ctrl-click with the mouse pointer 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 mouse pointer 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 mouse pointer 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 431). 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 web address or Uniform Resource Locator (URL).
• Mail. The hyperlink points to an email address.
• Document. The hyperlink points to a location in either the current document or another
existing document.
• New Document. Opening the hyperlink creates a new document.
Editing hyperlinks
To edit an existing text hyperlink, do any of the following:
• If the Tools > Options > LibreOffice > Security > Security Options and Warnings >
Options > Ctrl-click required to open hyperlinks option is selected, then click the cell
containing the hyperlink. Select Insert > Hyperlink on the Menu bar, or click the Insert
Hyperlink icon on the Standard toolbar, or press Ctrl+K.
• Select the cell containing the hyperlink. In some cases you may need to select a nearby
cell that does not contain a hyperlink and use the arrow keys to move the selection to the
hyperlink cell. Select Insert > Hyperlink on the Menu bar, or click the Insert Hyperlink
icon on the Standard toolbar, or press Ctrl+K.
• Right-click on the hyperlink and select the Edit Hyperlink option in the context menu.
In all cases, Calc opens the Hyperlink dialog, where you can modify the characteristics of the
hyperlink.
For a button hyperlink, the spreadsheet must have the form design mode enabled in order to edit
the hyperlink. With the button selected, select Insert > Hyperlink on the Menu bar, or click the
Insert Hyperlink icon on the Standard toolbar, or press Ctrl+K. Make your changes and click
OK.
If you need to edit several hyperlinks, you can leave the Hyperlink dialog open until you have
edited all of them. Be sure to click Apply after each one. When you are finished, click Close.
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.
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 440). If you double-click
this entry, Calc highlights the linked data within the sheet. When you hover the mouse pointer
over the entry, a tooltip indicates the file location of the linked data.
To view a list of all external data links in the spreadsheet, select Edit > Links to External Files
on the Menu bar. Calc displays the Edit Links dialog (Figure 439).
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.
Tip
The graphic on the Drag Mode icon on the Navigator changes to reflect the currently
selected drag mode.
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.
To register a data source that is not in *.odb format:
1) Choose File > New > Database on the Menu bar to open the Database Wizard (Figure
448). For more about the Database Wizard, see the Base Handbook.
2) Select Connect to an existing database and select the appropriate database type in
the drop-down menu. The choices for database type depend on your operating system.
For example, Microsoft Access and other Microsoft products are not among the choices if
you are using Linux. The example database type menu shown in Figure 448 relates to a
Windows 10 installation.
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.
Figure 453: Insert OLE Object dialog with Create new option selected
After clicking outside the spreadsheet area, double-click on the OLE object to re-enter the edit
mode of the object. The application devoted to handling that type of file (Calc in our example) will
open the object.
To save the inserted spreadsheet:
1) Click anywhere outside the spreadsheet to leave the edit mode.
2) Right-click on the spreadsheet and select Save Copy as in the context menu or select
Edit > Object > Save Copy as on the Menu bar.
3) Choose the name of the new file and the folder in which it will be saved.
4) Click the Save button.
Note
If the object inserted is handled by LibreOffice, then the transition to the program to
manipulate the object will be seamless; in other cases the object opens in a new
Note
This facility is not limited to LibreOffice files; you can create OLE objects using
existing files from many other applications.
Figure 454: Insert OLE Object dialog with Create from file option selected
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.
Figure 459: Paste Special dialog in Writer, with DDE link selected
XML Source
The XML Source feature allows a user to import data from arbitrarily structured XML content into
cells in an existing spreadsheet document. It allows XML content to be imported either partially
or in full, depending on the structure of the XML content and the map definitions that the user
defines. The user can specify multiple non-overlapping sub-structures to be mapped to different
cell positions within the same document, and can select to import either element contents,
attribute values, or both.
Note:
The XML Source feature currently allows you to import XML data as a one-time
event; it will not store the information about the data source once the data is
imported.
Suppose that you have sales data in an XML file, such as the following:
<sales>
<sale>
<date>01/19/08</date>
<value>$2,032</value>
<category>Golf</category>
<region>West</region>
Chapter 13
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 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.
To enable sharing, select the checkbox at the top of the dialog (Figure 463) and click OK. If the
spreadsheet has been saved previously, a message appears stating that you must save it to
• If the changes conflict, the Resolve Conflicts dialog (Figure 464) 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” below.
• You can save versions that are stored as part of the original file. See “Saving versions”
below.
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 465). A deleted column or row is marked by a heavy colored bar.
To see the changed information, hover the mouse pointer over the changed cell. See Figure 466.
Note
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” below) and do not appear in the Manage Changes dialog.
After you have added a comment to a changed cell, you can see the change and the comment
by hovering the mouse pointer over the cell, as shown in Figure 468.
The comment also appears on the Manage Changes dialog when you are accepting and
rejecting changes, as shown in the first line of Figure 472 on page 448.
3) Type your comment in the box, then click outside the box to close it.
Now the cell to which you added the comment has a colored triangle in the upper right-hand
corner, as shown in Figure 470. It does not have a colored border, unless the cell also has a
change comment.
Note
If you hover the mouse pointer 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.
On the Filter tab of the Manage Changes dialog (Figure 473), you can choose how to filter the
list of changes: by date, author, cell range, or comments containing specific terms. After
selecting the filter criteria, switch back to the List tab to see the results. Filtering the changes
affects only the contents of the List tab on the dialog, you will not see any filtered results in your
spreadsheet.
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.
2) Click the Save New Version button to save a new version. The Insert Version Comment
dialog (Figure 475) opens where you can enter comments about this version.
Chapter 14
Macros
Automating repetitive tasks
Introduction
Chapter Getting Started with Macros of the Getting Started Guide 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.
5) Use File > New > Spreadsheet on the Menu bar to create a new spreadsheet.
6) Enter the numbers shown in Figure 477 into cells A1:C3 of Sheet1 in the new
spreadsheet.
13) Select the entry for the current document in the Save Macro In area. As the current
document in this example has not been saved, it is referred to by its default name
Untitled 1.
14) Documents that have been saved include a macro library named Standard. This library is
not created until the document is saved or the library is needed, so at this point in the
example procedure your new document does not contain a library. You can create a new
library to contain the macro you have just created, but this is not necessary.
15) Click the New Module button. Calc displays the New Module dialog (Figure 482). Type a
name for the new module or leave the name as the default Module1.
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)
16) 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.
17) 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 483).
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.
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.
2) 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.
Listing 2. Function that returns the value 5
1|' ***** BASIC *****
2|Option Explicit
3|Sub Main
4|
5|End Sub
Tip
Function names are not case sensitive. In Figure 489, the function name was
entered as NumberFive but Calc displays it as NUMBERFIVE in the Formula bar.
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
1|Function TestMax(x, y)
2| If x >= y Then
3| TestMax = x
4| Else
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.
Use oSheet.getCellRangeByName("A2") to return a range of cells by name. If a single cell is
referenced, then a cell object is returned. If a cell range is given, then an entire range of cells is
Tip
When a macro is called as a Calc function, the macro cannot modify any value in the
sheet from which the macro was called, except the value of the cell that contains the
function.
Sorting
Consider sorting the data shown in Figure 496. First, sort on column B descending and then on
column A ascending.
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 498).
JavaScript macros
JavaScript is a high-level scripting language that was first released in 1995.
When you select Tools > Macros > Organize Macros > JavaScript on the Menu bar, Calc
displays the JavaScript Macros dialog (Figure 500).
Note
You cannot edit JavaScript macros inside LibreOffice. You must edit the macro on an
external editor.
Listing 11 is an example of a JavaScript macro that inserts the text “Hello World from JavaScript”
in cell A1 of the first sheet in a Calc spreadsheet.
Listing 11. Sample JavaScript macro
1|importClass(Packages.com.sun.star.uno.UnoRuntime);
2|importClass(Packages.com.sun.star.sheet.XSpreadsheetDocument);
3|importClass(Packages.com.sun.star.container.XIndexAccess);
4|importClass(Packages.com.sun.star.table.XCellRange);
5|importClass(Packages.com.sun.star.table.XCell);
6|
7|documentRef = XSCRIPTCONTEXT.getDocument();
8|
9|spreadsheetInterface = UnoRuntime.queryInterface(XSpreadsheetDocument,
documentRef);
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 501).
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 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
1|Option VBASupport 1
2|Sub Example
3| Dim sVar As Single
4| sVar = Worksheets("Sheet1").Range("A1")
5| Print sVar
6|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
1|Sub Example
2| Dim sVar As Single
3| Dim oSheet as Object
4| Dim oCell as Object
5| ' Worksheets(“Sheet1”).
6| oSheet = ThisComponent.getSheets().getByIndex(0)
7| ' Range("A1")
8| oCell = oSheet.getCellByPosition(0, 0)
9| sVar = oCell.getValue()
10| Print sVar
11|End Sub
Option VBASupport may affect or assist in the following situations:
• Allow special characters as identifiers. All characters that are defined as letters in the
Latin-1 (ISO 8859-1) character set, are accepted as part of identifiers. For example,
variables with accented characters in their names.
• Create VBA constants including non-printable characters (vbCrLf, vbNewLine,...).
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
(https://wiki.documentfoundation.org/Macros) and other Internet sources (for example the
https://ask.libreoffice.org/ Q&A site).
Chapter 15
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 504). In this sheet, each row represents individual students taking the class, while each
column contains their names and grades. With this table, you can quickly look up individual
students’ grades simply by searching for their names, and you can determine which students are
passing the class by filtering out records with failing average scores.
Named ranges
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 505), 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 506).
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 509).
Note
When saving as an .xlsx file in Excel, "structured references" are retained. However,
in Calc, the ODF standard does not yet have the means to save "structured
references". When saving as an .ods file, a "structured reference" is converted into a
direct reference using the values present at the time of saving.
Setting up a table
Spreadsheet "tables" are defined by database ranges (Data > Define Range). See Database
ranges above. In addition to the name of the database, the following is mandatory for using
"structured references":
• Tables must be vertically oriented.
• Tables must have column labels, if interoperability with Excel is required.
• The column label names must follow the named range rules. See Named ranges above.
The table below contains values used in examples later on in this document.
A B C D
1 Name Region Sales Seniority
2 Smith West 21 5
3 Jones East 23 11
4 Johnson East 9 7
5 Taylor West 34 11
6 Brown East 23 15
7 Walker East 12 4
8 Edwards East 15 12
9 Thomas West 17 10
10 Wilson West 31 3
11 Totals 2 185 8.67
The cell range A1:D11 was defined as database range "myData". The options Contains column
labels and Contains totals row were checked when defining the database range (Figure 509).
Note
The intersection is only possible with rows of the database range. A similar This
Column does not exist. If a database row does not exist in the row where the formula
is placed, a #VALUE! error is generated.
Tip
When switching from Excel to Calc, Excel does not allow the keyword [#This Row]
for the entire table range. If applied to non-data record rows, such as header or totals
rows, an error is produced.
In the user interface, Excel uses the short form myData[@]. This implicit intersection operator @
is not currently available in Calc.
Combinations
To reference a combination of the labels row and data records, use the format [#Headers];
[#Data] or [#Headers],[#Data], where the separator is the same separator as for function
parameters. So whether to use a semicolon or a comma depends on the setting defined in Tools
> Options > Calc > Formula.
To reference a combination of data records and totals row, use [#Data];[#Totals]. For
example, myData[[#Data];[#Totals]] references the cells A2:D11.
A combination like [#Headers];[#Totals] is not possible as that would result in two disjoint
cell rectangles.
To address several adjacent columns, use the range operator “:”. For example, the formula
myData[[Name]:[Sales]] addresses the cells A2:C10.
The use of non-adjacent columns is not possible since it would reference two separate cell
rectangles.
The reference via field name and the use of a reference keyword can be combined, first the
keyword, then function separator and last the field name in brackets. For example,
myData[[#Totals];[Sales]] references the cell C11.
Note
Instead of using the formula =myData. which will copy the entire database range in
LibreOffice and then produce an error when opened in Excel, use the formula
=myData[#All].
The output array or value of a structured reference can be used as input to other functions. For
example, the cells in row 11 have these formulas:
B11 =COUNTA(UNIQUE(myData[Region]))
C11 =SUM(myData[Sales])
D11 =AVERAGE(myData[Seniority])
If a formula uses a structured reference and it references an array of more than one cell, then
the formula has to be handled as array formula that has enclosing curly brackets in the input line
like {=myData[#Headers]}.
Sorting
Sorting is the process of rearranging data in a range or a sheet according to a specified sort
order.
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. 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.
Each AutoFilter combo box (Figure 512) provides the following options:
• A basic sort can be applied using the Sort Ascending and Sort Descending options.
• Use the Sort by Color menu to sort entries by background or font color, based on any
such color that appears in the column of interest.
• Use the Filter by Color menu to filter entries by background or font color for any such
color that appears in the column of interest.
• The Filter by Conditions menu provides Empty, Not Empty, Top 10, and Bottom 10
filter options. In addition the menu contains a menu item to access the Standard Filter
dialog (Figure 513).
• 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 512).
• If any filter has been applied to a column, use the Clear Filter option to remove all filters
defined for that column.
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 513), 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 and
Editing 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 514).
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.
Note
For an individual named range, it is possible to tick a Filter checkbox on the Define
Name and Manage Names dialogs (Figures 505 and 506 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 and Editing Data.
Figure 515 demonstrates an example criteria range for the grading sheet example in Figure 504.
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
Note
Calc will treat dates and logical values (such as TRUE or FALSE) as numeric when
calculating with these functions.
DAVERAGE
For all rows (database records) that match the specified search criteria, DAVERAGE
calculates the average of the numeric values in the cells (fields) of the specified column.
Non-numeric values in those cells are ignored.
Returns a #DIV/0! error if no records match the specified search criteria, or if there are
no numeric values in the cells of the specified column for the matching records.
Syntax: DAVERAGE(Database; DatabaseField; SearchCriteria)
DCOUNT
For all rows (database records) that match the specified search criteria, DCOUNT counts
the number of cells (fields) of the specified column that contain numeric values. However,
if no column is specified, DCOUNT returns the count of all records that match the
specified search criteria irrespective of their contents.
Syntax: DCOUNT(Database; [DatabaseField]; SearchCriteria)
DCOUNTA
For all rows (database records) that match the specified search criteria, DCOUNTA
counts the number of cells (fields) of the specified column that are not blank. Blank cells
of the specified column are not counted. However, if no column is specified, DCOUNTA
returns the count of all records that match the specified search criteria irrespective of
their contents.
Syntax: DCOUNTA(Database; [DatabaseField]; SearchCriteria)
DGET
For the single row (database record) that matches the specified search criteria, DGET
returns the contents of the cell (field) of the specified column.
Calc reports Err:502 (invalid argument) if multiple matches are found, or a #VALUE! error
(wrong data type) if no matches are found. A #VALUE! error is also reported if a single
match is found but the relevant cell is empty.
Syntax: DGET(Database; DatabaseField; SearchCriteria)
DMAX
For all rows (database records) that match the specified search criteria, DMAX calculates
the maximum value across the cells (fields) of the specified column that contain numeric
values. Blank cells or cells containing non-numeric characters are not included.
Returns 0 if no matches are found, or if there are no non-zero numeric values in the cells
of the specified column for the matching records.
Syntax: DMAX(Database; DatabaseField; SearchCriteria)
DMIN
For all rows (database records) that match the specified search criteria, DMIN calculates
the minimum value across the cells (fields) of the specified column that contain numeric
values. Blank cells or cells containing non-numeric characters are not included.
Returns 0 if no matches are found, or if there are no non-zero numeric values in the cells
of the specified column for the matching records.
Chapter 16
Setting up and Customizing
Introduction
This chapter presents some, but not all, of the setup options found under Tools > Options on
the Menu bar (LibreOffice > Preferences on macOS). Information about options not covered in
this chapter are covered in the Help and in the Getting Started Guide.
This chapter does explain how to customize menus, toolbars, and keyboard shortcuts.
Application extensions available from the LibreOffice website and other providers can simplify
the customization process.
Utilizing the “Type to search” function under Tools > Options on the Menu bar is useful for
finding a particular option to customize. When typing in this field, Calc automatically hides the
options in the tree that do not match the entered keywords.
LibreOffice options
The settings described in this section apply to all components of LibreOffice and are of particular
interest to users of Calc. To access the options:
1) Choose Tools > Options to open the Options dialog. The dynamic list on the left-hand
side only displays options applicable to open applications. 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 to reveal the list of
subsections.
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.
Warning
Keep this option selected!
Otherwise you will not be able to decrypt documents you've encrypted for other
people.
General
Set preferences for Help, Open/Save, File Associations, and more. You can also disable the tip
of the day popups here.
View
View settings affect how the document window looks and behaves. Users can change the size
and style of toolbar and sidebar icons, among other settings.
Print
The print options may be set 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 using the Print dialog. Calc-specific print options are described in “Print options” below.
See Chapter 8, Printing, Exporting, Emailing, and Signing, for more about these options.
Paths
The paths options can be used to change the location of files associated with, or used by,
LibreOffice. 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).
You could, for example, change the default path to a shared server instead of your PC.
Figure 519: Choosing security options for opening and saving documents
Macro Security
Click the Macro Security button to open the Macro Security dialog, where you can
adjust the security level for executing macros and specify trusted sources.
Certificate Path
Users can digitally sign documents using LibreOffice. A digital signature requires a
personal signing certificate. Most operating systems can generate a self-signed
certificate. However, a personal certificate issued by an outside agency (after verifying an
individual’s identity) has a higher degree of trust associated with it than a self-signed
certificate. LibreOffice does not provide a secure method of storing these certificates, but
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.
TSAs –Time Stamping Authorities
Allows you to select a Time Stamping Authority (TSA) URL for PDF documents created
by LibreOffice. Adding a trusted timestamp to an electronic signature on a PDF provides
a digital seal of data integrity and a trusted date and time of when the file was signed.
Recipients of PDF documents with a trusted timestamp can verify when the document
was digitally or electronically signed, as well as verify that the document was not altered
after the date the timestamp vouches for.
GPG Certificate Manager
Select your preferred GPG certificate manager. Note that LibreOffice tries to locate
installed ones automatically. Press the Browse button to locate the certificate manager
executable in your system.
Application colors
On the LibreOffice – Application Colors page (Figure 521), 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.
General
Many of the choices on the Load/Save – General page (Figure 522) 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.
Note
The Save AutoRecovery information every and Always create backup copy
options are enabled by default. Also by default, backup copies accumulate in the
folder specified by going to Tools > Options > LibreOffice > Paths, but this can be
changed by selecting the Place backup in same folder as document option.
VBA Properties
On the Load/Save – VBA Properties page (Figure 523), you can choose whether to keep any
VBA (Visual Basic for Applications) macros in Microsoft Office documents that are opened in
LibreOffice.
Microsoft Office
On the Load/Save – Microsoft Office page (Figure 524), 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 525) affect how LibreOffice
imports or exports HTML pages. See 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 526).
General
The choices on the LibreOffice Calc – General page (Figure 527) 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.
View
The options on the LibreOffice Calc – View page (Figure 529) affect the way the document
window looks and behaves when viewed onscreen.
Display section
Select various options for the display.
Formulas
Display the content of a cell either as a formula or as the result of that formula.
Zero values
Display a zero in a cell when the cell has a value of zero, or display as a blank cell.
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 and Editing Data.
Note
To print grid lines, choose Format > Page Style > Sheet > Print > Grid.
Pointer
When the mouse pointer lies over the grid of cells on a Calc spreadsheet, the default
pointer (“System”) is normally shown, typically as an arrow pointer. However, an
alternative pointer (“Themed”) is available to allow you to switch to using the pointer
shape defined in the icon theme (typically a “fat” cross, Figure 532).
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 534) to define the calculation settings for
spreadsheets.
Date section
Select the start date for the internal conversion from days to numbers.
12/30/1899 (default) – Sets December 30, 1899 as day zero.
01/01/1900 (StarCalc 1.0) – Sets January 1, 1900 as day zero. Use this setting for
StarCalc 1.0 spreadsheets containing date entries.
01/01/1904 – Sets January 1, 1904 as day zero. Use this setting for spreadsheets that
are imported from foreign formats.
Formula
Use the LibreOffice Calc – Formula page (Figure 535) to specify the following formula options.
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.
Separators
Separators are used in functions to distinguish points in the range used in the function:
the symbols used between elements. Enter the separator character to be used for
functions, row arrays, and column arrays. For example, a comma can be used as a
separator in functions and instead of writing =SUM(A1;B1;C1) the function would be
expressed as =SUM(A1,B1,C1).
Sort lists
View, define, delete, and edit sort lists on the LibreOffice Calc – Sort Lists page. Sort lists are
utilized for various purposes beyond just sorting, such as populating a series of cells during data
entry. These lists are organized in a specific sequence, but not necessarily in alphabetical or
numerical order; for instance, the days of the week. Besides the provided lists, you have the
option to create and modify your own lists, as detailed in Chapter 2, Entering and Editing 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
Key Bindings
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.
Hyperlinks
Calc can insert multiple hyperlinks in a cell as text fields, but multiple hyperlinks in a cell
cannot be saved to Excel file formats. This option prevents inserting multiple hyperlinks
in a cell when Excel files are edited, in order to be interoperable with Excel.
Grid options
The LibreOffice Calc – Grid page defines the grid settings for spreadsheets. Using a grid helps
determine the exact position of any charts or other objects you may add to a spreadsheet. You
can also set this grid in line with the snap grid.
If you have activated the snap grid but wish to move or create individual objects without snap
positions, press the Ctrl key to deactivate the snap grid for as long as needed.
Grid section
Snap to grid activates the snap function.
Visible grid displays grid points on the screen. These points are not printed.
Resolution and Subdivision sections
Here you can set the unit of distance for the spacing between horizontal and vertical grid
points and subdivisions (intermediate points) of the grid.
Synchronize axes changes the current grid settings symmetrically.
Print options
Use the LibreOffice Calc – Print page to choose defaults for printing spreadsheets. You can
override these for individual print jobs.
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 541) 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 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 546), 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 17, User Interface Variants.
Keyboard shortcuts
Along with utilizing the built-in keyboard shortcuts (found in Appendix A), you have the ability to
create your own. You can assign shortcuts to standard LibreOffice functions or your custom
macros, and save them for use across the entire LibreOffice suite or exclusively 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.
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 > Extensions 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 Extensions 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 Extensions dialog.
Updating extensions
Click the Check for Updates button on the Extensions 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 Languages and Locales > 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.
Note
User-defined theme color sets are saved only in the document; to use them in other
documents, you need to make a template.
Themes enhance compatibility with Microsoft Word. However, they are not yet part of
the ODF (OpenDocument Format), so you need to save to ODF 1.3 Extended to use
them.
Chapter 17
User Interface Variants
Introduction
By default, LibreOffice’s commands are grouped in cascading menus and in toolbars filled with
icons. 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 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.
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
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
toolbar is displayed, or if a drawing object is selected then the Drawing Object Properties toolbar
is displayed.
Figure 556 shows an example of the default Contextual Single interface when an image is
selected, with the context-sensitive Image toolbar shown and hidden automatically.
Tabbed interface
Introduction
The Tabbed interface (Figure 557) 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
558).
1 Icon bar 2 Active tab 3 Tab bar 4 Icons on active tab 5 Tab menus 6 Quick menu
Figure 557: 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 15, Setting up and
Icon bar
The Icon bar (Figure 558) is located at the top left of the tabs.
Quick menu
To the right of the tabs is a Quick menu (Figure 559) 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.
File tab
Figure 560 shows the File tab and Figure 561 shows the additional options that are presented
when the >> icon is pressed.
Home tab
Figure 563 shows the Home tab and Figure 564 shows the additional options that are presented
when the >> icon is pressed.
Insert tab
Figure 566 shows the Insert tab and Figure 567 shows the additional options that are presented
when the >> icon is pressed.
Layout tab
Figure 569 shows the Layout tab and Figure 570 shows the additional options that are presented
when the >> icon is pressed.
Data tab
Figure 572 shows the Data tab and Figure 573 shows the additional options that are presented
when the >> icon is pressed.
Review tab
Figure 575 shows the Review tab and Figure 576 shows the additional options that are
presented when the >> icon is pressed.
View tab
Figure 578 shows the View tab and Figure 579 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 581).
Tools tab
Figure 582 shows the Tools tab and Figure 583 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 585 shows the Draw tab and Figure 586 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 588 shows the Form tab, which is displayed when a form component is selected in design
mode.
Image tab
Figure 590 shows the Image tab and Figure 591 shows the additional options that are presented
when the >> icon is pressed. The Image tab is displayed when an image is selected.
Media tab
Figure 593 shows the Media tab, which is displayed a media object is selected.
Object tab
Figure 595 shows the Object tab, which is displayed when an object (for example, an OLE
object) is selected.
Print tab
Figure 597 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 16, 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 568 (Windows / Linux) and 576 (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.
Note
Many of the keyboard shortcuts in this section use the Ctrl key. Some keyboards
have two Ctrl keys and in that case you may need to experiment to identify which of
the two keys to use.
Table 25: 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.
Ctrl+Shift+2 Format > Number Format > Scientific (use the “2” key on the main
keyboard).
Format > Number Format > Date (use the “3” key on the main
Ctrl+Shift+3 keyboard).
Format as Date icon on the Formatting toolbar.
Format > Number Format > Currency (use the “4” key on the main
Ctrl+Shift+4 keyboard).
Format as Currency icon on the Formatting toolbar.
Format > Number Format > Percent (use the “5” key on the main
Ctrl+Shift+5 keyboard).
Format as Percent icon on the Formatting toolbar.
Ctrl+Shift+6 Format > Number Format > General (use the “6” key on the main
keyboard).
Table 26: 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.
Ctrl+* Edit > Select > Select Data Area (use the * key on the numeric
keypad). The cursor must be inside the area.
Ctrl+; Insert > Date.
Ctrl+Shift+; Insert > Time.
Alt+ Shift + E Insert > OLE Object > Formula Object.
Ctrl+` View > Show Formula. The grave (`) character can be found to the
left of the “1” key on many English keyboards.
Shift+Esc Help > Search Commands.
Ctrl+Shift+F2 Moves the cursor to the Input line where you can enter a formula for
the current cell.
Ctrl+Shift+F5
Moves the cursor to the Name Box field on the Formula bar.
Ctrl+Shift+T
Alt+↓ Opens a drop-down selection list of text items that have been
previously typed into other cells in the same column.
Shift+↓ Selects the adjacent cell or cells located in the down direction.
Selects in the down direction to the edge of the current data range (if
Ctrl+Shift+↓ the cell adjacent to the cursor is empty, the cursor moves to the next
cell that contains data).
Alt+Shift+↓ Optimizes the row height based on the current cell.
← Moves the cell focus left.
Moves the cursor in the left direction to the edge of the current data
Ctrl+← range (if the cell adjacent to the cursor is empty, the cursor moves to
the next cell that contains data).
Shift+← Selects the adjacent cell or cells located in the left direction.
Selects in the left direction to the edge of the current data range (if the
Ctrl+Shift+← cell adjacent to the cursor is empty, the cursor moves to the next cell
that contains data).
Alt+← Decreases the width of the current column.
Alt+Shift+← Optimizes the column width based on the current cell.
Ctrl+Shift+Home Selects all cells from the cursor to the first cell (A1) in the current
sheet.
End Moves the cursor along the current row to the cell in the last column
containing data in the sheet.
Ctrl+End Moves the cursor to the cell in the last column and row that contain
data in the current sheet.
Shift+End Selects cells along the current row from the cursor to the cell in the
last column containing data in the sheet.
Ctrl+Shift+End Selects all cells from the cursor to the cell in the last column and row
that contain data in the current sheet.
Ctrl+Insert Copies the selected cell or cell range to the clipboard in preparation
for a later paste operation.
Shift+Insert Pastes the contents of the clipboard into the selected cells.
Delete Deletes cell contents without a dialog (does not remove formatting).
Shift+Delete Removes and copies the selection to the clipboard.
Ctrl+Backspace Refocuses the view back on the cursor if it is not currently in view.
Shift+Backspace Deselects the current cell selection without deleting contents.
Alt+Backspace Reverses the last command or the last entry you typed.
Ctrl+[ Selects the cells on which the current cell is dependent.
Ctrl+] Selects the cells that are dependent on the current cell.
Ctrl+/ Selects the cells in the matrix formula range that contains the cursor.
Ctrl+Shift+Enter Creates a matrix in the current range using the information entered on
the input line.
Alt+Enter Fills the selected cell range with the formula that you entered on the
input line.
Alt+= Equivalent to selecting Select Function > Sum on the Formula bar.
Tip
You can use the Alt key with the arrow keys and plus (+) and minus (-) keys to
move elements with a finer degree of movement for more accuracy.
Table 34: Chart shortcuts
Windows / Linux Effect
Tab Selects the next chart element.
Shift+Tab Selects the previous chart element.
Home Selects the first chart element.
End Selects the last chart element.
Esc Cancels selection.
Arrow keys Moves the element in the direction of the arrow.
Arrow keys in pie
Moves the selected pie segment in the direction of the arrow.
charts
F2 in titles Enters text input mode.
F3 in legends and
Opens groups so that you can edit the individual components.
data series
Ctrl+F3 in legends
Exits groups.
and data series
+/- Enlarges or shrinks the chart (use the + / - keys in the numeric
keypad).
+/- in pie charts Moves the selected pie segment off or into the pie chart (use the + / -
keys in the numeric keypad).
Tab Cycles through each outline indicator from top to bottom or left to
right.
Shift+Tab Cycles through each outline indicator in the opposite direction.
Ctrl+1 to Ctrl+8 Show all levels up to the specified number while hiding all higher-
numbered levels in the outline.
+/- Shows (+) or hides (-) the focused outline group (use the + / - keys
in the numeric keypad).
Enter Activates the focused indicator button.
Arrow keys Cycles through indicator buttons in the direction of the arrow.
Ctrl+Shift+2 Format > Number Format > Scientific (use the “2” key on the main
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.
Ctrl+Shift+6 Format > Number Format > General (use the “6” key on the main
keyboard).
Table 40: 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.
Option+Cmd+E Tools > Extension Manager.
Cmd+F Edit > Find.
Edit > Find and Replace.
Option+Cmd+F
Find and Replace icon on the Standard toolbar.
Ctrl+Cmd+F View > Full Screen.
Cmd+H LibreOffice > Hide LibreOffice.
Format > Text > Italic.
Cmd+I
Italic icon on the Formatting toolbar.
Cmd+J Format > Align > Justified.
Insert > Hyperlink.
Cmd+K
Insert Hyperlink icon on the Standard toolbar.
Shift+Cmd+F2 Moves the cursor to the Input line where you can enter a formula for
the current cell.
Shift+Cmd+F5
Moves the cursor to the Name Box field on the Formula bar.
Shift+Cmd+T
F8 Toggles between the standard and extending selection modes.
Shift+F8 Toggles between the standard and adding selection modes.
Option+↓ Opens a drop-down selection list of text items that have been
previously typed into other cells in the same column.
Shift+↓ Selects the adjacent cell or cells located in the down direction.
Selects in the down direction to the edge of the current data range (if
Shift+Cmd+↓ the cell adjacent to the cursor is empty, the cursor moves to the next
cell that contains data).
Option+Shift+↓ Optimizes the row height based on the current cell.
← Moves the cell focus left.
Moves the cursor in the left direction the edge of the current data
Cmd+← range (if the cell adjacent to the cursor is empty, the cursor moves to
the next cell that contains data).
Shift+← Selects the adjacent cell or cells located in the left direction.
Selects in the left direction to the edge of the current data range (if the
Shift+Cmd+← cell adjacent to the cursor is empty, the cursor moves to the next cell
that contains data).
Option+← Decreases the width of the current column.
Option+Shift+← Optimizes the column width based on the current cell.
Shift+Cmd+Home Selects all cells from the cursor to the first cell in the current sheet
(A1).
End Moves the cursor along the current row to the cell in the last column
containing data in the sheet.
Cmd+End Moves the cursor to the cell in the last column and row that contain
data in the current sheet.
Shift+End Selects cells along the current row from the cursor to the cell in the
last column containing data in the sheet.
Shift+Cmd+End Selects all cells from the cursor to the cell in the last column and row
that contain data in the current sheet.
Shift+Cmd+Enter Creates a matrix in the current range using the information entered on
the input line.
Option+Enter Fills the selected cell range with the formula that you entered on the
input line.
Tip
You can use the Option key with the arrow keys and plus (+) and minus (-) keys to
move elements with a finer degree of movement for more accuracy.
Table 48: Chart shortcuts
macOS Effect
⇥ Selects the next chart element.
Shift+⇥ Selects the previous chart element.
Home Selects the first chart element.
End Selects the last chart element.
Esc Cancels selection.
Arrow keys Moves the element in the direction of the arrow.
Arrow keys in pie
Moves the selected pie segment in the direction of the arrow.
charts
F2 in titles Enters text input mode.
F3 in legends and
Opens groups so that you can edit the individual components.
data series
Cmd+F3 in legends
Exits groups.
and data series
Cmd+1 to Cmd+8 Show all levels up to the specified number while hiding all higher-
numbered levels in the outline.
+/- Shows (+) or hides (-) the focused outline group (use the + / - keys in
the numeric keypad).
Enter Activates the focused indicator button.
Arrow keys Cycles through indicator buttons in the direction of the arrow.
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 606), or on the Status bar (Figure 607), 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 606 shows the error code returned when a column is too narrow to
display the entire formatted date. The date displayed within the input line, 11/06/2023, would fit
within the cell without a problem, but the format used by the cell produces the date value
Monday, November 6, 2023.
Tip
You can use the ERRORTYPE() function to find the code number for an error
occurring in a different cell. See Calc Error Functions below.
Note
Errors described as Internal errors should not be encountered by users under normal
conditions.
Table 52: List of error codes
Code Status bar message Explanation of the error
Error: Invalid Invalid character in formula. Similar to the Invalid Name
501
character error (525) except that it occurs within a formula.
An argument of a function has an invalid value. This
Error: Invalid
502 error also occurs if more than one matching cell is
argument
found by the DGET() function.
Invalid floating point operation. Calculation result
503 Error: Invalid numeric outside of the defined value range. A calculation that
(#NUM!) value results in an overflow of the defined value range – a
value too big or too small.
The type of a parameter of a function is invalid. For
504 Error in parameter list instance, a parameter of a function is text instead of a
number.
507 Error: in bracketing Missing bracket or parenthesis
Missing bracket or parenthesis. For instance, closing
508 Error: in bracketing parenthesis without an opening parenthesis, or a
missing closing parenthesis in the middle of a formula.
Error: Operator
509 An operator is missing.
missing
Error: Variable Two operators, where the second is not a unitary
510
missing operator, follow each other.
Error: Variable The function requires more variables than those
511
missing provided.
Formula too long / complex. For example, the total
Error: Formula
512 number of internal tokens (that is, operators, variables,
overflow
brackets) in the formula exceeds 8192.
513 Error: String overflow Character string too long.
Error: Internal Internal capacity exceeded. An internal calculation
514
overflow stack overflow occurred.
Internal syntactical
515 Unknown error.
error
Matrix is expected on the calculation stack, but it is not
Internal syntactical
516 available. The calculation stack should contain a matrix
error
but it is not there.
Unknown operation code. A document containing a
Internal syntactical
517 newer feature is loaded in an older version of Calc that
error
did not support that feature.
Variable not available. A variable was supposed to be
Internal syntactical
518 popped from the calculation stack but it is not
error
available / not there.
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
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.lib
reoffice.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/
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.