Method: GoogleDrive::Worksheet#set_number_format

Defined in:
lib/google_drive/worksheet.rb

#set_number_format(top_row, left_col, num_rows, num_cols, pattern, type: "NUMBER") ⇒ Object

Changes the formatting of a range of cells to match the given number format. For example to change A1 to a percentage with 1 decimal point:

worksheet.set_number_format(1, 1, 1, 1, "##.#%")

Google API reference: developers.google.com/sheets/api/reference/rest/v4/spreadsheets#numberformat



562
563
564
565
566
567
# File 'lib/google_drive/worksheet.rb', line 562

def set_number_format(top_row, left_col, num_rows, num_cols, pattern, type: "NUMBER")
  number_format = Google::Apis::SheetsV4::NumberFormat.new(type: type, pattern: pattern)
  format = Google::Apis::SheetsV4::CellFormat.new(number_format: number_format)
  fields = 'userEnteredFormat(numberFormat)'
  format_cells(top_row, left_col, num_rows, num_cols, format, fields)
end