When playing around with sheet data, I always find myself using the Fiddler object – some more posts on this below if you are not familiar with it already.

More on this topic available here

One annoying omission is being able to format data when dumping it, but that’s now been added. Here’s how to format the header row
This class – Fiddler can be found in my cUseful library.
Here’s the key, and it’s also on github



Here’s our starting sheet 
Screenshot 2018-11-10 at 12.00.33


Let’s say we want to add a date in column E

function myFunction() {
  new cUseful.Fiddler (SpreadsheetApp.getActiveSheet())
    .insertColumn ("date seen")
    .mapRows (function (row) {
      row['date seen'] = new Date();
      return row;

Not bad


Screenshot 2018-11-10 at 12.06.59


But, it would be better if I could highlight the heading row, and wrap the ones that are too long

function better() {
  new cUseful.Fiddler (SpreadsheetApp.getActiveSheet())
    .setHeaderFormat ({

Much better


Screenshot 2018-11-10 at 12.11.10

What can be set

The argument to .setHeaderFormat() can be any of the (plural) properties you can set with the range.setxxxxxs method.  Just keep the camel case and lowercase the first letter – for examplerange.setFontWeights  becomes fontWeightsrange.setFontColor becomes fontColors note – that singular methods such as .setFontWeight won’t work, so always use the plural method eg .setFontWeights. That’s all folks.

For more like this see Google Apps Scripts Snippets
Why not join our forum, follow the blog or follow me on twitter to ensure you get updates when they are available.