Click here to Skip to main content
15,900,687 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
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)The problem is how to put url from sharepoint.I thnk the problem is on the url.
Posted
Updated 1-Oct-12 0:06am
v2

1 solution

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[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900