Styling tables

Everything related to our flagship word processor.
Post Reply
roblgs
Posts: 14
Joined: 2007-04-12 02:17:08

Styling tables

Post by roblgs »

Hi,

When placing tables into a document I need to apply 'space after' the preceding element as there is no means of applying 'space before' to the table itself. The same is true for space after a table... it needs to be simulated by setting 'space before' on the following item rather than being directly applicable to the table itself.

Going further, I'm working on a document that uses a lot of tables with different colour backgrounds and borders to mean specific things... 'error', 'warning' and 'no problem'.

While I can get the result I want by setting each one up and then copy/pasting as required, it gets to be a chore in a long document with lots of such tables. It would be better if it were possible to setup a specific style and attach this to the tables as necessary.

Copy/paste would be easier if there were split-screen editing available.

Thoughts on possibilities or is it wishful thinking?

Cheers


Rob
Þorvarður
Posts: 410
Joined: 2012-12-19 05:02:52

Re: Styling tables

Post by Þorvarður »

roblgs wrote: I'm working on a document that uses a lot of tables with different colour backgrounds and borders to mean specific things... 'error', 'warning' and 'no problem'.

While I can get the result I want by setting each one up and then copy/pasting as required, it gets to be a chore in a long document with lots of such tables. It would be better if it were possible to setup a specific style and attach this to the tables as necessary.

Copy/paste would be easier if there were split-screen editing available.
Hi Rob,

I would use the glossary feature. Set up the table, format it, use frames and colors, etc. When you are done, select the table and create a glossary entry. If you do this, you never have to copy and paste the table again. Saves you a lot of time.

Þorvarður
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Styling tables

Post by phspaelti »

Actually you can "place" a table by dragging it (the whole table).
space_before_table.jpg
space_before_table.jpg (52.85 KiB) Viewed 9199 times
Last edited by phspaelti on 2013-09-06 06:44:54, edited 1 time in total.
philip
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Styling tables

Post by phspaelti »

roblgs wrote:Going further, I'm working on a document that uses a lot of tables with different colour backgrounds and borders to mean specific things... 'error', 'warning' and 'no problem'.

While I can get the result I want by setting each one up and then copy/pasting as required, it gets to be a chore in a long document with lots of such tables. It would be better if it were possible to setup a specific style and attach this to the tables as necessary.
Yes, I've been hoping we would get menu and/or macro controls for cell borders and shadings etc., but unfortunately not (yet?).
philip
User avatar
martin
Official Nisus Person
Posts: 5227
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: Styling tables

Post by martin »

Þorvarður wrote:I would use the glossary feature. Set up the table, format it, use frames and colors, etc. When you are done, select the table and create a glossary entry. If you do this, you never have to copy and paste the table again. Saves you a lot of time.
That's one way to help, though it doesn't entirely solve the problem. Consider if you already inserted 3 copies of this template table into your document, but later decided the shading in the table header row should be a different color. There's no way to automatically change them all at the same time, like there is with textual styles.

Here's a macro that helps ease such a situation, though it doesn't cover all the scenarios. The macro will take a look at the current table selection, and then select the same cells in all the document's tables:

Code: Select all

# This macro looks at the existing table selection, and then selects the same
# corresponding cells in all tables in the document.
$doc = Document.active
$selection = $doc.tableSelection

If ! $selection
	Prompt "Please make a selection in a table."
	Exit
End


# Now select the same cells in all tables
$newSelections = Array.new
$errorCount = 0

$rows = $selection.rowRange
$cols = $selection.columnRange

$tables = $doc.text.tables
ForEach $table in $tables
	# make sure the same cells are in bounds for this table
	$canSelect = false
	If $rows.bound <= $table.rowCount
		If $cols.bound <= $table.columnCount
			$canSelect = true
		End
	End
	# generate selection or warn
	If $canSelect
		$select = TableSelection.new($table, $rows, $cols)
		$newSelections.appendValue($select)
	Else
		$errorCount += 1
	End
End

# select as needed
$doc.setSelection($newSelections)

If $errorCount > 0 
	Prompt "Could not mirror the selection in $errorCount tables.", 'Current row/column was out of bounds for those tables.'
End
Once you have the selections made in all tables, you can adjust the borders/shading for all those cells as you like.

Obviously there are a lot of limitations with this: you can't change cell sizes, logically different kinds of tables will be indiscriminately selected, you might have slightly different tables that should share cell properties, etc. Basically what NWP really needs is some kind of table/cell style system.
roblgs
Posts: 14
Joined: 2007-04-12 02:17:08

Re: Styling tables

Post by roblgs »

Hi,
phspaelti wrote:Actually you can "place" a table by dragging it (the whole table).
space_before_table.jpg
Thanks... that's something I wasn't aware of and produces the sort of result I'm after spacing-wise... but it's applied one table at a time and by sight... With 20–30 or more tables it becomes a bit of a chore, as is achieving completely consistent results on each table.

Ideally though I'd want the ability to attache this gap to all tables automatically by means of a table-style... that could also set borders, background colours and so on...

This sort of thing is trivial in HTML/CSS.

Thanks again


Rob
roblgs
Posts: 14
Joined: 2007-04-12 02:17:08

Re: Styling tables

Post by roblgs »

Hi,
Þorvarður wrote:Hi Rob,

I would use the glossary feature. Set up the table, format it, use frames and colors, etc. When you are done, select the table and create a glossary entry. If you do this, you never have to copy and paste the table again. Saves you a lot of time.

Þorvarður
Thanks for the suggestion... I was looking for something of the sort as a half-way-house type of solution, but was thinking 'scrapbook' not 'glossary'.

It would achieve same result as I am currently managing, but without the constant scrolling, which is a huge improvement.

However it also comes up short in terms of making any subsequent changes that need to be globally applied to these tables, and the macro-based solution to that is also not as complete as would be the case if this were possible through dedicated table-styles.

I will though be using it until table-styles become a reality :)

Cheers

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

Re: Styling tables

Post by martin »

roblgs wrote:the macro-based solution to that is also not as complete as would be the case if this were possible through dedicated table-styles.

I will though be using it until table-styles become a reality :)
Here's another macro that may (or may not) be more useful as a stopgap. Rather that mirroring the existing table selection, and potentially not successfully selecting parts of tables with a different size, this macro will select some pre-defined areas (eg: column headers) of all tables:

Code: Select all

# This macro selects all tables in the document.
# It has options that allow you to choose which parts of all tables to select.

$doc = Document.active
If ! $doc
	Exit
End

$tables = $doc.text.tables
If $tables.count == 0
	Prompt "This document does not have any tables to select.”
	Exit
End


# Ask the user what part of the table to select
$mess = “What parts of every table would you like to select?”
$parts = Array.new(“All Cells”, “Column Headers”, “Row Headers”, “Non-Header Cells”)
$part = Prompt Options $mess, ‘’, ‘Select Cells’, $parts


# Now select the cells in all tables
$newSelections = Array.new

ForEach $table in $tables
	If $part == ‘All Cells’
		$rows = Range.new( 0, $table.rowCount )
		$cols = Range.new( 0, $table.columnCount )
	ElseIf $part == ‘Column Headers’
		$rows = Range.new( 0, 1 )
		$cols = Range.new( 0, $table.columnCount )
	ElseIf $part == ‘Row Headers’
		$rows = Range.new( 0, $table.rowCount )
		$cols = Range.new( 0, 1 )
	ElseIf $part == ‘Non-Header Cells’
		$rows = Range.new( 1, $table.rowCount - 1 )
		$cols = Range.new( 1, $table.columnCount - 1 )
	End
	
	If $rows.length > 0
		If $cols.length > 0
			$select = TableSelection.new($table, $rows, $cols)
			$newSelections.appendValue($select)
		End
	End
End

# select as needed
$doc.setSelection($newSelections)
Post Reply