<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Data Access and ObjectDataSource Control</title><link>http://forums.asp.net/23.aspx</link><description>Questions and discussions related to using ADO.NET for data access, and the ObjectDataSource control. &lt;a href="http://aspadvice.com/SignUp/list.aspx?l=9&amp;c=17" target="_blank"&gt;Email List&lt;/a&gt;</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Re: connect sql datasource to excel in .net</title><link>http://forums.asp.net/thread/3277068.aspx</link><pubDate>Mon, 06 Jul 2009 15:12:55 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3277068</guid><dc:creator>Trini_NAtwaroo</dc:creator><author>Trini_NAtwaroo</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3277068.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=23&amp;PostID=3277068</wfw:commentRss><description>&lt;pre class="c-sharp" name="code"&gt;hey thanks for all your help, i used the code below to add the text before exporting to excel.&lt;/pre&gt;&lt;pre class="c-sharp" name="code"&gt;protected void Page_Load(object sender, EventArgs e)
        {
            VerifyRenderingInServerForm(form1);
            gvToExport.GridLines = GridLines.Both;

        }
        protected void btnExport_Click(object sender, EventArgs e)
        {
            Panel p = new Panel();
            Panel p2 = new Panel();
            Panel p3 = new Panel();
            Panel p4 = new Panel();
            Label lb = new Label();
            Label lb2 = new Label();
            Label lb3 = new Label();
            Label lb4 = new Label();
            lb.Text = &amp;quot;Company Name
            lb2.Text = &amp;quot;Title of report:&amp;quot;;
            lb3.Text = &amp;quot;1st March to 31st March 2008&amp;quot;; // test
            lb4.Text = &amp;quot;------&amp;quot;;
            p.Controls.Add(lb);
            p2.Controls.Add(lb2);
            p3.Controls.Add(lb3);
            p4.Controls.Add(lb4);
                
            Response.Clear();
            Response.AddHeader(&amp;quot;content-disposition&amp;quot;, &amp;quot;attachment;filename=FileName.xls&amp;quot;);
            Response.Charset = &amp;quot;&amp;quot;;
            Response.ContentType = &amp;quot;application/vnd.xls&amp;quot;;
            //StringWriter StringWriter = new System.IO.StringWriter();
           // HtmlTextWriter HtmlTextWriter = new HtmlTextWriter(StringWriter);
           // gvToExport.RenderControl(HtmlTextWriter);
           // Response.Write(StringWriter.ToString());
           // Response.End();
            System.IO.StringWriter stringWrite = new System.IO.StringWriter();
            System.Web.UI.HtmlTextWriter htmlWrite =
            new HtmlTextWriter(stringWrite);
            // turn off paging 
            gvToExport.AllowPaging = false;
            gvToExport.DataBind();
            p.RenderControl(htmlWrite);
            p2.RenderControl(htmlWrite);
            p3.RenderControl(htmlWrite);
            p4.RenderControl(htmlWrite);
            gvToExport.RenderControl(htmlWrite);          
            
            Response.Write(stringWrite.ToString());
            Response.End();
            // turn the paging on again 
            gvToExport.AllowPaging = true;
            gvToExport.DataBind();

        }

        public override void VerifyRenderingInServerForm(Control control)
        {
            /* Verifies that a Form control was rendered */
        }

        protected void gvToExport_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            gvToExport.PageIndex = e.NewPageIndex;
        }
&lt;/pre&gt;&lt;pre class="c-sharp" name="code"&gt;Thanks&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: connect sql datasource to excel in .net</title><link>http://forums.asp.net/thread/3276852.aspx</link><pubDate>Mon, 06 Jul 2009 13:37:27 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3276852</guid><dc:creator>hans_v</dc:creator><author>hans_v</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3276852.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=23&amp;PostID=3276852</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;I didn&amp;#39;t have a change to try it, but a couple of days ago I found a very promising solution on CodePlex:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://excelpackage.codeplex.com/" target="_blank"&gt;ExcelPackage: Office Open XML Format file creation&lt;/a&gt;&lt;/p&gt;</description></item><item><title>Re: connect sql datasource to excel in .net</title><link>http://forums.asp.net/thread/3276809.aspx</link><pubDate>Mon, 06 Jul 2009 13:15:56 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3276809</guid><dc:creator>Trini_NAtwaroo</dc:creator><author>Trini_NAtwaroo</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3276809.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=23&amp;PostID=3276809</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;hey thanks I actually used something similar as it and worked, however I am wondering if I can format the excel spreadsheet before it exports eg I want a title and subject of the excel before the gridview appears, do you have any idea by chance how to do this?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;</description></item><item><title>Re: connect sql datasource to excel in .net</title><link>http://forums.asp.net/thread/3275832.aspx</link><pubDate>Mon, 06 Jul 2009 03:30:39 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3275832</guid><dc:creator>vinz</dc:creator><author>vinz</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3275832.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=23&amp;PostID=3275832</wfw:commentRss><description>&lt;p&gt;&lt;a href="http://www.aspsnippets.com/post/2009/06/19/Exporting-Multiple-GridViews-To-Excel-SpreadSheet-in-ASPNet.aspx"&gt;Exporting Multiple GridViews To Excel SpreadSheet in ASP.Net&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://forums.asp.net/p/1333287/2730291.aspx#2730291"&gt;Export Data to Excel&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;</description></item><item><title>connect sql datasource to excel in .net</title><link>http://forums.asp.net/thread/3275040.aspx</link><pubDate>Sun, 05 Jul 2009 01:35:17 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3275040</guid><dc:creator>Trini_NAtwaroo</dc:creator><author>Trini_NAtwaroo</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3275040.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=23&amp;PostID=3275040</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;hey guys , I need some assistance and advice.&lt;/p&gt;
&lt;p&gt;The final product is an excel sheet. I have a query which returns result ideally I would be doing this using an sql datasource in .net. However what i would accomplish is to &amp;quot;export&amp;quot; the results returned from the query to an excel sheet fill with the returns; as well as additionally add in a title etc. So I was thinking if its possible to connect the datasource to a excel sheet and if this is possible how exactly will I be doing this.&lt;/p&gt;
&lt;p&gt;Please help any ideas or advice is welcomed&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;</description></item></channel></rss>