繁体   English   中英

哪个 nuget 包包含方法 GetSheetService()?

[英]Which nuget package contains the method GetSheetService()?

我想知道是否有包含 GetSheetService() 的 nuget 包,我找不到哪个是正确的包,有人知道吗? 有人用过这个方法吗?

这是我安装的软件包:

  <ItemGroup>
    <PackageReference Include="Google.Apis" Version="1.40.3" />
    <PackageReference Include="Google.Apis.Auth" Version="1.40.3" />
    <PackageReference Include="Google.Apis.Auth.Mvc" Version="1.40.3" />
    <PackageReference Include="Google.Apis.Sheets.v4" Version="1.40.3.1694" />
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.28" />
  </ItemGroup>

这是我遇到的问题: 在此处输入图片说明

这是cs文件的开始:

using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Google.Apis.Sheets.v4;

google .net 客户端库没有称为 get sheet 服务的方法。 我怀疑你是从某些地方的某人代码中复制的。 创建sheet服务的正确方法如下

/// <summary>
    /// This method get a valid service
    /// </summary>
    /// <param name="credential">Authecated user credentail</param>
    /// <returns>SheetsService used to make requests against the Sheets API</returns>
    private static SheetsService GetService(UserCredential credential)
    {
        try
        {
            if (credential == null)
                throw new ArgumentNullException("credential");

            // Create Sheets API service.
            return new SheetsService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName = "Sheets Oauth2 Authentication Sample"
            });
        }
        catch (Exception ex)
        {
            throw new Exception("Get Sheets service failed.", ex);
        }
    }
}

从我的 google .net 客户端库示例项目中提取的代码。 Oauth2Authentication.cs)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM