Other

Color

Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness; for example, the fields of this representation can be trivially provided to the constructor of "java.awt.Color" in Java; it can also be trivially provided to UIColor's "+colorWithRed:green:blue:alpha" method in iOS; and, with just a little work, it can be easily formatted into a CSS "rgba()" string in JavaScript, as well. Here are some examples:

Example (Java):

 import com.google.type.Color;

 // ...
 public static java.awt.Color fromProto(Color protocolor) {
   float alpha = protocolor.hasAlpha()
       ? protocolor.getAlpha().getValue()
       : 1.0;

   return new java.awt.Color(
       protocolor.getRed(),
       protocolor.getGreen(),
       protocolor.getBlue(),
       alpha);
 }

 public static Color toProto(java.awt.Color color) {
   float red = (float) color.getRed();
   float green = (float) color.getGreen();
   float blue = (float) color.getBlue();
   float denominator = 255.0;
   Color.Builder resultBuilder =
       Color
           .newBuilder()
           .setRed(red / denominator)
           .setGreen(green / denominator)
           .setBlue(blue / denominator);
   int alpha = color.getAlpha();
   if (alpha != 255) {
     result.setAlpha(
         FloatValue
             .newBuilder()
             .setValue(((float) alpha) / denominator)
             .build());
   }
   return resultBuilder.build();
 }
 // ...

Example (iOS / Obj-C):

 // ...
 static UIColor* fromProto(Color* protocolor) {
    float red = [protocolor red];
    float green = [protocolor green];
    float blue = [protocolor blue];
    FloatValue* alpha_wrapper = [protocolor alpha];
    float alpha = 1.0;
    if (alpha_wrapper != nil) {
      alpha = [alpha_wrapper value];
    }
    return [UIColor colorWithRed:red green:green blue:blue alpha:alpha];
 }

 static Color* toProto(UIColor* color) {
     CGFloat red, green, blue, alpha;
     if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) {
       return nil;
     }
     Color* result = [[Color alloc] init];
     [result setRed:red];
     [result setGreen:green];
     [result setBlue:blue];
     if (alpha <= 0.9999) {
       [result setAlpha:floatWrapperWithValue(alpha)];
     }
     [result autorelease];
     return result;
}
// ...

Example (JavaScript):

// ...

var protoToCssColor = function(rgb_color) {
   var redFrac = rgb_color.red || 0.0;
   var greenFrac = rgb_color.green || 0.0;
   var blueFrac = rgb_color.blue || 0.0;
   var red = Math.floor(redFrac * 255);
   var green = Math.floor(greenFrac * 255);
   var blue = Math.floor(blueFrac * 255);

   if (!('alpha' in rgb_color)) {
      return rgbToCssColor_(red, green, blue);
   }

   var alphaFrac = rgb_color.alpha.value || 0.0;
   var rgbParams = [red, green, blue].join(',');
   return ['rgba(', rgbParams, ',', alphaFrac, ')'].join('');
};

var rgbToCssColor_ = function(red, green, blue) {
  var rgbNumber = new Number((red << 16) | (green << 8) | blue);
  var hexString = rgbNumber.toString(16);
  var missingZeros = 6 - hexString.length;
  var resultBuilder = ['#'];
  for (var i = 0; i < missingZeros; i++) {
     resultBuilder.push('0');
  }
  resultBuilder.push(hexString);
  return resultBuilder.join('');
};

// ...
JSON representation
{
  "red": number,
  "green": number,
  "blue": number,
  "alpha": number
}
Fields
red

number

The amount of red in the color as a value in the interval [0, 1].

green

number

The amount of green in the color as a value in the interval [0, 1].

blue

number

The amount of blue in the color as a value in the interval [0, 1].

alpha

number

The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation:

pixel color = alpha * (this color) + (1.0 - alpha) * (background color)

This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is to be rendered as a solid color (as if the alpha value had been explicitly given with a value of 1.0).

HorizontalAlign

The horizontal alignment of text in a cell.

Enums
HORIZONTAL_ALIGN_UNSPECIFIED The horizontal alignment is not specified. Do not use this.
LEFT The text is explicitly aligned to the left of the cell.
CENTER The text is explicitly aligned to the center of the cell.
RIGHT The text is explicitly aligned to the right of the cell.

TextFormat

The format of a run of text in a cell. Absent values indicate that the field isn't specified.

JSON representation
{
  "foregroundColor": {
    object(Color)
  },
  "fontFamily": string,
  "fontSize": number,
  "bold": boolean,
  "italic": boolean,
  "strikethrough": boolean,
  "underline": boolean
}
Fields
foregroundColor

object( Color )

The foreground color of the text.

fontFamily

string

The font family.

fontSize

number

The size of the font.

bold

boolean

True if the text is bold.

italic

boolean

True if the text is italicized.

strikethrough

boolean

True if the text has a strikethrough.

underline

boolean

True if the text is underlined.

ExtendedValue

The kinds of value that a cell in a spreadsheet can have.

JSON representation
{

  // Union field value can be only one of the following:
  "numberValue": number,
  "stringValue": string,
  "boolValue": boolean,
  "formulaValue": string,
  "errorValue": {
    object(ErrorValue)
  }
  // End of list of possible types for union field value.
}
Fields
Union field value . The type of value in a cell. If no field is set, the cell has no data. value can be only one of the following:
numberValue

number

Represents a double value. Note: Dates, Times and DateTimes are represented as doubles in "serial number" format.

stringValue

string

Represents a string value. Leading single quotes are not included. For example, if the user typed '123 into the UI, this would be represented as a stringValue of "123" .

boolValue

boolean

Represents a boolean value.

formulaValue

string

Represents a formula.

errorValue

object( ErrorValue )

Represents an error. This field is read-only.

ErrorValue

An error in a cell.

JSON representation
{
  "type": enum(ErrorType),
  "message": string
}
Fields
type

enum( ErrorType )

The type of error.

message

string

A message with more information about the error (in the spreadsheet's locale).

ErrorType

The type of error.

Enums
ERROR_TYPE_UNSPECIFIED The default error type, do not use this.
ERROR Corresponds to the #ERROR! error.
NULL_VALUE Corresponds to the #NULL! error.
DIVIDE_BY_ZERO Corresponds to the #DIV/0 error.
VALUE Corresponds to the #VALUE! error.
REF Corresponds to the #REF! error.
NAME Corresponds to the #NAME? error.
NUM Corresponds to the #NUM ! error.
N_A Corresponds to the #N/A error.
LOADING Corresponds to the Loading... state.

BooleanCondition

A condition that can evaluate to true or false. BooleanConditions are used by conditional formatting, data validation, and the criteria in filters.

JSON representation
{
  "type": enum(ConditionType),
  "values": [
    {
      object(ConditionValue)
    }
  ]
}
Fields
type

enum( ConditionType )

The type of condition.

values[]

object( ConditionValue )

The values of the condition. The number of supported values depends on the condition type . Some support zero values, others one or two values, and ConditionType.ONE_OF_LIST supports an arbitrary number of values.

ConditionType

The type of condition.

Enums
CONDITION_TYPE_UNSPECIFIED The default value, do not use.
NUMBER_GREATER The cell's value must be greater than the condition's value. Supported by data validation, conditional formatting and filters. Requires a single ConditionValue .
NUMBER_GREATER_THAN_EQ The cell's value must be greater than or equal to the condition's value. Supported by data validation, conditional formatting and filters. Requires a single ConditionValue .
NUMBER_LESS The cell's value must be less than the condition's value. Supported by data validation, conditional formatting and filters. Requires a single ConditionValue .
NUMBER_LESS_THAN_EQ The cell's value must be less than or equal to the condition's value. Supported by data validation, conditional formatting and filters. Requires a single ConditionValue .
NUMBER_EQ The cell's value must be equal to the condition's value. Supported by data validation, conditional formatting and filters. Requires a single ConditionValue .
NUMBER_NOT_EQ The cell's value must be not equal to the condition's value. Supported by data validation, conditional formatting and filters. Requires a single ConditionValue .
NUMBER_BETWEEN The cell's value must be between the two condition values. Supported by data validation, conditional formatting and filters. Requires exactly two ConditionValues .
NUMBER_NOT_BETWEEN The cell's value must not be between the two condition values. Supported by data validation, conditional formatting and filters. Requires exactly two ConditionValues .
TEXT_CONTAINS The cell's value must contain the condition's value. Supported by data validation, conditional formatting and filters. Requires a single ConditionValue .
TEXT_NOT_CONTAINS The cell's value must not contain the condition's value. Supported by data validation, conditional formatting and filters. Requires a single ConditionValue .
TEXT_STARTS_WITH The cell's value must start with the condition's value. Supported by conditional formatting and filters. Requires a single ConditionValue .
TEXT_ENDS_WITH The cell's value must end with the condition's value. Supported by conditional formatting and filters. Requires a single ConditionValue .
TEXT_EQ The cell's value must be exactly the condition's value. Supported by data validation, conditional formatting and filters. Requires a single ConditionValue .
TEXT_IS_EMAIL The cell's value must be a valid email address. Supported by data validation. Requires no ConditionValues .
TEXT_IS_URL The cell's value must be a valid URL. Supported by data validation. Requires no ConditionValues .
DATE_EQ The cell's value must be the same date as the condition's value. Supported by data validation, conditional formatting and filters. Requires a single ConditionValue .
DATE_BEFORE The cell's value must be before the date of the condition's value. Supported by data validation, conditional formatting and filters. Requires a single ConditionValue that may be a relative date .
DATE_AFTER The cell's value must be after the date of the condition's value. Supported by data validation, conditional formatting and filters. Requires a single ConditionValue that may be a relative date .
DATE_ON_OR_BEFORE The cell's value must be on or before the date of the condition's value. Supported by data validation. Requires a single ConditionValue that may be a relative date .
DATE_ON_OR_AFTER The cell's value must be on or after the date of the condition's value. Supported by data validation. Requires a single ConditionValue that may be a relative date .
DATE_BETWEEN The cell's value must be between the dates of the two condition values. Supported by data validation. Requires exactly two ConditionValues .
DATE_NOT_BETWEEN The cell's value must be outside the dates of the two condition values. Supported by data validation. Requires exactly two ConditionValues .
DATE_IS_VALID The cell's value must be a date. Supported by data validation. Requires no ConditionValues .
ONE_OF_RANGE The cell's value must be listed in the grid in condition value's range. Supported by data validation. Requires a single ConditionValue , and the value must be a valid range in A1 notation.
ONE_OF_LIST The cell's value must be in the list of condition values. Supported by data validation. Supports any number of condition values , one per item in the list. Formulas are not supported in the values.
BLANK The cell's value must be empty. Supported by conditional formatting and filters. Requires no ConditionValues .
NOT_BLANK The cell's value must not be empty. Supported by conditional formatting and filters. Requires no ConditionValues .
CUSTOM_FORMULA The condition's formula must evaluate to true. Supported by data validation, conditional formatting and filters. Requires a single ConditionValue .
BOOLEAN The cell's value must be TRUE/FALSE or in the list of condition values. Supported by data validation. Renders as a cell checkbox. Supports zero, one or two ConditionValues . No values indicates the cell must be TRUE or FALSE, where TRUE renders as checked and FALSE renders as unchecked. One value indicates the cell will render as checked when it contains that value and unchecked when it is blank. Two values indicate that the cell will render as checked when it contains the first value and unchecked when it contains the second value. For example, ["Yes","No"] indicates that the cell will render a checked box when it has the value "Yes" and an unchecked box when it has the value "No".

ConditionValue

The value of the condition.

JSON representation
{

  // Union field value can be only one of the following:
  "relativeDate": enum(RelativeDate),
  "userEnteredValue": string
  // End of list of possible types for union field value.
}
Fields
Union field value . The value of the condition, exactly one must be set. value can be only one of the following:
relativeDate

enum( RelativeDate )

A relative date (based on the current date). Valid only if the type is DATE_BEFORE , DATE_AFTER , DATE_ON_OR_BEFORE or DATE_ON_OR_AFTER .

Relative dates are not supported in data validation. They are supported only in conditional formatting and conditional filters.

userEnteredValue

string

A value the condition is based on. The value is parsed as if the user typed into a cell. Formulas are supported (and must begin with an = or a '+').

RelativeDate

Controls how a date condition is evaluated.

Enums
RELATIVE_DATE_UNSPECIFIED Default value, do not use.
PAST_YEAR The value is one year before today.
PAST_MONTH The value is one month before today.
PAST_WEEK The value is one week before today.
YESTERDAY The value is yesterday.
TODAY The value is today.
TOMORROW The value is tomorrow.

GridRange

A range on a sheet. All indexes are zero-based. Indexes are half open, e.g the start index is inclusive and the end index is exclusive -- [startIndex, endIndex). Missing indexes indicate the range is unbounded on that side.

For example, if "Sheet1" is sheet ID 0, then:

Sheet1!A1:A1 == sheetId: 0, startRowIndex: 0, endRowIndex: 1, startColumnIndex: 0, endColumnIndex: 1

Sheet1!A3:B4 == sheetId: 0, startRowIndex: 2, endRowIndex: 4, startColumnIndex: 0, endColumnIndex: 2

Sheet1!A:B == sheetId: 0, startColumnIndex: 0, endColumnIndex: 2

Sheet1!A5:B == sheetId: 0, startRowIndex: 4, startColumnIndex: 0, endColumnIndex: 2

Sheet1 == sheetId:0

The start index must always be less than or equal to the end index. If the start index equals the end index, then the range is empty. Empty ranges are typically not meaningful and are usually rendered in the UI as #REF! .

JSON representation
{
  "sheetId": number,
  "startRowIndex": number,
  "endRowIndex": number,
  "startColumnIndex": number,
  "endColumnIndex": number
}
Fields
sheetId

number

The sheet this range is on.

startRowIndex

number

The start row (inclusive) of the range, or not set if unbounded.

endRowIndex

number

The end row (exclusive) of the range, or not set if unbounded.

startColumnIndex

number

The start column (inclusive) of the range, or not set if unbounded.

endColumnIndex

number

The end column (exclusive) of the range, or not set if unbounded.

SortOrder

A sort order.

Enums
SORT_ORDER_UNSPECIFIED Default value, do not use this.
ASCENDING Sort ascending.
DESCENDING Sort descending.

Send feedback about...

Need help? Visit our support page.