c#从Excel Sharepoint页面实时读取数据

时间:2019-05-01 16:57:19

标签: c# sharepoint

我想从共享点excel文件中实时读取一些数据,然后在我的应用程序中使用这些数据

试图从共享点页面打开excel文件,但无法使用数据

 public void test()
    {




        var authenticationManager =
           new OfficeDevPnP.Core.AuthenticationManager();

        ClientContext context =
        authenticationManager.GetWebLoginClientContext(@"https://alex.sharepoint.com/sites/alex/");

        Web web = context.Web;
        User user = web.CurrentUser;
        context.Load(web);
        context.Load(user);



        //   sp.List list = context.Web.Lists.GetByTitle("documents");
        // context.Load(list);
        context.Load(web, w => w.ServerRelativeUrl);
        context.ExecuteQuery();


        string foldername = web.ServerRelativeUrl + "/shared%20documents/test/";

        sp.Folder folder = web.GetFolderByServerRelativeUrl(foldername);
        var item2 = folder.GetFile("testfile.xlsx");

        context.Load(context.Web);
        context.Load(folder);
        context.Load(item2);
        context.ExecuteQuery();


        if (item2 == null)
        {
            Console.WriteLine("No file found");
        }
        else
        {
            sp.FileInformation i = sp.File.OpenBinaryDirect(context, item2.ServerRelativeUrl);


            Console.ReadLine();
        }
    }

我没有任何错误,但是我无法使用数据

0 个答案:

没有答案