Cells inherit their styling properties, such as alignment and text style, from the range class. The following demonstrates the setting of all of the inherited cell properties, to create a patchwork-quilt-style table:
Create Random Cell Color Table
01
setrowCountto 10
02
setcolumnCountto 12
03
tellapplication "Numbers"
04
activate
05
if not (existsdocument 1) thenmakenewdocument
06
tell the frontdocument
07
tellactive sheet
08
setthisTableto ¬
09
makenewtablewith properties ¬
10
{row count:rowCount, column count:columnCount}
11
tellthisTable
12
-- style the cells of the table
13
set thewidthof everycolumnto 60
14
set theheightof everyrowto 40
15
setalignmentof everycelltocenter
16
setvertical alignmentof everycelltocenter
17
setfont sizeof everycellto 16
18
repeat withifrom 1 to thecountofcells
19
-- show the address of the cell
20
setvalueofcellito (nameofcelli)
21
-- generate a random background color
22
setRcolorValuetorandom numberfrom 0 to 65535
23
setGcolorValuetorandom numberfrom 0 to 65535
24
setBcolorValuetorandom numberfrom 0 to 65535
25
-- set the background color of the cell
26
set thebackground colorofcellito ¬
27
{RcolorValue, GcolorValue, BcolorValue}
28
-- ensure that text color will constrast with background color
Mention of third-party websites and products is for informational purposes only and constitutes neither an endorsement nor a recommendation. MACOSXAUTOMATION.COM assumes no responsibility with regard to the selection, performance or use of information or products found at third-party websites. MACOSXAUTOMATION.COM provides this only as a convenience to our users. MACOSXAUTOMATION.COM has not tested the information found on these sites and makes no representations regarding its accuracy or reliability. There are risks inherent in the use of any information or products found on the Internet, and MACOSXAUTOMATION.COM assumes no responsibility in this regard. Please understand that a third-party site is independent from MACOSXAUTOMATION.COM and that MACOSXAUTOMATION.COM has no control over the content on that website. Please contact the vendor for additional information.