On 04/19/2015 07:22 PM, Brian Barker wrote:
At 14:10 15/04/2015 +0200, Alain Ronly wrote:
I'm looking for a simple and automatic way how to tell to my tables
in a writer document, to be formatted with alternat[]e rows color for
example even rows will be blue in the background and odd rows will
have a light blue as background color. I did not find any easy way to
do it. Is there someone who has already solved this topic ?
Not me.
o Once you have set the background colour for one row, you can use the
Format Paintbrush to paint the same colour on other rows. If you
double-click the button, you can drag the "paint bucket" across
alternate rows to achieve one colour and then repeat the process for
the other colour.
o For large numbers of rows, you can copy an entire existing table and
paste it immediately following - and you can repeat that process.
You'll end up with multiple tables, but that may suffice, providing
you delete the empty paragraph between them. If you need to, you can
put the cursor into the second table and go to Table | Merge Tables
(or right-click | Merge Tables) to merge the two tables into one.
o It is somewhat easier to set up such background colouring in a
spreadsheet than in a Writer table. If you colour two rows you can
easily copy them to two more. Then you can copy four rows to create
eight in total. With this binary multiplication, you can very quickly
achieve the desired size. If you then copy an appropriately-sized
section of the spreadsheet and paste it into your text document using
Paste Special... and "HTML (HyperText Markup Language)" you will get a
table with the same background formatting. The table properties can be
adjusted as necessary.
o The automatic way to colour spreadsheet rows alternately is to use
Conditional Formatting and create a formula using the ROW() function
to determine the oddness or evenness of the row number and control the
background colouring using cell styles. But unfortunately - and as you
might expect - the effect of such formatting is lost if you paste a
copy into a text document as a table. So that's a dead duck.
o It's probably much easier to set up formatting such as this before
you insert your data. If necessary, you should be able to copy any
existing material and paste it into a new, formatted table.
I trust this helps.
Brian Barker
I wrote a macro some years back and I still use it today. You probably
have no interest in the part that sets the borders...
Sub FormatTable(Optional oUseTable)
Dim oTable
Dim oCell
Dim nRow As Long
Dim nCol As Long
If IsMissing(oUseTable) Then
oTable = ThisComponent.CurrentController.getViewCursor().TextTable
Else
oTable = oUseTable
End If
If IsNull(oTable) OR IsEmpty(oTable) Then
Print "FormatTable: No table specified"
Exit Sub
End If
Dim v
Dim x
v = oTable.TableBorder
x = v.TopLine
x.OuterLineWidth = 2
v.TopLine = x
x = v.LeftLine
x.OuterLineWidth = 2
v.LeftLine = x
x = v.RightLine
x.OuterLineWidth = 2
v.RightLine = x
x = v.TopLine
x.OuterLineWidth = 2
v.TopLine = x
x = v.VerticalLine
x.OuterLineWidth = 2
v.VerticalLine = x
x = v.HorizontalLine
x.OuterLineWidth = 0
v.HorizontalLine = x
x = v.BottomLine
x.OuterLineWidth = 2
v.BottomLine = x
'v.Distance = 51
oTable.TableBorder = v
For nRow = 0 To oTable.getRows().getCount() - 1
For nCol = 0 To oTable.getColumns().getCount() - 1
oCell = oTable.getCellByPosition(nCol, nRow)
If nRow = 0 Then
oCell.BackColor = 128
SetParStyle(oCell.getText(), "OOoTableHeader")
Else
SetParStyle(oCell.getText(), "OOoTableText")
If nRow MOD 2 = 1 Then
oCell.BackColor = -1
Else
REM color is (230, 230, 230)
oCell.BackColor = 15132390
End If
End If
Next
Next
End Sub
--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
Info: http://www.pitonyak.org/oo.php
--
To unsubscribe e-mail to: users+unsubscribe@global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted
Context
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.