Writer Guide 24.2
Chapter 13, Tables
This document is Copyright © 2024 by the LibreOffice Documentation Team. Contributors are listed below. This document may be distributed and/or modified 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.
To this edition
Jean Hollis Weber |
|
|
To previous editions
Jean Hollis Weber |
Kees Kriek |
Gillian Polack |
Bruce Byfield |
John A Smith |
Barbara Duprey |
Shravani Bellapukonda |
Ron Faile Jr. |
|
Please direct any comments or suggestions about this document to the Documentation Team Forum at https://community.documentfoundation.org/c/documentation/loguides/ (registration is required) or send an email to: loguides@community.documentfoundation.org.
Note
Everything sent to a forum, including email addresses 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.
Published February 2024. Based on LibreOffice 24.2 Community.Other versions of LibreOffice may differ in appearance and functionality.
Some keystrokes and menu items are different on macOS from those used in Windows and Linux. The table below gives some common substitutions used in this document. For a detailed list, see LibreOffice Help.
Windows or Linux |
macOS equivalent |
Effect |
Tools > Options menu selection |
LibreOffice > Preferences |
Access setup options |
Right-click |
Control+click or right-click depending on computer setup |
Open a context menu |
Ctrl (Control) |
⌘ (Command) |
Used with other keys |
Alt |
⌥ (Option) or Alt |
Used with other keys |
F11 |
⌘+T |
Open Styles deck in Sidebar |
Tables are a useful way to organize and present large amounts of information, for example:
Technical, financial, or statistical reports.
Catalogs showing descriptions, prices, characteristics, and photographs of products.
Bills or invoices.
Lists of names with address, age, profession, and other information.
Tables can often be used as an alternative to spreadsheets to organize materials. A well-designed table can help readers understand better what you are saying. While you would normally use tables for text or numbers, you could put other objects, such as pictures, in cells. Writer’s tables provide limited spreadsheet functions; see “Using spreadsheet functions in a table” on page 1.
Tables can also be used as a page-layout tool to position text in areas of a document instead of using several Tab characters. Another example is in headers and footers to support independent positioning of different elements, such as page number, document title, and so on. This use of tables is described in Chapter 6, Formatting Pages: Advanced.
All of the table commands described in this chapter are conveniently located under Table on the Menu bar (Figure 1) and on the Table toolbar (Figure 2). Some are also found in the context menu for a table or in the Table panel of the Properties deck in the Sidebar (Figure 3).
Figure 1: Table menu
When you create a table or select an existing table, the Table toolbar (Figure 2) is displayed automatically. To display it at any time, click View > Toolbars > Table. The toolbar can float over the main Writer window, or it can be docked along any edge of the main window. See Chapter 1, Introducing Writer, for more about docking and floating toolbars, and how to hide and display specific tools on a toolbar.
1 |
Insert rows above |
12 |
Split Table |
23 |
Number Format: Percent |
2 |
Insert rows below |
13 |
Optimize Size |
24 |
Number Format: Decimal |
3 |
Insert columns before |
14 |
Align Top |
25 |
Number Format |
4 |
Insert columns after |
15 |
Center Vertically |
26 |
Insert Caption |
5 |
Delete selected rows |
16 |
Align Bottom |
27 |
Sort |
6 |
Delete selected columns |
17 |
Table Cell Background Color |
28 |
Protect Cells |
7 |
Delete table |
18 |
AutoFormat Styles |
29 |
Unprotect Cells |
8 |
Select Cell |
19 |
Borders |
30 |
Sum |
9 |
Select Table |
20 |
Border Style |
31 |
Insert or Edit Formula |
10 |
Merge Cells |
21 |
Border Color |
32 |
Table Properties |
11 |
Split Cells |
22 |
Number Format: Currency |
|
|
Figure 2: Table toolbar
When the cursor is in a table, the Properties deck in the Sidebar (Figure 3) includes table properties.
Figure 3: Table properties in the Sidebar
Before creating a table in a Writer document, it helps to have an idea of the visual result wanted and an estimate of the number of rows and columns required. Every parameter can be changed at a later stage; however, thinking ahead can save time as changes to fully formatted tables often require a significant effort.
To quickly create a table with the default properties, click the Insert Table icon on the Standard toolbar. On the drop-down graphic, choose the size of the table (up to fifteen rows and up to ten columns). To create the table, click the cell that you want to be on the last row of the last column.
Figure 4: Inserting a table
To create a new table and specify the properties for the table, position the cursor where you want the table to appear, then use any of these methods to open the Insert Table dialog (Figure 5):
Choose Table > Insert Table on the Menu bar.
Press Ctrl+F12.
On the Standard toolbar, click the Insert Table icon and select More Options at the bottom of the drop-down graphic.
In the General section of the Insert Table dialog, in the Name box, you can enter a different name from the Writer-generated default for the table. This might come in handy when using the Navigator to jump quickly to a table.
In the Columns and Rows boxes, specify the number of columns and rows for the new table. You can change the size of the table later, if necessary.
Figure 5: Insert Table dialog
Under Options, set up the initial table characteristics:
Heading — Enables a heading to be used in the table and defines the number of rows to be used as headings. A second (and, occasionally, third) heading row can be useful for sub-headings in a complex table.
Repeat heading rows on new pages — Enables the heading rows to be repeated at the top of subsequent pages if the table spans more than one page.
Heading rows — Specifies the number of rows to be used for the heading. Default is 1.
Don’t split table over pages — Prevents the table from spanning more than one page. This can be useful if the table starts near the end of a page, and would look better if it were completely located on the following page. If the table starts earlier on the page but does not all fit, this setting can lead to awkward page breaks. If the table becomes longer than would fit on one page, either deselect this option or manually split the table.
The Styles section lists several predefined table layouts, also known as table styles. See “Creating and applying table styles” on page 1 for more information. You can select and preview the desired table option from the list.
After making your choices, click Insert. Writer creates a table as wide as the text area (from the left page margin to the right page margin), with all columns the same width and all rows the same height. You can adjust the columns and rows later to suit your needs.
You can create tables within tables, nested to a depth limited only by imagination and practicality. Nested tables are especially useful for page layout. Figure 6 demonstrates a simple, two-level example. The shaded table is inside a cell of the larger table. To achieve this, simply click in a cell of an existing table and use any of the methods mentioned in “Creating a new table” above.
Figure 6: Nested table example
You can also create a table by typing a series of hyphens (-) or tabs separated by plus signs. Use the plus signs to indicate column dividers, while hyphens and tabs are used to indicate the width of a column. When using tabs, the default tab setting determines the width; this setting can be changed in Tools > Options > LibreOffice Writer > General.
For example, this character sequence:
+-----------------+---------------+------+
creates a table like this:
Note
This function can be disabled or enabled in Tools > AutoCorrect > AutoCorrect Options. On the Options page, deselect or select Create table.
To create a table from formatted text, select the text, then choose Table > Convert > Text to Table on the Menu bar. The text to be converted must contain characters to indicate column separators. Paragraph marks indicate an end of a table row.
Tip
Unlike the creation of a table by other methods, conversion from text to table preserves the paragraph style and character style applied to the original text.
1) Start by editing the text, if necessary, to ensure the column separator character is where you want it. Select the text to be converted and choose Table > Convert > Text to Table to open the dialog shown in Figure 7.
2) The Separate text at section has four options for the separator for the columns of text. Select Other to choose the default comma (useful if you are importing a .csv file) or type any character in the box.
The Options are the same as those in the Insert Table dialog (Figure 5).
3) Click OK to convert the text.
Figure 7: Convert Text to Table dialog
In this example we will convert the following text into a table.
In this case, the separator between elements is a semicolon. Select the text and choose Table > Convert > Text to Table. We obtain the following result.
Tip
You can also convert a table into plain text. This may be useful when you want to export the table contents into a different program. Place the cursor anywhere in the table, choose Table > Convert > Table to Text on the Menu bar, pick the preferred row separator, and click OK to finish.
To copy a spreadsheet area into a Writer document as a Writer table:
1) Open both the Writer document and the spreadsheet.
2) Select the sheet area (cells) that you want to copy.
3) Right-click and choose Copy in the context menu, or press Ctrl+C; then click in the Writer document and choose Paste in the context menu or press Ctrl+V. Or, drag the area into the Writer document.
See also Chapter 19, Spreadsheets, Charts, Other Objects, for other methods of inserting spreadsheets into Writer documents.
Formatting a table is a two-step process: formatting the table layout (the subject of this section) and formatting the table text (the subject of the next section).
Tip
If you apply similar formatting of table layout and table text to multiple tables, using table styles can speed up your work and provide consistency. See “Creating and applying table styles” on page 1.
Formatting the layout involves one or more of the following operations: adjusting the size of the table and its position on the page, adjusting sizes of rows and columns, adding or removing rows or columns, merging and splitting individual cells, changing borders and background.
If you create a table using the Insert Table dialog or the Insert Table icon on the Standard toolbar, the following defaults are set:
The cells use the Table Contents paragraph style. In the default template, this style is identical to the Default Paragraph Style.
The default table occupies all the space from margin to margin (text area).
The default table has thin black borders around each cell (grid).
If you activate the Heading option, the cells in the heading row (or rows) use the Table Heading paragraph style.
To quickly resize a table, first move the mouse pointer to either the left or right edge. When the pointer changes shape, drag the border to the new position. This method only changes the size of the first or last column; it does not change the alignment of the table on the page.
For more precise control over the size and position of the table on the page, use the Table Properties dialog (Figure 8). Choose Table > Properties on the Menu bar, or right-click anywhere in the table and choose Table Properties in the context menu, or click the More Options icon in the Table panel of the Properties deck on the Sidebar.
Figure 8: Table Properties dialog, Table tab
On the Table tab of the dialog (Figure 8), you can set the alignment of the table:
Automatic: the default setting for a table, fills the width of the text area.
Left: aligns the table with the left margin.
Right: aligns the table with the right margin.
From Left: lets you specify under Spacing exactly how far from the left margin the table is placed.
Center: aligns the table in the middle between the left and right margins. If the table width is greater than the margin, the table will extend outside of the margins.
Manual: lets you specify the distances from both left and right margins under Spacing.
Selecting an alignment option other than Automatic activates the Width field in the Properties section, where you can enter the desired size of the table. Select Relative to see the width as percentage of the text area.
In the Spacing section, use the Above and Below boxes to modify the separation between the text and the table.
When the size of the table is less than the size of the text area, Writer will insert some values in the Left and Right boxes. Otherwise these values are not available. You can enter values:
In both the Left and Right boxes if you select Manual alignment.
In the Left box when you select the From left, Right, or Center alignment.
In the Right box if you select Left alignment.
On the Text Flow tab of the Table Properties dialog (Figure 9), you can:
Insert a page or column break either before or after the table. Use the Text Flow: Break option, combined with the Page or Column and the Before or After options. If you insert a page break before the table (that is, start the table on a new page), you can also change the page style that will go with it by selecting With Page Style and a new page style. As with any page break, you can also reset the page numbers using the Page number box.
Keep a table on one page by deselecting Allow table to split across pages and columns. If this item is deselected, the next item is not active.
Keep each row on one page by deselecting Allow row to break across pages and columns.
Use Keep with next paragraph to keep the table and an immediately following paragraph together if you insert a page break.
Use Repeat heading, and its associated numbers box, to select the number of table heading rows that will be repeated on each page. A complicated table may need two or three heading rows to be easily read and understood.
Use the Text orientation list to select the direction for the text in the cells. Select from Horizontal, Vertical (top to bottom), Vertical (bottom to top), or Use superordinate object settings (meaning use the default text flow settings for the page).
Select the vertical alignment of the text in the table or the selected cells; the choices are to align with the top of the cell, the center of the cell, or the bottom of the cell. This alignment is in addition to the Left-Right alignment options available on the Table tab of the Table Properties dialog.
Note
A table heading row cannot span two pages, but any other row can. A one-row table (often used for page layout purposes), if set up with the default of including a heading, will not break across pages. The solution is to make sure the table is defined without a heading row.
Figure 9: Table Properties dialog, Text Flow tab
You can adjust the height of rows and the width of columns in a table in several ways.
Move the mouse pointer next to the edge of the cell and when a double-headed arrow appears, click and hold the left mouse button, drag the border to the desired position, and release the mouse button.
On the horizontal ruler, column dividers are marked by a pair of thin gray lines; the vertical ruler indicates row dividers in the same way. You can resize a row or column by holding the mouse button down on the appropriate divider and dragging it to the desired location.
Use the keyboard as described below.
Selecting Table > Size on the Menu bar also offers some resizing options:
Select Column Width or Row Height to enter a dimension into the size box for each selectable column or row of the table.
The Minimize Column Width or Minimize Row Height options make the selected columns or rows as narrow as possible while still fitting their contents. The rows or columns may not all be the same height or width.
The Optimal Column Width or Optimal Row Height options make the selected columns or rows fit the largest character in any row or the longest entry in any column.
Use Distribute Columns/Rows Evenly to quickly bring them back to all being the same width or height.
For greater control over the width of each column, use the Columns tab of the Table Properties dialog (Figure 10).
Figure 10: Table Properties dialog, Columns tab
Right-click on the table and choose Table Properties in the context menu, or choose Table > Properties on the Menu bar, or click the More Options icon in the Table panel of the Properties deck on the Sidebar. On the Table Properties dialog, select the Columns tab.
Adapt table width: If a table already stretches to the page margins, it cannot stretch any wider and the Adapt table width option can only be used to reduce the column width. If the table is narrower, increasing the width of a column will increase the width of the whole table. This option is not available if Automatic has been selected in the Alignment area of the Table tab.
If the table width already extends past the margins, with the Adapt table width option checked, attempting to change a column width will automatically decrease that column’s width so the table shrinks to the page margins while keeping the width of other columns.
Adjust columns proportionally results in all columns changing their widths by the same percentage when one is changed. For example, if you reduce by half the size of a column, the sizes of all the other columns will be halved. This option is not available if Automatic has been selected in the Alignment area of the Table tab.
Remaining space shows how much further the table can expand before hitting the limit of the margins. This value cannot be edited and will not be negative in the event that the table width is already larger than the space between the left and right margins.
Under Column width, each individual column can be adjusted. If more than six columns, use the arrows at the right and left to view them all. With no options selected, the column to the right of the one being adjusted will automatically change to keep the table width constant. Adjusting the most right hand column causes the first column to change.
Tip
Rather than starting from the Table Properties dialog, it is often more efficient to make rough adjustments to a new table using the mouse, and then fine-tune the layout using the Columns tab and the Table tab of the Table Properties dialog.
You can also resize a table using the keyboard:
1) Place the cursor in the cell where you want to make changes.
2) Press and hold the Alt key while using the arrow keys.
The left and right arrow keys adjust the column width by moving the border on the right edge of the cell, but not past the margin.
The up and down arrows adjust the row height (when possible) by moving the border on the lower edge of the cell.
To adjust the resizing parameters and behavior for keyboard handling, choose Tools > Options > LibreOffice Writer > Table (Figure 11).
Figure 11: Choosing keyboard handling of table columns and rows
Use the Row and Column values in the Move cells section to determine the amount of change produced by a single keystroke while resizing. In the Behavior of rows/columns section, you can choose one of three strategies when resizing:
Fixed: the resizing will affect only the adjacent cell and not the entire table. The width of the table does not change when resizing its cells.
Fixed, proportional: when resizing a cell, all the other cells are also resized proportionally, but in the opposite direction so as to maintain the width of the table.
Variable: resizing a cell affects the table size. For example, when you widen a cell, the width of the table increases. This is the default option.
To quickly insert one row or column, place the cursor in the row or column before or after which you want to add new rows or columns, and then do one of the following:
Click the Rows Above or Rows Below icons on the Table toolbar or the Table panel of the Properties deck on the Sidebar to insert one row above or below the selected one.
Click the Columns Before or Columns After icons on the Table toolbar or the Table panel of the Properties deck on the Sidebar to insert one column before or after the selected one.
Choose Table > Insert > Rows Above/Below or Table > Insert > Columns Before/After on the Menu bar.
Right-click and choose Insert > Rows Above/Below or Insert > Columns Before/After in the context menu.
To insert any number of rows or columns:
1) Place the cursor in the row or column where you want to add new rows or columns.
2) Choose Table > Insert > Rows or Table > Insert > Columns on the Menu bar, or right-click and choose Insert > Rows or Insert > Columns in the context menu.
3) In the small dialog that opens, select the number of rows or columns to add, and whether they appear before or after the one selected. Set Number to the number of rows or columns to insert, and Position to Before or After.
4) Click OK to close the dialog.
Note
Regardless of how they are inserted, new rows or columns have the same formatting as the row or column where the cursor was located.
To quickly delete one or more rows or columns, select the rows or columns you want to delete and do one of the following:
Click the Delete selected rows or Delete selected columns icons on the Table toolbar or the Table panel of the Properties deck on the Sidebar.
Right-click and choose Delete > Rows or Delete > Columns.
Choose Table > Delete > Rows or Table > Delete > Columns on the Menu bar.
A common use for merging cells is to make a heading row that takes up the entire width of the table, or a subheading row over more than one column.
To merge a cell or group of cells into one cell:
1) Select the cells to merge.
2) Right-click and choose Merge Cells in the context menu, or choose Table > Merge Cells from the Menu bar, or click the Merge Cells icon on the Table toolbar or the Table panel of the Properties deck on the Sidebar. Any content of the cells appears in the merged cell.
To split a cell into multiple cells:
1) Position the cursor inside the cell.
2) Right-click and choose Split Cells in the context menu, or choose Table > Split Cells on the Menu bar, or click the Split Cells icon on the Table toolbar or the Table panel of the Properties deck on the Sidebar.
3) On the Split Cells dialog, select how to split the cell and how many cells to create. A cell can be split either horizontally (create more rows) or vertically (create more columns).
Figure 12: Split Cells dialog
It is generally best to merge and split cells after completing other layout formatting. This is because some operations such as deleting a column or a row may produce a result difficult to predict when applied to a table with merged or split cells.
To quickly apply some table borders, use the palette of options on the Borders, Border Style, and Border color icons in the Table toolbar or the Table panel of the Properties deck on the Sidebar. For more control, use the Borders tab of the Table Properties dialog (Figure 13).
Figure 13: Table Properties dialog, Borders page
Line arrangement specifies where the borders go. If a group of cells is selected, the border will be applied only to those cells. You can specify individually the style of the border for the outside edges of the selected cells and for the cell divisions. Writer provides default arrangements, but you can click the line you want to customize in the User-defined area to get exactly what you want. When multiple cells are selected, you can select the edges of the selection as well as the cell dividers.
Note
When the selected cells have different styles of border, the User-defined area shows the border as a gray line. Click the gray line to choose a new border style (first click), leave the border as it is (second click) or delete the border (third click).
Line specifies what the border looks like. You can choose from the drop-down lists for Style and Color, and specify a Width. Your selections apply to those borders highlighted by a pair of black arrows in the User-defined area.
Padding specifies how much space to leave between the border and the cell contents. Spacing can be specified individually for the left, right, top, and bottom borders. Choose Synchronize to have the same spacing on all four sides.
Shadow Style properties always apply to the whole table. A shadow has three components: where it is (position), how far from the table it is cast (distance), and what color it is.
If Merge adjacent line styles (under Properties) is checked, two cells sharing a common border will have their borders merged, rather than being side by side or above/below each other.
Tip
To reset everything on the Borders tab of the Table Properties dialog, select the No Borders icon under Line arrangement Presets (the box on the left).
A table background can greatly improve the readability of data, visually highlight important parts of the table (such as the heading or a specific cell), or just make the table more appealing. You can choose between two types of background: solid color or image. The background can be applied to the whole table, to a single cell, or to a row.
You can quickly apply color cell backgrounds using the palette of options on the Table Cell Background Color icon in the Table toolbar or the Table panel of the Properties deck on the Sidebar. For more control, or to use an image as a background, use the Background tab of the Table Properties dialog (Figure 14).
Figure 14: Table Properties dialog: inserting an image as a background
Tip
Consider the color contrast between the background and foreground (usually text). Background colors and images can also have transparency applied to help make the text more readable. The row background option is quite handy for creating alternate color rows or assigning a different background to the heading of the table.
Note
The background selected for a cell will be in front of the row background which in turn will be in front of (and hide) the table background.
To set the background for a cell, row, or table:
1) Place the cursor anywhere inside the cell, row, or table to work with. To apply a background to a group of cells, select the group.
2) Right-click and choose Table Properties in the context menu, or choose Table > Properties on the Menu bar, or click the More Options icon on the Table panel of the Properties deck on the Sidebar.
3) In the Table Properties dialog, select the Background tab (Figure 14).
4) Choose whether to apply the settings to cell, row, or table.
Cell: changes apply only to the selected cells, or the cell where the cursor currently resides. Even when a group of cells is selected, the background settings are applied to each cell individually.
Row: changes affect the entire row where the cursor resides.
Table: changes will set the background for the entire table, regardless of the cursor position or selected cells.
5) To apply a color, click the Color button, select the color, and click OK.To apply an image, click the Image button, then,
a) Select from the given images or use the Add/Import button.
b) Under Options, select the type of placement for the image.Style – the way the image is to appear: custom position/size, tiled, or stretched.Size – the required Image aspect ratio or the Scale option.Position – where the image is to be displayed.
c) To apply the image, click OK.
A table boundary is a set of pale (usually gray) lines around the cells when viewed on‑screen in LibreOffice with no borders enabled. These boundaries are not printed; their only function is to show where the table cells are. They are particularly useful when using tables for page layout.
To display tables the same way on the screen as on the printed page, with no boundary lines, deselect View > Table Boundaries, or go to Tools > Options > LibreOffice > Application Colors, where you can display or hide boundaries around text, tables, headers and footers, figures, and other parts of a document, and you can choose the color of boundary lines.
Turning boundaries off does not hide any borders that the table may have.
Using table styles, you can apply an elaborate format to your table with just a few clicks. Like other styles, table styles enable you to produce consistent looking tables in a document.
To apply a table style, go to the Table Styles tab of the Styles deck on the Sidebar. Then place the cursor anywhere in the table and double-click the name of a style.
For more control, go to Table > AutoFormat Styles on the Menu bar, or click the AutoFormat Styles icon on the Table toolbar. On the AutoFormat dialog (FIgure Figure 15), select a format from the list, choose which features you wish to use in your table (font, alignment, borders, and so on), and then click OK. The table will be reformatted.
Figure 15: AutoFormat dialog
Tip
You can rename the formats by selecting one and clicking the Rename button. The name will change in this dialog and in the Table Styles page on the sidebar.
You can delete a format by selecting it and clicking the Delete button. However, you cannot rename or delete the Default Table Style.
Although the Table Styles tab of the Sidebar’s Styles deck includes a quick way to apply table styles, they are created by using the AutoFormat feature. Follow these steps:
1) Create a table. Format it as you wish: font, alignment, borders, background, number format.
2) Put the cursor anywhere in the table. Select Table > AutoFormat Styles on the Menu bar, or click the AutoFormat Styles icon on the Table toolbar.
3) On the AutoFormat dialog (Figure 15), choose which formatting to include in the new table style, and then click Add.
4) In the pop-up dialog, type a name for the new style and click OK. The new style is added to the list of formats in the AutoFormat dialog and to the list of table styles in the Styles deck in the sidebar.
Table styles also include the following table-level properties:
Break
Keep with next paragraph
Repeat heading
Allow table to split across pages
Allow rows to break across pages
Merge adjacent line styles
Table shadow
Tip
These styles do not include table and column widths in the table format. To insert a table with predefined full formatting, save it as AutoText. See Chapter 2, Working with Text: Basics, for instructions.
Once the table layout is set, you can move on to formatting the text in the individual cells. You can apply manual formatting as with any other paragraph in the text, but it is highly recommended that you use paragraph and character styles, for consistency and ease of maintenance. Other aspects to consider include text flow, alignment, and orientation.
You can format each cell independently of other cells, or you can simultaneously format a group of cells by selecting them before applying the desired formatting.
Tip
You can apply basic table text formatting by choosing a table style and then modify only those cells that you wish to be different.
By default, text entered into a table is aligned to the top-left of the cell. You can change the default for the entire table, as described above, or for individually selected cells.
To vertically align the text in specific cells:
1) Place the cursor in the cell you wish to change, or select multiple cells.
2) Click an icon on the Table toolbar: Align Top, Center Vertically, or Align Bottom.
The number format can be set for a whole table, a group of cells, or a single cell. For example, cells can be set to display in a particular currency, to four decimal places, or in a particular date format.
Number recognition specifies that numbers in a text table are recognized and formatted as numbers. If Number recognition is not selected, numbers are saved in text format and are automatically left-aligned. To enable Number recognition, go to Tools > Options > LibreOffice Writer > Table and select the option in the Input in Tables section.
To set the number format for one or more cells, select the cells, then either click the icon for one of the popular formats on the Table toolbar, or choose Table > Number Format on the Menu bar. On the Format Number dialog (Figure 16), you can set options for various categories of numerical data.
In the Category list, select the category you want, such as currency, date, or text.
In the Format list, choose a format for the category you just selected.
For some categories, such as Date, you may wish to change the language using the Language list, while for other numerical categories you can use the Options section of the dialog to customize the appearance.
Tip
Writer displays the formatting code for the category and format selected in Format Code section at the bottom of the dialog. For example, if you select a date format such as 31 Dec 1999 the corresponding code is D MMM YYYY. Advanced users can easily customize this formatting code as well as create new user-defined codes.
Figure 16: Format Number dialog
You can rotate text in a table cell by 90 or 270 degrees. Text rotation can be useful when you have long headings for narrow columns.
Select the text to be rotated and then choose Format > Character, or right-click and select Character > Character in the context menu.
On the Position tab, in the Rotation / Scaling section, choose the rotation angle, optionally change the Scale width, and click OK.
Note
Text rotation within table cells can also be achieved with the use of paragraph styles, discussed in Chapter 9, Working with Styles.
To move between cells within a table, use the mouse, the arrow keys, or the Tab key.
The arrow keys move the cursor one text character left or right at a time. If a cell is empty, pressing the arrow key moves the cursor to the adjacent cell.
The Tab key moves directly to the next cell and, if the cursor is in the last cell in the table, creates a new row. Pressing Shift+Tab moves the cursor back a cell.
Tip
To enter a Tab character as part of the text of the cell, press the Ctrl and Tab keys at the same time.
To move to the beginning of the table, press Ctrl+Home. If the active cell is empty, the move is to the beginning of the table. If the cell has content, the first press goes to the beginning of the cell and the next press goes to the beginning of the table. (Pressing again goes to the beginning of the document.)
To move to the end of the table, press Ctrl+End. If the active cell is empty, the move is to the end of the table. If the cell has content, the first press goes to the end of the cell and the next press goes to the end of the table. (Pressing again goes to the end of the document.)
Just as in a spreadsheet, data in a table can be sorted. You can specify up to three levels of sorting (for example, sort first by age numerically, then alphabetically by name within each age).
To sort data in a table:
1) Select the table (or part of the table) to be sorted.
2) Choose Table > Sort on the Menu bar, or click the Sort icon on the Table toolbar.
3) In the Sort dialog (Figure 17):
a) Decide whether you want to sort in the direction of rows or columns. The default sorting direction is by rows, which results in sorting the data in a column.
b) Select up to three keys to sort on, in the correct order.
c) For each key, select which column or row to sort on, whether the sort is Numeric or Alphanumeric and whether it is Ascending or Descending.
d) Click OK to perform the sort.
Figure 17: Selecting criteria for sorting
Note
Be sure to select all cells that might be affected by the sorting. For example, if you select only the cells of one column, the sort affects that column only, while the others remain unchanged. In such a case, you risk mixing the data of the rows.
For many simple mathematical functions, Writer tables can be used as basic spreadsheets. Just as in a spreadsheet, each table cell is identified by a letter (for the column) and a number (for the row). For example, cell C4 is the cell in the third column from the left and fourth row from the top. When the cursor is in a cell, the table name and this cell reference is displayed on the status bar.
Tip
Basic spreadsheet functions in tables are much the same as in LibreOffice Calc. The main difference is that cell references are formatted differently. Cell A2 (first column, second row) is referred to in Calc as A2 (or $A$2 for an absolute reference). In Writer tables, it is referred to as <A2>.
For example, suppose you had two numbers in cells <B1> and <C2> and wanted to display the sum of the two in cell <A1>, as shown in Figure 18.
Do the following to sum up 4 and 5:
Click in cell <A1> and press the = key, or choose Table > Formula on the Menu bar, or press F2, or click the Sum icon or the Formula icon on the Table toolbar, or click the Formula icon in the Table panel of the Properties deck on the Sidebar.
The Formula bar appears automatically at the top of the workspace. In the leftmost side of the bar, you can see the coordinates of the selected cell.
Click in cell <B1>. The identifiers of this cell are automatically displayed in the Formula bar and inserted into cell <A1>.
Press the + key.
Click in cell <C2>. You can see the final formula = <B1>+<C2> displayed both in the selected cell and on the Object bar.
Press the Enter key, or click the green check mark (may be a different symbol on some installations) on the Formula Bar, to replace the formula in the cell with the result of the calculation.
Figure 18: Using spreadsheet functions in a table
Tip
To display a cell's formula and make it available for editing, choose Table > Formula on the Menu bar, or use one of the other methods above.
To display the list of the mathematical functions available for use in a table, display the Formula toolbar and then click the Formula f(x) icon.
In our example, this gives the result 9 in the top left cell. For summing contiguous cells, you can simply select the cells in the row, column, or the rectangle of rows and columns. Thus, for example, to add a column of numbers, do this:
1) Type an equals sign = in an empty cell.
2) Select the cells to be added together, in this case the cells from A2 to A5. The formula should be something like =<A2:A5>.
3) Press the Enter key or click the green check mark on the Formula Bar.
4) The result appears in the empty cell where you entered the formula.
When using a function, you can type the cell references manually or select them. Thus, to add up the four numbers that we added above (A2, A3, A4, A5), do this:
1) Type an equals sign = in an empty cell.
2) Type sum or select it from the function list f(x).
3) Select the contiguous cells to be added together. The formula should be something like =sum<A2:A5>.
4) Press the Enter key or click the green check mark on the Formula Bar. The answer appears in the empty cell where you entered the formula.
Caution
In Writer, formulas are not updated automatically when inserting or deleting rows or columns of the table, although the results do update when a value is changed in a cell. To use complex formulas, consider embedding a Calc spreadsheet in the Writer document. See Chapter 19, Spreadsheets, Charts, Other Objects.
You can protect the contents of individual cells of a table from changes. When a cell is protected, most of the menu items and toolbar icons are inactivated.
Note
This protection is not intended for secure protection. It protects the cells against accidental changes.
To turn on cell protection, place the cursor in a cell or select cells, then click the Protect Cells icon on the Table toolbar or choose Table > Protect Cells on the Menu bar.
To tun off cell protection, place the cursor in the cell or select the cells. Then click the Unprotect Cells icon on the Table toolbar or choose Table > Unprotect Cells on the Menu bar.
To remove protection for the entire current table or all selected tables, press Shift+Ctrl+T.
Tip
If you cannot place the cursor in a protected cell, you need to enable the cursor. Choose Tools > Options > LibreOffice Writer > Formatting Aids and in the Protected Areas section mark Enable cursor.
You can easily add a caption to any table. Writer will keep track of all your captioned tables, automatically number them, and update any links to them. To add a caption to a table:
1) Right-click anywhere in the table and select Insert Caption in the context menu, or choose Insert > Caption on the Menu bar, or click the Insert Caption icon on the Table toolbar.
2) Under Properties on the Caption dialog, make your selections for the Category (it defaults to Table, which is usually what you want), Numbering, and Separator fields. The position of the caption defaults to above a table; you can change this if necessary.
3) Type your caption text in the text box at the top of the dialog.
4) Click OK.
You can also set up Writer to add captions to tables automatically. The procedure is the same as for adding captions automatically to images, described in Chapter 11.
You can insert a cross‑reference to a captioned table. Clicking on the cross-reference takes the reader directly to the table. For details, see Chapter 17, Fields.
One table can be split into two tables, and two tables can be merged into a single table. Tables are split horizontally: the rows above the split point are put into one table, and the rows below into another. To split a table:
1) Place the cursor in a cell that will be in the top row of the second table after the split (the table splits immediately above the cursor).
2) Choose Table > Split Table on the Menu bar or click the Split Table icon on the Table toolbar.
3) A Split Table dialog opens, where you can choose how to handle heading rows.
4) Click OK. The table is then split into two tables separated by a blank paragraph.
Note
If cells in one table include formulas using data from the other table, those cells will contain an error message: **Expression is faulty**.
To merge two tables:
1) Delete the blank paragraph between the tables. You must use the Delete key (not the Backspace key) to do this.
2) Select any cell in one of the tables.
3) Choose Table > Merge Table from the Menu bar.
Tip
To see clearly where the paragraphs are and to delete them easily, choose View > Formatting Marks (Ctrl+F10) or click the ¶ icon in the Standard toolbar.
To delete a table, do any of the following:
Right-click anywhere in the table and choose Delete > Table in the context menu.
Click anywhere in the table and choose Table > Delete > Table on the Menu bar.
Select from the end of the paragraph before the table to the start of the paragraph after the table, and then press the Delete key or the Backspace key.
Note
The third method also merges the paragraph after the table with the paragraph before the table, which may not be what you want.
To copy a table from one part of the document and paste it into another part:
1) Select the table.
2) Press Ctrl+C or click the Copy icon on the Standard toolbar.
3) Click where you want the table to be copied.
4) Press Ctrl+V or click the Paste icon on the Standard toolbar.
To move a table from one part of a document to another part:
1) Select the table.
2) Press Ctrl+X or click the Cut icon on the Standard toolbar.
3) Click where you want the table to be moved.
4) Press Ctrl+V or click the Paste icon on the Standard toolbar. This pastes the cells and their contents and formatting.
To insert a paragraph before a table, position the cursor before any text or other contents in the first (upper left-hand) cell and press Alt+Enter. To insert a paragraph after a table, position the cursor after any text in the last (lower right-hand) cell and press Alt+Enter.
Tables may be used as a page layout tool to position text in a document instead of using tabs or spaces. For more information and tips about using tables in page layout, see Chapter 6, Formatting Pages: Advanced.