在SharePoint列表中将数据导出到Excel的问题 [英] Problem to export data to excel in sharepoint list
本文介绍了在SharePoint列表中将数据导出到Excel的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.Office.Interop.Excel;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Client;
namespace test.VisualWebPart1
{
public partial class VisualWebPart1UserControl : UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
error.Text = "";
}
protected void Button1_Click(object sender, EventArgs e)
{
try
{
System.Data.OleDb.OleDbConnection MyConnection;
System.Data.OleDb.OleDbCommand myCommand = new System.Data.OleDb.OleDbCommand();
string sql = null;
MyConnection = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='//eccoe-sps2010:9001/test1/Forms/AllItems.aspx';Extended Properties=Excel 12.0 Xml;");
string date = DateTime.Today.ToShortDateString();
MyConnection.Open();
myCommand.Connection = MyConnection;
sql = "Insert into [S1$] ([DATE]) values('" + date + "')";
myCommand.CommandText = sql;
myCommand.ExecuteNonQuery();
MyConnection.Close();
}
catch (Exception ex)
{
error.Text = ex.Message;
}
}
}
}
1)问题是如何从sharepoint放置url.我认为问题出在url上.
1)The problem is how to put url from sharepoint.I thnk the problem is on the url.
推荐答案
([DATE])values('" +日期+ " ; myCommand.CommandText = sql; myCommand.ExecuteNonQuery(); MyConnection.Close(); } 捕获(例外) { error.Text = ex.Message; } } } }
([DATE]) values('" + date + "')"; myCommand.CommandText = sql; myCommand.ExecuteNonQuery(); MyConnection.Close(); } catch (Exception ex) { error.Text = ex.Message; } } } }
1)问题是如何从sharepoint放置url.我认为问题出在url上.
1)The problem is how to put url from sharepoint.I thnk the problem is on the url.
下面的文章可能不是完全准确的答案,但是您可以尝试一下其中的方法.
9将数据导出到Excel for ASP的解决方案. NET [ ^ ]
^ ]
Below articles may be not the completely exact answer, but you can give it a try of the methods in it.
9 Solutions to Export Data to Excel for ASP.NET[^]
Export Data from Database to Excel via SQL Command and Customize Style of it For VB.NET without Auto[^]
这篇关于在SharePoint列表中将数据导出到Excel的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文