Italic style

Here is a tip how to edit italic style property.

 

Source code

function setStyleItalic() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sh = ss.getActiveSheet();

  // Set bold property = true
  ss.getActiveRange().setFontWeight("italic");

  // Set bold property = false
  ss.getActiveRange().setFontWeight(null);
}

 

Format

RangeObject.setFontWeight(fontWeight)

 

Parameters

fontWeight … You can enter only 2 values like the following them;

+ “italic” -> italic style property = true

+ null -> italic style property = false

 

Responses

None

 

How to check italic style status?

GAS supplies a function to get the status. of that.

Here is source code.

function checkItalic(){
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sh = ss.getActiveSheet();
  var rs = ss.getActiveRange().getTextStyle().isItalic();
  Browser.msgBox("Italic: " + rs);
}

The following is the format. This function returns “true” or “false”.

RangeObject.getTextStyle().isItalic()

 

How to get a range’s object?

Please refer the following tips.

Get an active range object

Get a range object by row & column number

Get a range object by address

Leave a Comment