I have a Google Doc with a table. I've gotten a script that copies the table and inserts the copy between the first paragraph and the table. I would like the tables to be identical but I can't figure out how to make the header row of the table gray like it is in the original table.
I've figured out how to highlight the text in the header row, but I'm looking to turn the entire row gray.
//Add menu to document
function onOpen() {
DocumentApp.getUi()
.createMenu('New Table')
.addItem('Add Table', 'addTable')
.addToUi();
}
function addTable() {
var body = DocumentApp.getActiveDocument().getBody();
//Add a horizontal rule & line break above existing tables
body.insertHorizontalRule(3);
body.insertParagraph(4, ' ');
// Create a two-dimensional array containing the cell contents.
var cells = [
['Week of: Week _'],
['Agenda/ Focus for the Week:'],
['Notes / Questions:'],
['Next Steps / Who’s Responsible?:'],
['Progress Toward SMART Goal(s):'],
];
// Build a table from the array
var table1 = body.insertTable(2,cells);
//Set width of the first column
table1.setColumnWidth(0, 467);
//Set height of first column
table1.getRow(1).setMinimumHeight(35);
table1.getRow(2).setMinimumHeight(35);
table1.getRow(3).setMinimumHeight(35);
table1.getRow(4).setMinimumHeight(35);
//Set Border color
table1.setBorderColor('#000000');
//Set style of font in table
var style = {};
style[DocumentApp.Attribute.FONT_SIZE] = '10';
style[DocumentApp.Attribute.BOLD] = false;
table1.setAttributes(style);
//Set header row style var tableHeader = table1.getRow(0);
var headerStyle = {};
headerStyle[DocumentApp.Attribute.BOLD] = true;
headerStyle[DocumentApp.Attribute.FONT_SIZE] = '10';
headerStyle[DocumentApp.Attribute.BACKGROUND_COLOR] = '#BBB9B9';
tableHeader.setAttributes(headerStyle);
I want the top row of the new table to be colored gray, but it only highlights the text gray.