[LibreOffice Writer] Table with alternative row color

classic Classic list List threaded Threaded
13 messages Options
Rafnews Rafnews
Reply | Threaded
Open this post in threaded view
|

[LibreOffice Writer] Table with alternative row color

Hi,

I'm looking for a simple and automatic way how to tell to my tables in a
writer document, to be formatted with alternative 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 ?
thx
--

Best Regards

Alain R.

The information contained in this e-mail message is privileged and
confidential and is for the exclusive use of the addressee. The person
who receives this message and who is not the addressee, one of his
employees or an agent entitled to hand it over to the addressee, is
informed that he may not use, disclose or reproduce the contents
thereof. Please do not disclose the contents to anyone, but notify the
sender by return email and delete this email (and any attachments) from
your system. Thank you.

--
To unsubscribe e-mail to: [hidden email]
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
Andreas Säger Andreas Säger
Reply | Threaded
Open this post in threaded view
|

Re: [LibreOffice Writer] Table with alternative row color

Am 15.04.2015 um 14:10 schrieb Rafnews:

> Hi,
>
> I'm looking for a simple and automatic way how to tell to my tables in a
> writer document, to be formatted with alternative 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 ?
> thx


menu:Table>AutoFormat...




--
To unsubscribe e-mail to: [hidden email]
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
jonathon-6 jonathon-6
Reply | Threaded
Open this post in threaded view
|

Re: [LibreOffice Writer] Table with alternative row color

In reply to this post by Rafnews


On April 15, 2015 5:10:03 AM PDT, Rafnews  wrote:

>I'm looking for a simple and automatic way how to tell to my tables in
>a writer document, to be formatted with alternative rows color
>for example even rows will be blue in the background and odd rows will
>have a light blue as background color.

Try the Color2Rows extension, available at http://extensions/openoffice.org/en/project/color2rows.

jonathon
--
Multilingual ODF Office Suite Support.

--
To unsubscribe e-mail to: [hidden email]
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
Brian Barker Brian Barker
Reply | Threaded
Open this post in threaded view
|

Re: [LibreOffice Writer] Table with alternat[]e row color

In reply to this post by Rafnews
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


--
To unsubscribe e-mail to: [hidden email]
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

James E. Lang James E. Lang
Reply | Threaded
Open this post in threaded view
|

(no subject)

 [hidden email])
Subject: Re: [libreoffice-users] [LibreOffice Writer] Table with alternat[]e
 row color
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

Alain,

I don't know whether you consider this to be "simple and automatic" but what I've found is this:

Use LibreOffice to create a spreadsheet.

Select the table space.

Use Format=>Conditional Formatting=>Condition

Condition 1:
  Formula is ISEVEN(ROW())
  select or create your style for even rows

Add

Condition 2:
  Formula is ISODD(ROW())
  select or create your style for odd rows

OK

Copy the selected cells and paste them into your writer document.

This is the best solution I have found. Maybe it will tickle someone else's creativity to come up with a better solution.

--
Jim

-----Original Message-----
From: Brian Barker <[hidden email]>
To: [hidden email]
Sent: Sun, 19 Apr 2015 16:23
Subject: Re: [libreoffice-users] [LibreOffice Writer] Table with alternat[]e row color

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


--
To unsubscribe e-mail to: [hidden email]
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


--
To unsubscribe e-mail to: [hidden email]
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

Brian Barker Brian Barker
Reply | Threaded
Open this post in threaded view
|

Re: Table with alternat[]e row color

At 20:21 19/04/2015 -0700, James E Lang wrote:

>From: Brian Barker:
>>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.
>
>Alain, I don't know whether you consider this to be "simple and
>automatic" but what I've found is this:
>
>Use LibreOffice to create a spreadsheet. Select the table space. Use
>Format=>Conditional Formatting=>Condition
>Condition 1:
>   Formula is ISEVEN(ROW())
>   select or create your style for even rows
>
>Add
>Condition 2:
>   Formula is ISODD(ROW())
>   select or create your style for odd rows
>
>OK. Copy the selected cells and paste them into your writer
>document. This is the best solution I have found. Maybe it will
>tickle someone else's creativity to come up with a better solution.

It's not clear whether you appreciate that this is the method that I
described as a dead duck! Could you come clean about exactly how you
are making this work, please?

Depending on how I paste the cell range from a spreadsheet, I can create:
o a striped graphic with no row or column structure - just a picture,
o an embedded spreadsheet section,
o a blank picture,
o a stack of paragraphs containing only sequences of tab characters, or
o the required table - but without the background formatting!

In particular, freezing the effect of the conditional formatting in
the spreadsheet before copying the range of cells to the text
document might be expected to work, but I didn't see any way to do this.

A striped panel is not going to provide the alternately coloured
table rows that the questioner wanted. Do please explain how you have
managed to paste the spreadsheet range to create a *formatted table*
in the text document.

Brian Barker  


--
To unsubscribe e-mail to: [hidden email]
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

James E. Lang James E. Lang
Reply | Threaded
Open this post in threaded view
|

(no subject)

 [hidden email])
Subject: Re: [libreoffice-users] Table with alternat[]e row color
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

I performed a simple paste. I guess that technically it's an image (or if you like, a picture) but the contents can be editted.

I don't generally use Writer but I do use Calc a lot. I knew that I could generate the alternating color bands in Calc by means of formulas so I first looked for that functionality in Writer to no avail. Then I tried the technique I posted and editted the data successfully so I posted it.

Maybe I'm being over sensitive but I sensed hostlity in your response to me. I thought this list was one where everyone (expert or novice) shared for the benefit of all.

--
Jim

-----Original Message-----
From: Brian Barker <[hidden email]>
To: [hidden email]
Sent: Sun, 19 Apr 2015 22:27
Subject: Re: [libreoffice-users] Table with alternat[]e row color

At 20:21 19/04/2015 -0700, James E Lang wrote:

>From: Brian Barker:
>>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.
>
>Alain, I don't know whether you consider this to be "simple and
>automatic" but what I've found is this:
>
>Use LibreOffice to create a spreadsheet. Select the table space. Use
>Format=>Conditional Formatting=>Condition
>Condition 1:
>   Formula is ISEVEN(ROW())
>   select or create your style for even rows
>
>Add
>Condition 2:
>   Formula is ISODD(ROW())
>   select or create your style for odd rows
>
>OK. Copy the selected cells and paste them into your writer
>document. This is the best solution I have found. Maybe it will
>tickle someone else's creativity to come up with a better solution.

It's not clear whether you appreciate that this is the method that I
described as a dead duck! Could you come clean about exactly how you
are making this work, please?

Depending on how I paste the cell range from a spreadsheet, I can create:
o a striped graphic with no row or column structure - just a picture,
o an embedded spreadsheet section,
o a blank picture,
o a stack of paragraphs containing only sequences of tab characters, or
o the required table - but without the background formatting!

In particular, freezing the effect of the conditional formatting in
the spreadsheet before copying the range of cells to the text
document might be expected to work, but I didn't see any way to do this.

A striped panel is not going to provide the alternately coloured
table rows that the questioner wanted. Do please explain how you have
managed to paste the spreadsheet range to create a *formatted table*
in the text document.

Brian Barker  


--
To unsubscribe e-mail to: [hidden email]
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


--
To unsubscribe e-mail to: [hidden email]
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

Brian Barker Brian Barker
Reply | Threaded
Open this post in threaded view
|

Re: Table with alternat[]e row color

At 22:51 19/04/2015 -0700, James E Lang wrote:
>Maybe I'm being over sensitive but I sensed hostility in your response to me.

Oh, no: not at all! Sorry you got that impression. Indeed, I was
surprised that you hadn't explicitly suggested that my rejection of
the method as a dead duck in my earlier message was wrong. And I
replied as I assumed that, unlike me, you had made this method work
and I was genuinely interested to know how.

>I thought this list was one where everyone (expert or novice) shared
>for the benefit of all.

Of course it is! Let's not change that.

Brian Barker  


--
To unsubscribe e-mail to: [hidden email]
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

James E Lang-2 James E Lang-2
Reply | Threaded
Open this post in threaded view
|

(no subject)

 [hidden email])
Subject: Re: [libreoffice-users] Table with alternat[]e row color
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

Thanks Brian. It looks like Paste in this case is the same as Paste Special Calc8. They both retain the colors, some formulas, and spreadsheet context (Row & Column identities).

--
Jim

-----Original Message-----
From: Brian Barker <[hidden email]>
To: [hidden email]
Sent: Sun, 19 Apr 2015 23:13
Subject: Re: [libreoffice-users] Table with alternat[]e row color

At 22:51 19/04/2015 -0700, James E Lang wrote:
>Maybe I'm being over sensitive but I sensed hostility in your response to me.

Oh, no: not at all! Sorry you got that impression. Indeed, I was
surprised that you hadn't explicitly suggested that my rejection of
the method as a dead duck in my earlier message was wrong. And I
replied as I assumed that, unlike me, you had made this method work
and I was genuinely interested to know how.

>I thought this list was one where everyone (expert or novice) shared
>for the benefit of all.

Of course it is! Let's not change that.

Brian Barker  


--
To unsubscribe e-mail to: [hidden email]
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


--
To unsubscribe e-mail to: [hidden email]
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

Andrew Douglas Pitonyak Andrew Douglas Pitonyak
Reply | Threaded
Open this post in threaded view
|

Re: [LibreOffice Writer] Table with alternat[]e row color

In reply to this post by Brian Barker


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: [hidden email]
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

pietervo pietervo
Reply | Threaded
Open this post in threaded view
|

Re: [LibreOffice Writer] Table with alternat[]e row color

In reply to this post by Brian Barker
I din't remember if this has already been mentioned in this thread, but you can do this simply with an Autoformat.

Just take 3 rows of your table (or create a special table for this). Then color the rows alternatively. Or you can color the header row with a different color if so desired. Then select these 3 rows and click "Table -> AutoFormat". Click "Add"" and give your autoformat a name.
Then select the table to be formatted and Autoformat it with the newly created AutoFormat. You can indicate if you want a header row.

You can also create the AutoFormat in a Calc spreadsheet, but there you need at least a 3x3 rectangle. In a Writer table you only need at least 3 rows.

It is also possible to do striped columns, then you would need at least 3 columns.

Some Caveats:
1. In Calc If you give the new AutoFormat a name that lexicographically sorts before "Default", e.g. when it starts with A, B or C, then it just disappears. In Writer that is not the case.

2. If you later insert or delete an odd number of rows from the table, they will no longer be alternatively colored. You will have to re-apply the format.

3. An autoformat has a column header (the first row) that you can disable when applying the AutoFormat. It also has a totals row at the bottom, and a rows header column and a totals column at the right that you cannot disable (This is a design error). If you don't color your columns differently the row header and Totals columns are no problem. But the Totals row always gets the color of the last row in the AutoFormat, and so if your AutoFormat has an even number of rows (excluding a possible header row), and your table has an odd number of rows, or vice versa, then the last row will get the wrong color. You can correct this by creating the table with one row more, and then deleting the last row. If you would have striped columns, I guess the same will happen in the other direction, but I haven't tried.

--
Piet van Oostrum <[hidden email]>
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]

--
To unsubscribe e-mail to: [hidden email]
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

Brian Barker Brian Barker
Reply | Threaded
Open this post in threaded view
|

Re: [LibreOffice Writer] Table with alternat[]e row color

At 14:59 20/04/2015 +0200, Piet van Oostrum wrote:
>I din't remember if this has already been mentioned in this thread,
>but you can do this simply with an Autoformat.
>
>Just take 3 rows of your table (or create a special table for this).
>Then color the rows alternatively. Or you can color the header row
>with a different color if so desired. Then select these 3 rows and
>click "Table -> AutoFormat". Click "Add"" and give your autoformat a name.
>Then select the table to be formatted and Autoformat it with the
>newly created AutoFormat. You can indicate if you want a header row.

Aha: the perfect answer!

Brian Barker


--
To unsubscribe e-mail to: [hidden email]
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

James E. Lang James E. Lang
Reply | Threaded
Open this post in threaded view
|

Re: [LibreOffice Writer] Table with alternat[]e row color

In reply to this post by Andrew Douglas Pitonyak
Thank you Andrew. That looks like it's a full answer to the question. I have learned something from this. I might not use it often but I now have it in my bag of tools and who knows ....

--
Jim

-----Original Message-----
From: Andrew Pitonyak <[hidden email]>
To: "James E. Lang" <[hidden email]>
Sent: Mon, 20 Apr 2015 11:40
Subject: Re: [libreoffice-users] [LibreOffice Writer] Table with alternat[]e row color

On 20.04.2015 10:03, James E. Lang wrote:
> Hi Andrew,
>
> This message is off list for technical reasons.

No problem, especially for this type of question :-)

>
> As I stated in a message that I posted to the list yesterday, I don't
> do a lot of work with
> LibreOffice Writer. That said, I tried your macro and it choked
> (Sub-procedure or function
> procedure not defined) on this line:
>
>     SetParStyle(oCell.getText(), "OOoTableHeader")


Yeah, sorry about that. What this is doing is setting the first row to
use the paragraph style named "OOoTableHeader". I don't know if you have
seen any of my documents, but it is how I format my text tables in
general. You can comment out that line, or, change "OOoTableHeader" to
be the paragraph style that you want to use.

There is another line below it

SetParStyle(oCell.getText(), "OOoTableText")

This sets all of the other lines to use the paragraph style
"OOoTableText", which is probably a paragraph style that you do not have
if you do not write documentation for LibreOffice.

Comment out these two lines by placing a single quote before them or
the text REM as follows:

'SetParStyle(oCell.getText(), "OOoTableText")
REM SetParStyle(oCell.getText(), "OOoTableText")



>
> Is this because I don't have the jre installed or is there something
> else that is required
> (defining the UNO interface maybe?) beyond the Sub you posted?
>
> My Macros=>Standard=>Module1 contains only the empty Sub Main, three
> pure Basic (UNO
> free) functions that I wrote for a spreadsheet, and your Sub
> FormatTable which I copied from
> the eMail and pasted into the module.
>
> --
> Jim
>
> On 20 Apr 2015 at 8:03, Andrew Douglas Pitonyak wrote:
>
>> 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

--
To unsubscribe e-mail to: [hidden email]
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