Skip to content

Instantly share code, notes, and snippets.

@cp-sumi-k
Last active November 8, 2022 09:54
Show Gist options
  • Save cp-sumi-k/911ba6fe6c78be75c04bf10c630c94c4 to your computer and use it in GitHub Desktop.
Save cp-sumi-k/911ba6fe6c78be75c04bf10c630c94c4 to your computer and use it in GitHub Desktop.
func prepareCells(records []string) []*sheets.RowData {
// init cells array
cells := []*sheets.CellData{}
bgWhite := &sheets.Color{ // green background
Alpha: 1,
Blue: 0,
Red: 0,
Green: 1,
}
// prepare cell for each records and append it to cells
for i := range records {
data := &sheets.CellData{
UserEnteredValue: &sheets.ExtendedValue{
StringValue: &(records[i]), // add value
},
UserEnteredFormat: &sheets.CellFormat{ // add background color
BackgroundColor: bgWhite,
},
}
cells = append(cells, data)
}
// prepare row from cells
return []*sheets.RowData{
{Values: cells},
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment