我有两个要求:
1)我想以编程方式从当前电子表格中的现有工作表创建一个新工作表
2) 我想以编程方式将一张工作表从一个电子表格复制到另一个电子表格
帮助表示赞赏。
是否可以?我可以通过更新 ValueRange 对象来更改值,如上面的代码所示,但找不到更改格式的方法。
ValueRange l_oValueRange = new ValueRange();
List<object> l_olCellsNewValue = new List<object>() { DateTime.UtcNow.ToString("dd'/'MM'/'yyyy HH:mm:ss") };
l_oValueRange.Values = new List<IList<object>> { l_olCellsNewValue };
SpreadsheetsResource.ValuesResource.UpdateRequest l_oUpdate = service.Spreadsheets.Values.Update(
l_oValueRange,
spreadsheetId,
"A60");
l_oUpdate.ValueInputOption = SpreadsheetsResource.ValuesResource.UpdateRequest.ValueInputOptionEnum.RAW;
UpdateValuesResponse l_oResponse = l_oUpdate.Execute();
Run Code Online (Sandbox Code Playgroud) 我正在使用 php-google-spreadsheet-client 库。我不知道如何获取谷歌表格中可用的表格列表。提前致谢。
我正在尝试使用 Google Sheets API v4 使用 C# 控制台应用程序在 google Sheet 中插入行。我可以使用下面的代码插入行,但无法在顶部插入。
我希望插入的每一行都应该插入到顶部,而其他现有行应该向下移动。
SpreadsheetsResource.ValuesResource.UpdateRequest request =
service.Spreadsheets.Values.Update(new ValueRange() { Values = values }, spreadsheetId, newRange);
request.ValueInputOption = SpreadsheetsResource.ValuesResource.UpdateRequest.ValueInputOptionEnum.USERENTERED;
var response = request.Execute();
Run Code Online (Sandbox Code Playgroud) 自从 2018 年将复选框添加到原生 Google Sheets UI 以来,开发人员一直希望以编程方式读取它们或以某种方式处理它们,例如将它们视为“单选按钮”、将它们重置为“未选中”或将它们设置为“检查过”。
我们如何才能最好地在给定的 Google Sheet 中找到复选框,以便避免在操作其他单元格的状态时意外修改它们?
一种方法是检查工作表上的值并将任何true/false值视为复选框:
function getAllCheckboxes() {
const wb = SpreadsheetApp.getActive();
const checkboxes = [];
wb.getSheets().forEach(function (sheet) {
var rg = sheet.getDataRange();
var values = rg.getValues();
var sheetCheckBoxes = [];
values.forEach(function (row, r) {
row.forEach(function (val, c) {
// Checkbox values are stored as `false` (unchecked) and `true` (checked)
if (val === false || val === true) {
sheetCheckBoxes.push({
rowIndex: r,
colIndex: c,
value: val,
r1c1: "R" + …Run Code Online (Sandbox Code Playgroud) 我的目标是创建一个电子表格单元格,其中包含来自 Google 脚本的多个超链接。
我可以创建一个带有多个链接的单元格,选择单元格文本的一部分,然后使用Ctrl+K或 menu insert link。google and yahoo例如,我的单元格有两个超链接,每个搜索引擎一个。
我可以通过两种不同的方式阅读此单元格中的超链接:
var range = SpreadsheetApp.getActiveSheet().getRange('A1');
var richText = range.getRichTextValue();
var allRuns = richText.getRuns();
var firstLink = allRuns[0].getLinkUrl();
var secondLink = allRuns[2].getLinkUrl();
var gLink = richText.getLinkUrl(0, 5);
var aLink = richText.getLinkUrl(11, 15);
Run Code Online (Sandbox Code Playgroud)
但是没有setLinkUrl可用的方法。我也无法在Google 表格 API 中找到任何内容。
我复制了这个单元格并在 Linux 中使用 xclip,命令
xclip -selection clipboard -o -t text/html
Run Code Online (Sandbox Code Playgroud)
结果是
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<style type="text/css">
<!--
td {
border: 1px solid #ccc;
} …Run Code Online (Sandbox Code Playgroud) hyperlink google-sheets google-apps-script google-sheets-api
我正在尝试编写一个链接到谷歌表格的不和谐机器人,但我的代码遇到了无数错误。我得到的错误如下:
Traceback (most recent call last):
File "/home/runner/Bundeswehr-Bot/venv/lib/python3.8/site-packages/discord/ui/modal.py", line 186, in _scheduled_task
await self.on_submit(interaction)
File "/home/runner/Bundeswehr-Bot/modals.py", line 45, in on_submit
if sheet.find(self.host.value) == None:
File "/home/runner/Bundeswehr-Bot/venv/lib/python3.8/site-packages/gspread/cell.py", line 44, in __eq__
same_row = self.row == other.row
AttributeError: 'NoneType' object has no attribute 'row'
Run Code Online (Sandbox Code Playgroud)
我的代码是:
class bct_modal(discord.ui.Modal, title="BCT Logging"):
host = discord.ui.TextInput(
label='Host ID',
placeholder='The hosts discord ID here...',
required=True
)
async def on_submit(self, interaction: discord.Interaction):
ids = []
ids.append(self.host.value)
print(ids)
if sheet.find(self.host.value) == None:
sheet.append_row([self.host.value, 0, 0, 0, 0, 0, 0, …Run Code Online (Sandbox Code Playgroud) 我有一个关于将过滤器应用于多个值以使用 Google 脚本隐藏它们的问题。我有一个具有多种状态的项目跟踪器,例如“达到目标”、“已完成”、“已取消”、“已延迟”等。我想编写一个脚本来设置“状态”列的筛选器值,以便标记为“已完成”或“的行”已取消”被隐藏。我编写了下面的代码片段来隐藏“已完成”状态,如何向其中添加“已取消”?感谢您的帮助。
//Below code has been written to hide rows with status = Completed.
//I'd like to modify it to hide rows with status = Completed AND rows with status = Canceled.
function SetFilters() {
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var ssId = spreadsheet.getId();
var sheet = spreadsheet.getSheetByName("Project Tracker");
var lastRow = sheet.getLastRow();
var lastColumn = sheet.getLastColumn();
var sheetId = sheet.getSheetId();
var filterSettings = {
"range": {
"sheetId": sheetId,
"startRowIndex": 0,
"endRowIndex": lastRow,
"startColumnIndex": 0,
"endColumnIndex": lastColumn
}
};
filterSettings.criteria …Run Code Online (Sandbox Code Playgroud) 这是我的代码,用于出席没有参加 google meet 会议的朋友。
我们使用组织电子邮件,所以每个人都有他们的名字作为他们的卷号。
电子表格中记录了使用会议出勤分机号码(谁在场)。
import gspread
from oauth2client.service_account import ServiceAccountCredentials
scope = ["https://spreadsheets.google.com/feeds",
"https://www.googleapis.com/auth/spreadsheets",
"https://www.googleapis.com/auth/drive.file",
"https://www.googleapis.com/auth/drive"]
creds = ServiceAccountCredentials.from_json_keyfile_name('Client_secret.json', scope)
client = gspread.authorize(creds)
url = "Url of my SpreadSheet"
sheet = client.open_by_url(url).sheet1
# 66
try:
cell = sheet.find('566')
pass
except gspread.exceptions.CellNotFound:
print('566 Absent')
# 67
try:
cell = sheet.find('567')
pass
except gspread.exceptions.CellNotFound:
print("567 Absent")
# 68, etc...
# ----------------------------------------------------
# Code to delete the spreadsheet once the work is done.
# ----------------------------------------------------
Run Code Online (Sandbox Code Playgroud)
我有责任将缺席者名册编号提供给经理。
我正在尝试保存我的存储空间我不能一直手动删除电子表格,这就是为什么我需要一个代码来删除完整的电子表格使用 …
c# ×2
gspread ×2
.net ×1
checkbox ×1
filtering ×1
google-docs ×1
hyperlink ×1
python ×1
python-3.x ×1