Graphic Table

Sometimes the best way to display a data set is in a table, organized in rows and columns. And since OmniGraffle is all about visualizing data, it offers the ability to create fully editable tables by cloning a specified graphic to create tables of multiple “cells,” with each “table cell” being a clone of the original specified graphic.

Here are the scripting terms and commands for the Table class:

Table Constructors

Table Properties

Table Functions

Getting Tables

Here is a script for creating an array of references to all tables on the current canvas:

cnvs = document.windows[0].selection.canvas var tables = new Array() cnvs.graphics.forEach(function(graphic){ if(graphic.toString() === '[object Table]'){tables.push(graphic)} })

And here’s a script for creating an array of references to every table in the document:

var tables = new Array() canvases.forEach(function(cnvs){ cnvs.graphics.forEach(function(graphic){ if(graphic.toString() === '[object Table]'){tables.push(graphic)} }) })

Creating Tables

Using the commands and properties of the Table class, you can create automation tools for quickly building and editing tables.

Create Table by Cloning the Selected Graphic

In this first example, a table is constructed by cloning a selected graphic to be the cells of the created table. As you can see in the example, the process simply involves using a reference to the selected graphic to create a new table object, and then indicating the number of rows and column the table object should have. The result is a new table with the indicated number of rows and columns.

if(document.windows[0].selection.graphics.length == 1){ graphic = document.windows[0].selection.graphics[0] table = new Table(graphic) table.columns = 4 table.rows = 3 } else { new Alert('SELECTION ERROR','Please select a single graphic.').show(function(result){}) }
omnigraffle:///omnijs-run?script=if%28document%2Ewindows%5B0%5D%2Eselection%2Egraphics%2Elength%20%3D%3D%201%29%7B%0A%09graphic%20%3D%20document%2Ewindows%5B0%5D%2Eselection%2Egraphics%5B0%5D%0A%09table%20%3D%20new%20Table%28graphic%29%0A%09table%2Ecolumns%20%3D%204%0A%09table%2Erows%20%3D%203%0A%7D%20else%20%7B%0A%09new%20Alert%28%27SELECTION%20ERROR%27%2C%27Please%20select%20a%20single%20graphic%2E%27%29%2Eshow%28function%28result%29%7B%7D%29%0A%7D

Create a Cloned Table from JSON

Building upon the concepts used in the previous script, this script also creates a new table object using a selected graphic as the template for the table cells. However, this script determines the number of rows and columns to add to the table object, based upon the data in a JSON object (JSON = JavaScript Object Notation).

Once the table has been created, it is populated with the data from the JSON object.

if(document.windows[0].selection.graphics.length == 1){ graphic = document.windows[0].selection.graphics[0] // Reconstitute data from JSON string JSONstr = '[{"id":"ABV","state":"STATE","TSPCPC":"Cap Per Capita","TSPC":"Power(MW)","POPULATION":"POPULATION"},{"id":"AZ","state":"Arizona","TSPCPC":"166.9","TSPC":"1093.5","POPULATION":"6,553,225"},{"id":"HI","state":"Hawaii","TSPCPC":"136.5","TSPC":"190.0","POPULATION":"6,553,225"},{"id":"NV","state":"Nevada","TSPCPC":"122.9","TSPC":"339.1","POPULATION":"2,758,931"},{"id":"NJ","state":"New Jersey","TSPCPC":"109.6","TSPC":"971.4","POPULATION":"8,864,590"},{"id":"NM","state":"New Mexico","TSPCPC":"88.4","TSPC":"184.4","POPULATION":"2,085,538"},{"id":"CA","state":"California","TSPCPC":"66.7","TSPC":"2537.4","POPULATION":"38,041,430"}]' dataSet = JSON.parse(JSONstr) rowCount = dataSet.length columnCount = Object.keys(dataSet[0]).length table = new Table(graphic) table.columns = columnCount table.rows = rowCount // Populate the data to the table for (var i = 0; i < rowCount; i++){ var obj = dataSet[i]; var x = 0 for (var key in obj){ var attrName = key; var attrValue = obj[key]; table.graphicAt(i,x).text = attrValue x = x + 1 } } } else { new Alert('SELECTION ERROR','Please select a single graphic.').show(function(result){}) }
omnigraffle:///omnijs-run?script=if%28document%2Ewindows%5B0%5D%2Eselection%2Egraphics%2Elength%20%3D%3D%201%29%7B%0A%09graphic%20%3D%20document%2Ewindows%5B0%5D%2Eselection%2Egraphics%5B0%5D%0A%09%2F%2F%20Reconstitute%20data%20from%20JSON%20string%0A%09JSONstr%20%3D%20%27%5B%7B%22id%22%3A%22ABV%22%2C%22state%22%3A%22STATE%22%2C%22TSPCPC%22%3A%22Cap%20Per%20Capita%22%2C%22TSPC%22%3A%22Power%28MW%29%22%2C%22POPULATION%22%3A%22POPULATION%22%7D%2C%7B%22id%22%3A%22AZ%22%2C%22state%22%3A%22Arizona%22%2C%22TSPCPC%22%3A%22166%2E9%22%2C%22TSPC%22%3A%221093%2E5%22%2C%22POPULATION%22%3A%226%2C553%2C225%22%7D%2C%7B%22id%22%3A%22HI%22%2C%22state%22%3A%22Hawaii%22%2C%22TSPCPC%22%3A%22136%2E5%22%2C%22TSPC%22%3A%22190%2E0%22%2C%22POPULATION%22%3A%226%2C553%2C225%22%7D%2C%7B%22id%22%3A%22NV%22%2C%22state%22%3A%22Nevada%22%2C%22TSPCPC%22%3A%22122%2E9%22%2C%22TSPC%22%3A%22339%2E1%22%2C%22POPULATION%22%3A%222%2C758%2C931%22%7D%2C%7B%22id%22%3A%22NJ%22%2C%22state%22%3A%22New%20Jersey%22%2C%22TSPCPC%22%3A%22109%2E6%22%2C%22TSPC%22%3A%22971%2E4%22%2C%22POPULATION%22%3A%228%2C864%2C590%22%7D%2C%7B%22id%22%3A%22NM%22%2C%22state%22%3A%22New%20Mexico%22%2C%22TSPCPC%22%3A%2288%2E4%22%2C%22TSPC%22%3A%22184%2E4%22%2C%22POPULATION%22%3A%222%2C085%2C538%22%7D%2C%7B%22id%22%3A%22CA%22%2C%22state%22%3A%22California%22%2C%22TSPCPC%22%3A%2266%2E7%22%2C%22TSPC%22%3A%222537%2E4%22%2C%22POPULATION%22%3A%2238%2C041%2C430%22%7D%5D%27%0A%09dataSet%20%3D%20JSON%2Eparse%28JSONstr%29%0A%09rowCount%20%3D%20dataSet%2Elength%0A%09columnCount%20%3D%20Object%2Ekeys%28dataSet%5B0%5D%29%2Elength%0A%09table%20%3D%20new%20Table%28graphic%29%0A%09table%2Ecolumns%20%3D%20columnCount%0A%09table%2Erows%20%3D%20rowCount%0A%09%2F%2F%20Populate%20the%20data%20to%20the%20table%0A%09for%20%28var%20i%20%3D%200%3B%20i%20%3C%20rowCount%3B%20i%2B%2B%29%7B%0A%09%09var%20obj%20%3D%20dataSet%5Bi%5D%3B%0A%09%09var%20x%20%3D%200%0A%09%09for%20%28var%20key%20in%20obj%29%7B%0A%09%09%09var%20attrName%20%3D%20key%3B%0A%09%09%09var%20attrValue%20%3D%20obj%5Bkey%5D%3B%0A%09%09%09table%2EgraphicAt%28i%2Cx%29%2Etext%20%3D%20attrValue%0A%09%09%09x%20%3D%20x%20%2B%201%0A%09%09%7D%0A%09%7D%0A%7D%20else%20%7B%0A%09new%20Alert%28%27SELECTION%20ERROR%27%2C%27Please%20select%20a%20single%20graphic%2E%27%29%2Eshow%28function%28result%29%7B%7D%29%0A%7D

Create a new Table

In this example, the source graphic is created by the script itself instead of requiring the user to have an existing graphic selected. Various style properties, such as fill and stroke color are applied to the created graphic, before it is used to create the table.

// add a shape to the current canvas cnvs = document.windows[0].selection.canvas rect = new Rect(72, 72, 120, 36) graphic = cnvs.addShape("Rectangle", rect) // graphic properties graphic.strokeThickness = 2 graphic.strokeColor = Color.white // solid properties graphic.fillColor = Color.darkGray graphic.fillType = FillType.Solid // solid text properties graphic.text = 'PLACEHOLDER' graphic.textSize = 14 graphic.textColor = Color.white graphic.textHorizontalAlignment = HorizontalTextAlignment.Center graphic.textVerticalPlacement = VerticalTextPlacement.Middle graphic.textHorizontalPadding = 2 graphic.textVerticalPadding = 2 // create the table table = new Table(graphic) table.columns = 4 table.rows = 3 // adjust header row and column size table.setRowHeight(72,0) table.setColumnWidth(160,0)
omnigraffle:///omnijs-run?script=%2F%2F%20add%20a%20shape%20to%20the%20current%20canvas%0Acnvs%20%3D%20document%2Ewindows%5B0%5D%2Eselection%2Ecanvas%0Arect%20%3D%20new%20Rect%2872%2C%2072%2C%20120%2C%2036%29%0Agraphic%20%3D%20cnvs%2EaddShape%28%22Rectangle%22%2C%20rect%29%0A%2F%2F%20graphic%20properties%0Agraphic%2EstrokeThickness%20%3D%202%0Agraphic%2EstrokeColor%20%3D%20Color%2Ewhite%0A%2F%2F%20solid%20properties%0Agraphic%2EfillColor%20%3D%20Color%2EdarkGray%0Agraphic%2EfillType%20%3D%20FillType%2ESolid%0A%2F%2F%20solid%20text%20properties%0Agraphic%2Etext%20%3D%20%27PLACEHOLDER%27%0Agraphic%2EtextSize%20%3D%2014%0Agraphic%2EtextColor%20%3D%20Color%2Ewhite%0Agraphic%2EtextHorizontalAlignment%20%3D%20HorizontalTextAlignment%2ECenter%0Agraphic%2EtextVerticalPlacement%20%3D%20VerticalTextPlacement%2EMiddle%0Agraphic%2EtextHorizontalPadding%20%3D%202%0Agraphic%2EtextVerticalPadding%20%3D%202%0A%2F%2F%20create%20the%20table%0Atable%20%3D%20new%20Table%28graphic%29%0Atable%2Ecolumns%20%3D%204%0Atable%2Erows%20%3D%203%0A%2F%2F%20adjust%20row%20and%20column%20size%0Atable%2EsetRowHeight%2872%2C0%29%0Atable%2EsetColumnWidth%28160%2C0%29

Change Properties of All Cells of Selected Table

Using Omni Automation, it is possible to create your own set of “table styles” that can be quickly applied to any table.

if(document.windows[0].selection.graphics.length == 1){ table = document.windows[0].selection.graphics[0] if(table.toString() == '[object Table]'){ for(r = 0; r < table.rows; r++){ for(c = 0; c < table.columns; c++){ cell = table.graphicAt(r,c) cell.fillColor = Color.black cell.textColor = Color.white cell.strokeColor = Color.white } } } else { new Alert('SELECTION ERROR','Please select a single table.').show(function(result){}) } } else { new Alert('SELECTION ERROR','Please select a single table.').show(function(result){}) }
omnigraffle:///omnijs-run?script=if%28document%2Ewindows%5B0%5D%2Eselection%2Egraphics%2Elength%20%3D%3D%201%29%7B%0A%09table%20%3D%20document%2Ewindows%5B0%5D%2Eselection%2Egraphics%5B0%5D%0A%09if%28table%2EtoString%28%29%20%3D%3D%20%27%5Bobject%20Table%5D%27%29%7B%0A%09%09for%28r%20%3D%200%3B%20r%20%3C%20table%2Erows%3B%20r%2B%2B%29%7B%0A%09%09%09for%28c%20%3D%200%3B%20c%20%3C%20table%2Ecolumns%3B%20c%2B%2B%29%7B%0A%09%09%09%09cell%20%3D%20table%2EgraphicAt%28r%2Cc%29%0A%09%09%09%09cell%2EfillColor%20%3D%20Color%2Eblack%0A%09%09%09%09cell%2EtextColor%20%3D%20Color%2Ewhite%0A%09%09%09%09cell%2EstrokeColor%20%3D%20Color%2Ewhite%0A%09%09%09%7D%0A%09%09%7D%0A%09%7D%20else%20%7B%0A%09%09new%20Alert%28%27SELECTION%20ERROR%27%2C%27Please%20select%20a%20single%20table%2E%27%29%2Eshow%28function%28result%29%7B%7D%29%0A%09%7D%0A%7D%20else%20%7B%0A%09new%20Alert%28%27SELECTION%20ERROR%27%2C%27Please%20select%20a%20single%20table%2E%27%29%2Eshow%28function%28result%29%7B%7D%29%0A%7D%0A

Here’s another way to change the value of every cell of a table. Since a table is a specialized group, the Table class inherits some properties from the Group class, including the graphics property, whose value is an array of the individual graphics comprising a table. You can use the forEach() function to iterate the array, changing the value of the object’s properties.

if(document.windows[0].selection.graphics.length == 1){ table = document.windows[0].selection.graphics[0] if(table.toString() == '[object Table]'){ table.graphics.forEach(function(cell){ cell.fillColor = Color.white cell.textColor = Color.black cell.strokeColor = Color.black }) } else { new Alert('SELECTION ERROR','Please select a single table.').show(function(result){}) } } else { new Alert('SELECTION ERROR','Please select a single table.').show(function(result){}) }
omnigraffle:///omnijs-run?script=if%28document%2Ewindows%5B0%5D%2Eselection%2Egraphics%2Elength%20%3D%3D%201%29%7B%0A%09table%20%3D%20document%2Ewindows%5B0%5D%2Eselection%2Egraphics%5B0%5D%0A%09if%28table%2EtoString%28%29%20%3D%3D%20%27%5Bobject%20Table%5D%27%29%7B%0A%09%09table%2Egraphics%2EforEach%28function%28cell%29%7B%0A%09%09%09cell%2EfillColor%20%3D%20Color%2Ewhite%0A%09%09%09cell%2EtextColor%20%3D%20Color%2Eblack%0A%09%09%09cell%2EstrokeColor%20%3D%20Color%2Eblack%0A%09%09%7D%29%20%0A%09%7D%20else%20%7B%0A%09%09new%20Alert%28%27SELECTION%20ERROR%27%2C%27Please%20select%20a%20single%20table%2E%27%29%2Eshow%28function%28result%29%7B%7D%29%0A%09%7D%0A%7D%20else%20%7B%0A%09new%20Alert%28%27SELECTION%20ERROR%27%2C%27Please%20select%20a%20single%20table%2E%27%29%2Eshow%28function%28result%29%7B%7D%29%0A%7D

Here’s a variation of the previous scripts that prompts the user to choose between two sets of “styles” to apply to the graphics of the selected table. Note the use of the graphicAt() method to identify a specific table cell for alteration:

if(document.windows[0].selection.graphics.length == 1){ table = document.windows[0].selection.graphics[0] if(table.toString() == '[object Table]'){ var alert = new Alert("Table Style", "Should the table be styled black text over white background, or white text over a black background?") alert.addOption("Black Text") alert.addOption("White Text") alert.addOption("Cancel") alert.show(function(result){ if (result == 0){ for(r = 0; r < table.rows; r++){ for(c = 0; c < table.columns; c++){ cell = table.graphicAt(r,c) cell.fillColor = Color.white cell.textColor = Color.black cell.strokeColor = Color.black } } } else if (result == 1){ for(r = 0; r < table.rows; r++){ for(c = 0; c < table.columns; c++){ cell = table.graphicAt(r,c) cell.fillColor = Color.black cell.textColor = Color.white cell.strokeColor = Color.white } } } else { throw new Error('script cancelled') } }) } else { new Alert('SELECTION ERROR','Please select a single table.').show(function(result){}) } } else { new Alert('SELECTION ERROR','Please select a single table.').show(function(result){}) }
omnigraffle:///omnijs-run?script=if%28document%2Ewindows%5B0%5D%2Eselection%2Egraphics%2Elength%20%3D%3D%201%29%7B%0A%09table%20%3D%20document%2Ewindows%5B0%5D%2Eselection%2Egraphics%5B0%5D%0A%09if%28table%2EtoString%28%29%20%3D%3D%20%27%5Bobject%20Table%5D%27%29%7B%0A%09%09var%20alert%20%3D%20new%20Alert%28%22Table%20Style%22%2C%20%22Should%20the%20table%20be%20styled%20black%20text%20over%20white%20background%2C%20or%20white%20text%20over%20a%20black%20background%3F%22%29%0A%09%09alert%2EaddOption%28%22Black%20Text%22%29%0A%09%09alert%2EaddOption%28%22White%20Text%22%29%0A%09%09alert%2EaddOption%28%22Cancel%22%29%0A%09%09alert%2Eshow%28function%28result%29%7B%0A%09%09%09if%20%28result%20%3D%3D%200%29%7B%0A%09%09%09%09for%28r%20%3D%200%3B%20r%20%3C%20table%2Erows%3B%20r%2B%2B%29%7B%0A%09%09%09%09%09for%28c%20%3D%200%3B%20c%20%3C%20table%2Ecolumns%3B%20c%2B%2B%29%7B%0A%09%09%09%09%09%09cell%20%3D%20table%2EgraphicAt%28r%2Cc%29%0A%09%09%09%09%09%09cell%2EfillColor%20%3D%20Color%2Ewhite%0A%09%09%09%09%09%09cell%2EtextColor%20%3D%20Color%2Eblack%0A%09%09%09%09%09%09cell%2EstrokeColor%20%3D%20Color%2Eblack%0A%09%09%09%09%09%7D%0A%09%09%09%09%7D%0A%09%09%09%7D%20else%20if%20%28result%20%3D%3D%201%29%7B%0A%09%09%09%09for%28r%20%3D%200%3B%20r%20%3C%20table%2Erows%3B%20r%2B%2B%29%7B%0A%09%09%09%09%09for%28c%20%3D%200%3B%20c%20%3C%20table%2Ecolumns%3B%20c%2B%2B%29%7B%0A%09%09%09%09%09%09cell%20%3D%20table%2EgraphicAt%28r%2Cc%29%0A%09%09%09%09%09%09cell%2EfillColor%20%3D%20Color%2Eblack%0A%09%09%09%09%09%09cell%2EtextColor%20%3D%20Color%2Ewhite%0A%09%09%09%09%09%09cell%2EstrokeColor%20%3D%20Color%2Ewhite%0A%09%09%09%09%09%7D%0A%09%09%09%09%7D%0A%09%09%09%7D%20else%20%7B%0A%09%09%09%09throw%20new%20Error%28%27script%20cancelled%27%29%0A%09%09%09%7D%0A%09%09%7D%29%0A%09%7D%20else%20%7B%0A%09%09new%20Alert%28%27SELECTION%20ERROR%27%2C%27Please%20select%20a%20single%20table%2E%27%29%2Eshow%28function%28result%29%7B%7D%29%0A%09%7D%0A%7D%20else%20%7B%0A%09new%20Alert%28%27SELECTION%20ERROR%27%2C%27Please%20select%20a%20single%20table%2E%27%29%2Eshow%28function%28result%29%7B%7D%29%0A%7D

And here’s a script for changing the styling of the top row header of the selected table:

if(document.windows[0].selection.graphics.length == 1){ table = document.windows[0].selection.graphics[0] if(table.toString() == '[object Table]'){ var alert = new Alert("Table Style", "Should the top table row be styled black text over white background, or white text over a black background?") alert.addOption("Black Text") alert.addOption("White Text") alert.addOption("Cancel") alert.show(function(result){ r = 0 if (result == 0){ for(c = 0; c < table.columns; c++){ cell = table.graphicAt(r,c) cell.fillColor = Color.white cell.textColor = Color.black cell.strokeColor = Color.black } } else if (result == 1){ for(c = 0; c < table.columns; c++){ cell = table.graphicAt(r,c) cell.fillColor = Color.black cell.textColor = Color.white cell.strokeColor = Color.white } } else { throw new Error('script cancelled') } }) } else { new Alert('SELECTION ERROR','Please select a single table.').show(function(result){}) } } else { new Alert('SELECTION ERROR','Please select a single table.').show(function(result){}) }
omnigraffle:///omnijs-run?script=if%28document%2Ewindows%5B0%5D%2Eselection%2Egraphics%2Elength%20%3D%3D%201%29%7B%0A%09table%20%3D%20document%2Ewindows%5B0%5D%2Eselection%2Egraphics%5B0%5D%0A%09if%28table%2EtoString%28%29%20%3D%3D%20%27%5Bobject%20Table%5D%27%29%7B%0A%09%09var%20alert%20%3D%20new%20Alert%28%22Table%20Style%22%2C%20%22Should%20the%20top%20table%20row%20be%20styled%20black%20text%20over%20white%20background%2C%20or%20white%20text%20over%20a%20black%20background%3F%22%29%0A%09%09alert%2EaddOption%28%22Black%20Text%22%29%0A%09%09alert%2EaddOption%28%22White%20Text%22%29%0A%09%09alert%2EaddOption%28%22Cancel%22%29%0A%09%09alert%2Eshow%28function%28result%29%7B%0A%09%09%09r%20%3D%200%0A%09%09%09if%20%28result%20%3D%3D%200%29%7B%0A%09%09%09%09for%28c%20%3D%200%3B%20c%20%3C%20table%2Ecolumns%3B%20c%2B%2B%29%7B%0A%09%09%09%09%09cell%20%3D%20table%2EgraphicAt%28r%2Cc%29%0A%09%09%09%09%09cell%2EfillColor%20%3D%20Color%2Ewhite%0A%09%09%09%09%09cell%2EtextColor%20%3D%20Color%2Eblack%0A%09%09%09%09%09cell%2EstrokeColor%20%3D%20Color%2Eblack%0A%09%09%09%09%09%7D%0A%09%09%09%7D%20else%20if%20%28result%20%3D%3D%201%29%7B%0A%09%09%09%09for%28c%20%3D%200%3B%20c%20%3C%20table%2Ecolumns%3B%20c%2B%2B%29%7B%0A%09%09%09%09%09cell%20%3D%20table%2EgraphicAt%28r%2Cc%29%0A%09%09%09%09%09cell%2EfillColor%20%3D%20Color%2Eblack%0A%09%09%09%09%09cell%2EtextColor%20%3D%20Color%2Ewhite%0A%09%09%09%09%09cell%2EstrokeColor%20%3D%20Color%2Ewhite%0A%09%09%09%09%7D%0A%09%09%09%7D%20else%20%7B%0A%09%09%09%09throw%20new%20Error%28%27script%20cancelled%27%29%0A%09%09%09%7D%0A%09%09%7D%29%0A%09%7D%20else%20%7B%0A%09%09new%20Alert%28%27SELECTION%20ERROR%27%2C%27Please%20select%20a%20single%20table%2E%27%29%2Eshow%28function%28result%29%7B%7D%29%0A%09%7D%0A%7D%20else%20%7B%0A%09new%20Alert%28%27SELECTION%20ERROR%27%2C%27Please%20select%20a%20single%20table%2E%27%29%2Eshow%28function%28result%29%7B%7D%29%0A%7D

And here’s a script for changing the styling of the left column header of the selected table:

if(document.windows[0].selection.graphics.length == 1){ table = document.windows[0].selection.graphics[0] if(table.toString() == '[object Table]'){ var alert = new Alert("Table Style", "Should the left table column be styled black text over white background, or white text over a black background?") alert.addOption("Black Text") alert.addOption("White Text") alert.addOption("Cancel") alert.show(function(result){ var c = 0 if (result == 0){ for(r = 0; r < table.rows; r++){ cell = table.graphicAt(r,c) cell.fillColor = Color.white cell.textColor = Color.black cell.strokeColor = Color.black } } else if (result == 1){ for(r = 0; r < table.rows; r++){ cell = table.graphicAt(r,c) cell.fillColor = Color.black cell.textColor = Color.white cell.strokeColor = Color.white } } else { throw new Error('script cancelled') } }) } else { new Alert('SELECTION ERROR','Please select a single table.').show(function(result){}) } } else { new Alert('SELECTION ERROR','Please select a single table.').show(function(result){}) }
omnigraffle:///omnijs-run?script=if%28document%2Ewindows%5B0%5D%2Eselection%2Egraphics%2Elength%20%3D%3D%201%29%7B%0A%09table%20%3D%20document%2Ewindows%5B0%5D%2Eselection%2Egraphics%5B0%5D%0A%09if%28table%2EtoString%28%29%20%3D%3D%20%27%5Bobject%20Table%5D%27%29%7B%0A%09%09var%20alert%20%3D%20new%20Alert%28%22Table%20Style%22%2C%20%22Should%20the%20left%20table%20column%20be%20styled%20black%20text%20over%20white%20background%2C%20or%20white%20text%20over%20a%20black%20background%3F%22%29%0A%09%09alert%2EaddOption%28%22Black%20Text%22%29%0A%09%09alert%2EaddOption%28%22White%20Text%22%29%0A%09%09alert%2EaddOption%28%22Cancel%22%29%0A%09%09alert%2Eshow%28function%28result%29%7B%0A%09%09%09var%20c%20%3D%200%0A%09%09%09if%20%28result%20%3D%3D%200%29%7B%0A%09%09%09%09for%28r%20%3D%200%3B%20r%20%3C%20table%2Erows%3B%20r%2B%2B%29%7B%0A%09%09%09%09%09cell%20%3D%20table%2EgraphicAt%28r%2Cc%29%0A%09%09%09%09%09cell%2EfillColor%20%3D%20Color%2Ewhite%0A%09%09%09%09%09cell%2EtextColor%20%3D%20Color%2Eblack%0A%09%09%09%09%09cell%2EstrokeColor%20%3D%20Color%2Eblack%0A%09%09%09%09%09%7D%0A%09%09%09%7D%20else%20if%20%28result%20%3D%3D%201%29%7B%0A%09%09%09%09for%28r%20%3D%200%3B%20r%20%3C%20table%2Erows%3B%20r%2B%2B%29%7B%0A%09%09%09%09%09cell%20%3D%20table%2EgraphicAt%28r%2Cc%29%0A%09%09%09%09%09cell%2EfillColor%20%3D%20Color%2Eblack%0A%09%09%09%09%09cell%2EtextColor%20%3D%20Color%2Ewhite%0A%09%09%09%09%09cell%2EstrokeColor%20%3D%20Color%2Ewhite%0A%09%09%09%09%7D%0A%09%09%09%7D%20else%20%7B%0A%09%09%09%09throw%20new%20Error%28%27script%20cancelled%27%29%0A%09%09%09%7D%0A%09%09%7D%29%0A%09%7D%20else%20%7B%0A%09%09new%20Alert%28%27SELECTION%20ERROR%27%2C%27Please%20select%20a%20single%20table%2E%27%29%2Eshow%28function%28result%29%7B%7D%29%0A%09%7D%0A%7D%20else%20%7B%0A%09new%20Alert%28%27SELECTION%20ERROR%27%2C%27Please%20select%20a%20single%20table%2E%27%29%2Eshow%28function%28result%29%7B%7D%29%0A%7D

Add|Remove Rows and Columns

To add or remove rows and columns from a table, simply change the vale of the table’s rows and columns properties..

if(document.windows[0].selection.graphics.length == 1){ table = document.windows[0].selection.graphics[0] if(table.toString() == '[object Table]'){ table.rows = table.rows + 2 table.columns = table.columns + 2 } else { new Alert('SELECTION ERROR','Please select a single table.').show(function(result){}) } } else { new Alert('SELECTION ERROR','Please select a single table.').show(function(result){}) }
omnigraffle:///omnijs-run?script=if%28document%2Ewindows%5B0%5D%2Eselection%2Egraphics%2Elength%20%3D%3D%201%29%7B%0A%09table%20%3D%20document%2Ewindows%5B0%5D%2Eselection%2Egraphics%5B0%5D%0A%09if%28table%2EtoString%28%29%20%3D%3D%20%27%5Bobject%20Table%5D%27%29%7B%0A%09%09table%2Erows%20%3D%20table%2Erows%20%2B%202%0A%09%09table%2Ecolumns%20%3D%20table%2Ecolumns%20%2B%202%0A%09%7D%20else%20%7B%0A%09%09new%20Alert%28%27SELECTION%20ERROR%27%2C%27Please%20select%20a%20single%20table%2E%27%29%2Eshow%28function%28result%29%7B%7D%29%0A%09%7D%0A%7D%20else%20%7B%0A%09new%20Alert%28%27SELECTION%20ERROR%27%2C%27Please%20select%20a%20single%20table%2E%27%29%2Eshow%28function%28result%29%7B%7D%29%0A%7D
UNDER CONSTRUCTION

This webpage is in the process of being developed. Any content may change and may not be accurate or complete at this time.

DISCLAIMER