获取 google 的特定 sheet 的字体单元格和背景颜色单元格传播 sheet
getting font cell and backcolor cell of a specific sheet of google spread sheet
我有一个 Google 传播 sheet,它有很多 sheet。我想获取特定 sheet 中单元格的字体颜色。
我找到了 this API,但我无法指定来自哪个 sheet。你知道 API 我怎样才能完成这项工作吗?
- includeGridData 应设置为 true
- 输入要获取的单元格或单元格范围
示例:
工作表:
查询参数:
响应正文:
Spreadsheets.get 将 return 一个 Resource:Spreadsheet, you can get the cell font color of your range requested under "sheets" -> "data" -> "rowData" -> "values" -> "userEnteredFormat" -> "textFormat" -> "foregroundColor"
"sheets": [
{
"data": [
{
"rowData": [
{
"values": [
{
"userEnteredValue": {
"stringValue": "DONE"
},
"effectiveValue": {
"stringValue": "DONE"
},
"formattedValue": "DONE",
"userEnteredFormat": {
"textFormat": {
"foregroundColor": {
"red": 0.9843137,
"green": 0.7372549,
"blue": 0.015686275
},
"fontFamily": "Arial",
"foregroundColorStyle": {
"themeColor": "ACCENT3"
}
}
},
* * *
{
"startRow": 1,
"rowData": [
{
"values": [
{
"userEnteredValue": {
"stringValue": "NOK"
},
"effectiveValue": {
"stringValue": "NOK"
},
"formattedValue": "NOK",
"userEnteredFormat": {
"textFormat": {
"foregroundColor": {
"red": 1,
"blue": 1
},
"fontFamily": "Arial",
"foregroundColorStyle": {
"rgbColor": {
"red": 1,
"blue": 1
}
}
}
},
* **
}
Sheet1!A1 的字体颜色将为:
"foregroundColor": { "red": 0.9843137, "green": 0.7372549, "blue": 0.015686275 }
您需要使用此公式转换浮动 rgb 值:
Math.floor( floating color value * 255)
基于此参考:https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/other#Color
我有一个 Google 传播 sheet,它有很多 sheet。我想获取特定 sheet 中单元格的字体颜色。 我找到了 this API,但我无法指定来自哪个 sheet。你知道 API 我怎样才能完成这项工作吗?
- includeGridData 应设置为 true
- 输入要获取的单元格或单元格范围
示例:
工作表:
查询参数:
响应正文:
Spreadsheets.get 将 return 一个 Resource:Spreadsheet, you can get the cell font color of your range requested under "sheets" -> "data" -> "rowData" -> "values" -> "userEnteredFormat" -> "textFormat" -> "foregroundColor"
"sheets": [ { "data": [ { "rowData": [ { "values": [ { "userEnteredValue": { "stringValue": "DONE" }, "effectiveValue": { "stringValue": "DONE" }, "formattedValue": "DONE", "userEnteredFormat": { "textFormat": { "foregroundColor": { "red": 0.9843137, "green": 0.7372549, "blue": 0.015686275 }, "fontFamily": "Arial", "foregroundColorStyle": { "themeColor": "ACCENT3" } } }, * * * { "startRow": 1, "rowData": [ { "values": [ { "userEnteredValue": { "stringValue": "NOK" }, "effectiveValue": { "stringValue": "NOK" }, "formattedValue": "NOK", "userEnteredFormat": { "textFormat": { "foregroundColor": { "red": 1, "blue": 1 }, "fontFamily": "Arial", "foregroundColorStyle": { "rgbColor": { "red": 1, "blue": 1 } } } }, * **
}
Sheet1!A1 的字体颜色将为:
"foregroundColor": { "red": 0.9843137, "green": 0.7372549, "blue": 0.015686275 }
您需要使用此公式转换浮动 rgb 值:
Math.floor( floating color value * 255)
基于此参考:https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/other#Color