无法使用Google Sheets C#API编写列

无法使用Google Sheets C#API编写列,c#,google-sheets,google-sheets-api,google-sheets-importxml,C#,Google Sheets,Google Sheets Api,Google Sheets Importxml,我正在尝试使用c#Google Sheets API通过下面的代码将信息输入到我的Google Sheets中,但它只作为行输入,我希望将其作为列输入。有办法做到这一点吗 valueRange.Values = new List<IList<object>> { objectList }; appendRequest = service.Spreadsheets.Values.Append(valueRange, SpreadsheetId, range); append

我正在尝试使用c#Google Sheets API通过下面的代码将信息输入到我的Google Sheets中,但它只作为行输入,我希望将其作为列输入。有办法做到这一点吗

valueRange.Values = new List<IList<object>> { objectList };
appendRequest = service.Spreadsheets.Values.Append(valueRange, SpreadsheetId, range);
appendRequest.ValueInputOption = SpreadsheetsResource.ValuesResource.AppendRequest.ValueInputOptionEnum.USERENTERED;
appendResponse = appendRequest.Execute();
valueRange.Values=新列表{objectList};
appendRequest=service.Spreadsheets.Values.Append(valueRange,SpreadsheetId,range);
appendRequest.ValueInputOption=SpreadsheetsResource.ValuesResource.appendRequest.ValueInputOptionEnum.USERENTERED;
appendResponse=appendRequest.Execute();

我在下面修复了您的代码。似乎是您的值范围。值转换不正确。

public static AppendValuesResponse InsertColumnLine(this SheetsService service, string spreadsheetId, string range, params object[] columnValues)
{
    // convert columnValues to columList
    var columList = columnValues.Select(v => new List<object> { v });

    // Add columList to values and input to valueRange
    var values = new List<IList<object>>();
    values.AddRange(columList.ToList());
    var valueRange = new ValueRange()
    {
        Values = values
    };

    // Create request and execute
    var appendRequest = service.Spreadsheets.Values.Append(valueRange, spreadsheetId, range);
    appendRequest.ValueInputOption = SpreadsheetsResource.ValuesResource.AppendRequest.ValueInputOptionEnum.USERENTERED;
    return appendRequest.Execute();
}
看看结果。我希望它能帮助你。

请您澄清一下您要完成的任务好吗?该方法用于添加行,而不是列。是否将值添加到第一个空列?
// Sample!A1 => Sample is workseet name, A1 cell feild
_sheetsService.InsertColumnLine(_chickenOptions.Debug.SpreadSheetId, "Sample!A1", 1, 2, 3, 4, 5);