Copying Cell Attributes?

Everything related to our flagship word processor.
Post Reply
goldste4
Posts: 98
Joined: 2010-02-22 15:06:48

Copying Cell Attributes?

Post by goldste4 »

Hello All,

I have a table where a number of discontinuous cells have the same cell shading. Is there an easy way to copy cell shading from one cell to another one?

Also, the manual seems to indicate that one can create styles for table cells, but I'm a bit uncertain how to do that. When I create either a new paragraph or character style, I don't seem to have access to any of the Table Cell palettes.

Thanks in advance,
Josh
Kino
Posts: 400
Joined: 2008-05-17 04:02:32

Re: Copying Cell Attributes?

Post by Kino »

I don’t know about the first problem but . . .
Also, the manual seems to indicate that one can create styles for table cells, but I'm a bit uncertain how to do that.
It’s a Paragraph style you can create and edit in the Style Sheet view.
TableCell.png
TableCell.png (61.55 KiB) Viewed 12707 times
goldste4
Posts: 98
Joined: 2010-02-22 15:06:48

Re: Copying Cell Attributes?

Post by goldste4 »

Hello Kino,

When I try to edit that style, NWP won't allow me to modify the table cell attributes (e.g., to set the cell shading): they are grayed out. I'm not sure if this is a problem with me or my NWP or what.

What I would like to do is set up a number of table cell styles and then apply them to the cells I need, just as I would do with paragraph styles and text.

Thanks,
Josh
User avatar
martin
Official Nisus Person
Posts: 5228
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: Copying Cell Attributes?

Post by martin »

Hi Josh- I'm afraid that there are no proper table/cell styles in NWP. What we refer to as the "Table Cell" style is just a regular paragraph style that controls font, line spacing, etc. There's no opportunity to systematically control table cell properties like shading, borders, etc. The same goes for your first problem- there's no way to easily copy/sync cell properties between existing cells. The best you can do is to create a multipart selection that includes all the table cells at once (and then change the desired cell properties directly). Sorry to not have better news.
goldste4
Posts: 98
Joined: 2010-02-22 15:06:48

Re: Copying Cell Attributes?

Post by goldste4 »

Hi Martin, thanks. Selecting noncontiguous cells will do for now. Of course, it would be nice to either have true table cell styles or to be able to copy and paste cell attributes just like you can do with text attributes (btw, the copy and paste ruler feature of NWP is very nice and handy!).
Josh
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Copying Cell Attributes?

Post by phspaelti »

What I would really like to see in this regard is the ability to control these things with macros. I guess there are several ways this could be implemented. If these "styles" were handled in the same way as other styles, then this woud presumably be one possible solution.
philip
Kino
Posts: 400
Joined: 2008-05-17 04:02:32

Re: Copying Cell Attributes?

Post by Kino »

goldste4 wrote:Selecting noncontiguous cells will do for now.
If what you want to achieve is something like this, the macro below will help you by making such selections. You still have to apply cell attributes manually, though.
table.png
table.png (18.42 KiB) Viewed 12486 times

Code: Select all

# Put the insertion point somewhere within a table and run the macro.
# You will be asked to specify the starting row number.

$doc = Document.active
if $doc == undefined
	exit  # no open document
end

$tblsel = $doc.tableSelection
if $tblsel == undefined
	exit 'No selection in a table, exiting...'
end

$table = $tblsel.table
if $table.rowCount <= 2
	exit 'Table consisting of just one or two row(s), exiting...'
end

$i = Prompt Options 'Select every other row', 'starting from row #', '', 1, 2, 3
$i -= 1
$sels = Array.new
$c = Range.new 0, $table.columnCount

while $i < $table.rowCount
	$r = Range.new $i, 1
	$sel = TableSelection.new $table, $r ,$c
	$sels.appendValue $sel
	$i += 2
end

$doc.setSelections $sels
SelectEveryOtherRow_20110115_nwm.zip
(4.62 KiB) Downloaded 503 times
Kino

Edit: fixed a typo in the description of the macro.
goldste4
Posts: 98
Joined: 2010-02-22 15:06:48

Re: Copying Cell Attributes?

Post by goldste4 »

Thanks, Kino, a very helpful macro. Josh
User avatar
greenmorpher
Posts: 767
Joined: 2007-04-12 04:01:46
Location: Melbourne, Australia
Contact:

Re: Copying Cell Attributes?

Post by greenmorpher »

Hey, Kino -- can you modify this macro to work with columns instead of rows? That would be a great addition.

Kind regards

Geoffrey Heard
Business writer, Editor, Publisher
The Worsley Press
Kino
Posts: 400
Joined: 2008-05-17 04:02:32

Re: Copying Cell Attributes?

Post by Kino »

Hiya Geoff. Yes, just by exchanging ‘row’ and ‘column’ and ‘$c’ and ‘$r’ globally except in $sel = TableSelection.new $table, $r, $c near the end.
SelectEveryOtherColumn_20110205a_nwm.zip
(4.66 KiB) Downloaded 495 times

Code: Select all

$doc = Document.active
if $doc == undefined
	exit  # no open document
end

$tblsel = $doc.tableSelection
if $tblsel == undefined
	exit 'No selection in a table, exiting...'
end

$table = $tblsel.table
if $table.columnCount <= 2
	exit 'Table consisting of just one or two column(s), exiting...'
end

$i = Prompt Options 'Select every other column', 'starting from column #', '', 1, 2, 3
$i -= 1
$sels = Array.new
$r = Range.new 0, $table.rowCount

while $i < $table.columnCount
	$c = Range.new $i, 1
	$sel = TableSelection.new $table, $r ,$c
	$sels.appendValue $sel
	$i += 2
end

$doc.setSelections $sels
EDIT: Oup! there was a bug in the macro. I forgot to exchange ‘row’ and ‘column’ in the while . . . line. I corrected the code above and replaced the attached macro file with a corrected version.
User avatar
greenmorpher
Posts: 767
Joined: 2007-04-12 04:01:46
Location: Melbourne, Australia
Contact:

Re: Copying Cell Attributes?

Post by greenmorpher »

Hey Kino

Many thanks. I thought the process you outlined would be correct, but I made an error (or errors) and once off the path didn't know how to find my way back. :D

I'm sure others will find that useful too.

Cheers, geoff
Post Reply