Calc Guide
Chapter
4
Using Styles and Templates in Calc
Bringing uniformity to your spreadsheets
This document is Copyright © 2005–2011 by its contributors as listed below. You may distribute it and/or modify it under the terms of either the GNU General Public License (http://www.gnu.org/licenses/gpl.html), version 3 or later, or the Creative Commons Attribution License (http://creativecommons.org/licenses/by/3.0/), version 3.0 or later.
All trademarks within this guide belong to their legitimate owners.
Contributors
Barbara Duprey
Feedback
Please direct any comments or suggestions about this document to: documentation@libreoffice.org
Acknowledgments
This chapter is based on Chapter 4 of the OpenOffice.org 3.3 Calc Guide. The contributors to that chapter are:
Andy
Brown T. J. Frazier
Peter Kupfer Nikita Telang
Jean Hollis
Weber
Publication date and software version
Published 15 April 2011. Based on LibreOffice 3.3.
Some keystrokes and menu items are different on a Mac from those used in Windows and Linux. The table below gives some common substitutions for the instructions in this chapter. For a more detailed list, see the application Help.
Windows/Linux |
Mac equivalent |
Effect |
Tools → Options menu selection |
LibreOffice → Preferences |
Access setup options |
Right-click |
Control+click |
Open context menu |
Ctrl (Control) |
z (Command) |
Used with other keys |
F5 |
Shift+z+F5 |
Open the Navigator |
F11 |
z+T |
Open Styles & Formatting window |
Contents
Using the Styles and Formatting window 7
Assigning styles to shortcut keys 8
Creating new (custom) styles 12
Creating a new style using the Style dialog 12
Creating a new style from a selection 13
Creating a new style by dragging and dropping 13
Creating a spreadsheet from a template 15
Updating a spreadsheet from a changed template 17
Adding templates using the Extension Manager 18
Setting a custom template as the default 19
Resetting the default template 19
A template is a model that you use to create other documents. For example, you can create a template for invoices that has your company’s logo and address at the top of the page. New spreadsheets created from this template will all have your company’s logo and address on the first page.
Templates can contain anything that regular documents can contain, such as text, graphics, styles, and user-specific setup information such as measurement units, language, the default printer, and toolbar and menu customization.
All documents in LibreOffice are based on templates. You can create, or download and install, as many templates as you wish. If you do not specify a template when you start a new a new spreadsheet, the new spreadsheet is based on the default template for spreadsheets. If you have not specified a default template, LibreOffice uses the blank spreadsheet template that is installed with the program. See “Setting a default template” on page 19.
A style is a set of formats that you can apply to selected elements in a document to quickly change their appearance. When you apply a style, you apply a whole group of formats at the same time.
Many people manually format spreadsheet cells and pages without paying any attention to styles. They are used 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 formatting such as bold or italic.
Styles are logical attributes. Using styles means that you stop saying “font size 14pt, Times New Roman, bold, centered”, and you start saying “Title” because you have defined the “Title” style to have those characteristics. In other words, styles means that you shift the emphasis from what the text (or page, or other element) looks like, to what the text is.
Styles help improve consistency in a document and can greatly speed up formatting. They also make major formatting changes easy. For example, you may decide to change the appearance of all subtotals in your spreadsheet to be 10 pt. Arial instead of 8 pt. Times New Roman after you have created a 15-page spreadsheet; you can change all of the subtotals in the document by simply changing the properties for the subtotal style.
Page styles assist with printing, so you don’t need to define margins, headers and footers, and other printing attributes each time you print a spreadsheet.
While some components of LibreOffice offer many style types, Calc offers only two:
Cell styles include fonts, alignment, borders, background, number formats (for example, currency, date, number), and cell protection.
Page styles include margins, headers and footers, borders and backgrounds, and the sequence for printing sheets. The page size, orientation, and other attributes of a page style apply only when a spreadsheet is printed; they are not displayed onscreen.
Similar to paragraph styles in LibreOffice Writer, cell styles are the most basic type of style in Calc. You can apply a cell style to a cell and that cell will follow the formatting rules of the style. A range of cell styles are supplied with LibreOffice; five are shown in Figure 1.
Initially, the styles are configured so that if you change the font family of Default, then all of the other styles will change to match. We will discuss how to set this up in “Creating new (custom) styles” on page 12.
Page styles in Calc are applied to sheets. Although one sheet may print on several pages (pieces of paper), only one page style can be applied to a sheet. If a spreadsheet file contains more than one sheet, the different sheets can have different page styles applied to them. So, for example, a spreadsheet might contain one sheet to be printed in landscape orientation (using the Default page style) and another sheet to be printed in portrait orientation (using the Report page style).
Two page styles are supplied with Calc: Default and Report. The major difference between these two styles is that Report is portrait-oriented and Default is landscape-oriented. You can adjust many settings using page styles. You can also define as many page styles as you wish.
Because spreadsheets are primarily used onscreen and not printed, Calc does not display the page style on the screen. If you want a spreadsheet to fit on a certain page size, you have to carefully control the column width and row height, with only File → Page Preview to guide you.
Despite this limitation, it’s well worth defining page styles for any spreadsheets that you are likely to print. Otherwise, if a need for printing does arise, you may lose time to trial and error.
The main way to access styles is through the Styles and Formatting window (shown in Figure 2). You can open this window in several ways.
Keyboard: Press the F11 key.
Menu: Choose Format → Styles and Formatting.
Toolbar: Click the icon on the far left of the Formatting toolbar.
The Styles and Formatting window can be docked at the left or right of the main Calc window. To dock or undock the window, hold down the Ctrl key and double-click a gray part of the window next to the icons at the top.
The first button on the top left of the window, , is for cell styles and the second, , is for page styles.
Calc provides several ways to apply cell styles:
Using the Styles and Formatting window
Using Fill Format mode
Using the Apply Style list
Assigning styles to shortcut keys
Using the Styles and Formatting window
Ensure the Styles and Formatting window is open by pressing F11 or by selecting Format → Styles and Formatting. Choose the Cell Styles list by clicking the icon.
Highlight the cell or group of cells to which the styles should be applied.
Double-click on the cell style name.
This method is quite useful when you need to apply the same style to many scattered cells.
Open the Styles and Formatting window and select the style you want to apply.
Click the Fill Format mode icon . The mouse pointer changes to this icon.
Position the moving icon on the cell to be styled and click the mouse button.
To quit Fill Format mode, click the Fill Format mode icon again or close the Styles and Formatting window.
Caution
|
When this mode is active, a right-click anywhere in the document undoes the last Fill Format action. Be careful not to accidentally right-click and thus undo actions you want to keep. |
You can also add an Apply Style drop-down list to the Formatting toolbar and select a style from the list to apply it to the selected cells:
Click the down-arrow at the right-hand end of the Formatting toolbar (circled in Figure 3). On the drop-down menu, click Visible Buttons.
On the submenu, click Apply Style. The menus close and the Apply Style list now appears on the toolbar between the Styles and Formatting icon and the Font Name list.
Assigning styles to shortcut keys
You can create keyboard shortcuts to apply commonly-used cell or page styles, including custom styles that you have created. See Chapter 14, Setting up and Customizing Calc, for instructions.
Select the sheet to be styled (click on its sheet tab at the bottom of the screen).
In the Styles and Formatting window, choose the Page Styles list by clicking the icon. Double-click on the required page style.
To find out which page style is in use for a selected sheet, look in status bar.
To modify a style, right-click on its name in the Styles and Formatting window and choose Modify. Make the changes in the Style dialog and click OK to save the changes.
You can also modify a current cell style by selecting an already formatted cell and clicking the Update Style button on the top right hand corner of the Styles and Formatting window.
Right click on the name of a style in the Styles and Formatting window and click Modify to open a Style dialog similar to the one shown in Figure 6.
The Style dialog has several tabs. The Organizer tab, shown in Figure 6 for cell styles, is found in all components of LibreOffice. It provides basic information about the style. The Organizer tab for page styles is similar to the one shown for cell styles.
Name
This is the style’s name. You cannot change the name of a built-in style, but you can change the name of a custom style.
Linked with
This option is only available for cell styles; page styles cannot be linked. If you link cell styles, then when you change the base style (for example, by changing the font from Times to Helvetica), all the linked styles will change as well. Sometimes this is exactly what you want; other times you do not want the changes to apply to all the linked styles. It pays to plan ahead.
For example, you can make a new style called red, in which the only change you want to make is for the cell text to be red. In order to make sure that the rest of the text characteristics are the same as the default style, you can link red with default. Then, any changes you make to default will be automatically applied to red.
Category
In Calc, the only option in this drop-down box is Custom styles.
When editing or creating cell styles, you can set several options, which are similar to those for directly formatting cells. A more detailed coverage of cell formatting is given in Chapter 2, Entering, Editing, and Formatting Data. A brief summary is provided here.
On the Numbers tab, you can control the behavior of the data in a cell with this style. This includes specifying the type of data, the number of decimal places, and the language.
Use the Font tab to choose the font for the cell’s contents.
The Font Effects tab offers more font options including underlining, strikethrough, and color.
Use the Alignment tab to set the horizontal and vertical alignment for the data in the cells, and rotate the text.
Use the Borders tab to set the borders for the cells, along with a shadow.
Use the Background tab to choose the background color for a cell.
Use the Cell Protection options to protect cells against certain types of editing.
Several of the page style options are described in more detail in Chapter 6, Printing, Exporting, and E-mailing, because manually formatting a sheet at print time (using Format → Page) actually modifies the page style.
Use the Page tab to edit the overall appearance of the page and its layout. The available options are shown in Figure 7.
Paper format
Here you can set a generic paper type to be used. Letter or A4 are most common, but you can also use legal, tabloid, envelope sizes, or user-defined paper types. You can also define the orientation of the page and which print tray for the paper to come from (if your printer has more than one tray).
Margins
Here you can set the margins for the page.
Layout settings: Page layout
Here you can specify whether to apply the formatting to right (odd) pages only, left (even) pages only, or both right and left pages that use the current page style.
Mirrored formats the pages as if you want to bind the printed pages like a book.
The first page of a document is assumed to be an odd page.
Layout settings: Format
This area specifies the page numbering style for this page style.
Layout settings: Table alignment
This option specifies the alignment options for the cells on a printed page, either horizontal or vertical.
The Border and Background tabs for pages duplicate the tabs of the same name on cell styles, and are over-ridden by the cell style or manual settings. You may choose to ignore the Border and Background tabs altogether in page styles. Both tabs are illustrated with helpful diagrams.
Similar to formatting a cell style, use the Borders tab to choose whether the page should have borders, how large the borders should be, and how far the text will be from the borders.
Use this tab to specify the background for this page style. You can apply either a solid color or a picture as a background.
Use this tab to design and apply the header for this page style. For more detailed instructions on how to format the header, see Chapter 6, Printing, Exporting, and E-mailing.
Use this tab to design and apply the footer for this page style. For more detailed instructions on how to format the footer, see Chapter 6.
By far the most important settings for Calc page styles are on the Sheet tab. Although the Sheet tab includes an option that sets the first page option, most of its settings involve exactly how your spreadsheet will print. See Chapter 6.
You may want to add some new styles. You can do this in two ways:
Creating a new style using the Style dialog
Creating a new style from a selection
Note |
New styles apply only to this document; they are not saved in the template. To save new styles in a template, see “Copying and moving styles“ on page 13 and “Creating a template” on page 16. |
Creating a new style using the Style dialog
To create a new style using the Style dialog, right-click in the Styles and Formatting window and choose New from the context menu.
(Cell styles only) If you want your new style to be linked with an existing style, first select that style and then right-click and choose New.
If you link styles, then when you change the base style (for example, by changing the font from Times to Helvetica), all the linked styles will change as well. Sometimes this is exactly what you want; other times you do not want the changes to apply to all the linked styles. It pays to plan ahead.
The dialogs and choices are the same for defining new styles and for modifying existing styles.
Creating a new style from a selection
You can create a new cell style by copying an existing manual format.
Open the Styles and Formatting window and choose the type of style you want to create.
In the document, select the formatted cell that you want to save as a style.
In the Styles and Formatting window, click on the New Style from Selection icon .
In the Create Style dialog, type a name for the new style. The list shows the names of existing custom styles of the selected type. Click OK to save the new style.
Creating a new style by dragging and dropping
Select a cell and drag it to the Styles and Formatting window.
To copy a style from one spreadsheet to another, or between a spreadsheet and a template, instead of recreating it in the second spreadsheet, use the Template Management dialog.
Click File → Templates → Organize.
In the Template Management dialog (Figure 9), set the lists at the bottom to either Templates or Documents, as needed. The default is Templates on the left and Documents on the right.
Tip |
To copy styles from a file that is not open, click the File button. When you return to this dialog, both lists show the selected file as well as all the currently open documents. |
Open the folders and find the templates from and to which you want to copy. Double-click on the name of the template or document, and then double-click the Styles icon to show the list of individual styles (Figure 10).
To copy a style, hold down the Ctrl key and drag the name of the style from one list to the other. To move a style, drag the name of the style without holding down the Ctrl key.
Repeat for each style you want to copy. If the receiving template or document has many styles, you may not see any change unless you scroll down in the list. When you are finished, click Close.
You cannot remove (delete) any of Calc’s predefined styles, even if you are not using them.
You can remove any user-defined (custom) styles; but before you do, you should make sure the styles are not in use. If an unwanted style is in use, you will want to replace it with a substitute style.
Replacing styles (and then deleting the unwanted ones) can be very useful if you are dealing with a spreadsheet that has been worked on by several people.
To delete unwanted styles, right-click on them (one at a time) in the Styles and Formatting window and click Delete on the context menu. Choose Yes in the confirmation dialog.
Creating a spreadsheet from a template
To create a spreadsheet from a template:
From the menu bar, choose File → New → Templates and Documents. The Templates and Documents dialog opens.
In the box on the left, click the Templates icon if it is not already selected. A list of template folders appears in the center box.
Double-click the folder that contains the template that you want to use. A list of all the templates contained in that folder appears in the center box.
Select the template that you want to use. You can preview the selected template or view the template’s properties:
To preview the template, click the Preview icon. A preview of the template appears in the box on the right.
To view the template’s properties, click the Document Properties icon. The template’s properties appear in the box on the right.
Click Open. The Templates and Documents dialog closes and a new document based on the selected template opens in Calc.
You can create a template from a document:
Open a new or existing document of the type you want to make into a template (text document, spreadsheet, drawing, presentation).
Add the content and styles that you want.
From the menu bar, choose File → Templates → Save. The Templates dialog opens .
In the New template field, type a name for the new template.
In the Categories list, click the category to which you want to assign the template. The category you choose has no effect on the template itself; it is simply the folder in which you save the template. Choosing an appropriate folder (category) makes it easier to find the template when you want to use it. You may wish to create a folder for Calc templates.
To learn more about template folders, see “Organizing templates” on page 20.
Click OK to save the new template.
Any settings that can be added to or modified in a document can be saved in a template. For example, below are some of the settings (although not a full list) that can be included in a Calc document and then saved as a template for later use:
Printer settings: which printer, single sided / double sided, and paper size, and so on
Cell and page styles to be used
Templates can also contain predefined text, saving you from having to type it every time you create a new document. For example, an invoice template might contain your company’s name, address and logo.
You can also save menu and toolbar customizations in templates; see Chapter 14, Setting up and Customizing Calc, for more information.
You can edit a template’s styles and content, and then, if you wish, you can reapply the template’s styles to documents that were created from that template. (Note that you can only reapply styles. You cannot reapply content.)
To edit a template:
From the menu bar, choose File → Templates → Organize. The Template Management dialog opens.
In the box on the left, double-click the folder that contains the template that you want to edit. A list of all the templates contained in that folder appears underneath the folder name.
Select the template that you want to edit.
Click the Commands button and choose Edit from the drop-down menu.
Edit the template just as you would any other document. To save your changes, choose File → Save from the menu bar.
Updating a spreadsheet from a changed template
The next time you open a spreadsheet that was created from the changed template, the following message appears.
Click Update Styles to apply the template’s changed styles to the spreadsheet. Click Keep Old Styles if you do not want to apply the template’s changed styles to the spreadsheet (but see Caution notice below).
Caution
|
If you choose Keep Old Styles in the message box shown in Figure 14, that message will not appear again the next time you open the document after changing the template it is based on. You will not get another chance to update the styles from the template, although you can use the macro given in the Note below to re-enable this feature. |
Note |
To re-enable updating from a template:
Sub
FixDocV3
Next time when you open this document you will have the update from template feature back. |
Adding templates using the Extension Manager
The Extension Manager provides an easy way to install collections of templates, graphics, macros, or other add-ins that have been “packaged” into files with a .OXT extension. See Chapter 14, Setting Up and Customizing Calc, for more about the Extension Manager.
This Web page lists many of the available extensions: http://extensions.libreoffice.org/.
To install an extension, follow these steps:
Download an extension package and save it anywhere on your computer.
In LibreOffice, choose Tools → Extension Manager from the menu bar. In the Extension Manager dialog, click Add.
A file browser window opens. Find and select the package of templates you want to install and click Open. The package begins installing. You may be asked to accept a license agreement.
When the package installation is complete, the templates are available for use through File → New → Templates and Documents and the extension is listed in the Extension Manager.
If you create a document by choosing File → New → Spreadsheet from the menu bar, LibreOffice creates the document from the Default template for spreadsheets. You can, however, set a custom template to be the default. You can reset the default later if you choose.
Setting a custom template as the default
You can set any template to be the default, as long as it is in one of the folders displayed in the Template Management dialog.
To set a custom template as the default:
From the menu bar, choose File → Templates → Organize. The Template Management dialog opens.
In the box on the left, select the folder containing the template that you want to set as the default, then select the template.
Click the Commands button and choose Set As Default Template from the drop-down menu.
The next time that you create a document by choosing File → New, the document will be created from this template.
Resetting the default template
To re-enable LibreOffice’s default spreadsheet template as the default:
In the Template Management dialog, click any folder in the box on the left.
Click the Commands button and choose Reset Default Template → Spreadsheet from the drop-down menu.
The next time that you create a spreadsheet by choosing File → New, it will be created from LibreOffice’s default template for spreadsheets.
Associating a spreadsheet with a different template
At times you might want to associate a spreadsheet with a different template, or perhaps you’re working with a spreadsheet that did not start from a template but you now want it associated with a template.
One of the major advantages of using templates is the ease of updating styles in more than one document, as described on page 17. If you update styles by copying them from a different template (as described on page 13), the document has no association with the template from which the styles were loaded—so you cannot use this method. What you need to do is associate the document with the different template.
For best results, the names of styles should be the same in the existing document and the new template. If they are not, you will need to use Search and Replace to replace the old styles with new ones. See Chapter 2, Entering, Editing, and Formatting Data, for more about replacing styles using Find and Replace.
Use File → New → Templates and Documents. Choose the template you want. A new file, based on the template, opens. If the template has unwanted text or graphics in it, delete them.
Open the spreadsheet you want to change. (It opens in a new window.) Press Control+A to select everything in the spreadsheet.
Switch to the window containing the blank spreadsheet created in step 1, and paste the content into that spreadsheet.
Save the file under a new name.
LibreOffice can only use templates that are in its template folders. You can create new template folders and use them to organize your templates, and import templates into those folders. For example, you might have one template folder for report templates and another for letter templates. You can also export templates.
To begin, choose File → Templates → Organize from the menu bar. The Template Management dialog opens.
Note |
All the actions made by the Commands button in the Template Management dialog can be made as well by right-clicking on the templates or the folders. |
To create a template folder:
In the Template Management dialog, click any folder.
Click the Commands button and choose New from the drop-down menu. A new folder called Untitled appears.
Type a name for the new folder, and then press Enter. LibreOffice saves the folder with the name that you entered.
You cannot delete template folders supplied with LibreOffice or installed using the Extension Manager; you can only delete template folders that you have created.
To delete a template folder:
In the Template Management dialog, select the folder that you want to delete.
Click the Commands button and choose Delete from the drop-down menu. A message box appears and asks you to confirm the deletion. Click Yes.
To move a template from one template folder to another template folder:
In the Template Management dialog, double-click the folder that contains the template you want to move. A list of the templates contained in that folder appears underneath the folder name.
Click the template that you want to move and drag it to the desired folder. If you do not have the authority to delete templates from the source folder, this action copies the template instead of moving it.
You cannot delete templates supplied with LibreOffice or installed using the Extension Manager; you can only delete templates that you have created or imported.
To delete a template:
In the Template Management dialog, double-click the folder that contains the template you want to delete.
Click the template that you want to delete.
Click the Commands button and choose Delete from the drop-down menu. A message box appears and asks you to confirm the deletion. Click Yes.
If the template that you want to use is in a different location, you must import it into a LibreOffice template folder.
To import a template into a template folder:
In the Template Management dialog, select the folder into which you want to import the template.
Click the Commands button and choose Import Template from the drop-down menu. A standard file browser window opens.
Find and select the template that you want to import and click Open. The file browser window closes and the template appears in the selected folder.
If you want, type a new name for the template, and then press Enter.
To export a template from a template folder to another location:
In the Template Management dialog, double-click the folder that contains the template you want to export.
Click the template that you want to export.
Click the Commands button and choose Export Template from the drop-down menu. The Save As window opens.
Find the folder into which you want to export the template and click Save.