以编程方式将数据从Excel工作表导入SharePoint列表 [英] Importing data from Excel sheet to SharePoint list programmatically

查看:110
本文介绍了以编程方式将数据从Excel工作表导入SharePoint列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

我想使用C#代码将数据从Excel工作表导入SharePoint列表.

I would like to import data from Excel sheet to SharePoint list using C# code.

使用导入电子表格"的现成创建列表不是一种选择.鉴于,我已经尝试了oledb和Microsoft.Office.Interop.Excel过程,但是它们不能与SharePoint一起使用.

Using the out-of-the-box create list using Import Spreadsheet is not an option. Whereas, I've tried both oledb and Microsoft.Office.Interop.Excel procedures but they are not working with SharePoint.

Sohaib Khan

Sohaib Khan

推荐答案

如果您想通过c#读取excel数据,则可以使用COM库. /span>

If you want to read excel data by c#, you could use COM library.

示例代码:

//创建COM对象.为所引用的所有内容创建一个COM对象

Excel 应用程序 = Excel 应用程序

Excel.Application xlApp = new Excel.Application();

Excel 工作簿 = . . (@ " sandbox_test.xlsx"

Excel.Workbook xlWorkbook = xlApp.Workbooks.Open(@"sandbox_test.xlsx");

Excel _ Worksheet = . [ ];

Excel._Worksheet xlWorksheet = xlWorkbook.Sheets[1];

Excel 范围 = . ;

Excel.Range xlRange = xlWorksheet.UsedRange;

此处是供您参考的链接.

如果您无法在服务器中安装Office,则可以尝试使用其他库(例如:NPOI).

您可以在下面的线程中查看示例.

然后,您可以通过CSOM/SSOM将数据插入SharePoint列表.

此处提供了一些链接供您参考.

最好的问候,


这篇关于以编程方式将数据从Excel工作表导入SharePoint列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆