Method: GoogleDrive::Worksheet#set_text_format
- Defined in:
- lib/google_drive/worksheet.rb
#set_text_format(top_row, left_col, num_rows, num_cols, bold: false, italic: false, strikethrough: false, font_size: nil, font_family: nil, foreground_color: nil) ⇒ Object
Change the text formatting on a range of cells. e.g., To set cell A1 to have red text that is bold and italic:
worksheet.set_text_format(
1, 1, 1, 1,
bold: true,
italic: true,
foreground_color: GoogleDrive::Worksheet::Colors::RED_BERRY)
foreground_color is an instance of Google::Apis::SheetsV4::Color. Google API reference: developers.google.com/sheets/api/reference/rest/v4/spreadsheets#textformat
609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 |
# File 'lib/google_drive/worksheet.rb', line 609 def set_text_format(top_row, left_col, num_rows, num_cols, bold: false, italic: false, strikethrough: false, font_size: nil, font_family: nil, foreground_color: nil) text_format = Google::Apis::SheetsV4::TextFormat.new( bold: bold, italic: italic, strikethrough: strikethrough, font_size: font_size, font_family: font_family, foreground_color: foreground_color ) format = Google::Apis::SheetsV4::CellFormat.new(text_format: text_format) fields = 'userEnteredFormat(textFormat)' format_cells(top_row, left_col, num_rows, num_cols, format, fields) end |