我必须复制现有工作表并重命名。我找不到任何有关如何通过Google Sheet API v4重命名工作表的信息。 现在我有:
var defaultSheet = service.Spreadsheets
.Get(spreadsheetKey)
.Execute().Sheets
.First(x => x.Properties.Title.Equals("Default sheet"));
var newSheet = Service.Spreadsheets.Sheets.CopyTo(
new CopySheetToAnotherSpreadsheetRequest { DestinationSpreadsheetId = spreadsheetKey },
spreadsheetKey,
(int)defaultSheet.Properties.SheetId);
我希望有人知道怎么做。
提前致谢!
答案 0 :(得分:0)
var defSheet = Service.Spreadsheets.Get(baseUrl).Execute().Sheets.First(x => x.Properties.Title.Equals("OldSheet"));
var newSheet = new Request
{
DuplicateSheet = new DuplicateSheetRequest
{
SourceSheetId = defSheet.Properties.SheetId,
NewSheetName = "NewSheet",
InsertSheetIndex = 1
}
};
var y = new BatchUpdateSpreadsheetRequest { Requests = new List<Request> { newSheet } };
Service.Spreadsheets.BatchUpdate(y, baseUrl).Execute();