<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ASP.NET Archives - Robotic Process Automation | RPA Company in Mumbai, India</title>
	<atom:link href="https://www.aakarsoft.com/category/asp-net/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>Be Better.</description>
	<lastBuildDate>Mon, 10 Dec 2012 07:18:00 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
	<item>
		<title>Export Gridview data to Excel (.xlsx) without using HtmlTextWriter in Asp.NET</title>
		<link>https://www.aakarsoft.com/export-gridview-data-to-excel-xlsx-without-using-htmltextwriter-in-asp-net/</link>
		
		<dc:creator><![CDATA[aaAdmi]]></dc:creator>
		<pubDate>Mon, 10 Dec 2012 07:18:00 +0000</pubDate>
				<category><![CDATA[ASP.NET]]></category>
		<guid isPermaLink="false">https://www.aakarsoft.com/?p=7230</guid>

					<description><![CDATA[<p>You can use export data by using&#160;EPPlus.dll. Following is the sample code. public void ExportToExcel(){DataView dv = new DataView();System.Data.DataTable tbl = new System.Data.DataTable();dv = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty); // To access the data associated with Gridviewtbl = dv.ToTable(); //Following code is copied from&#160;StackOverFlow using (ExcelPackage pck = new ExcelPackage()){//Create the worksheetExcelWorksheet ws = pck.Workbook.Worksheets.Add(“Demo”); //Load the datatable into [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.aakarsoft.com/export-gridview-data-to-excel-xlsx-without-using-htmltextwriter-in-asp-net/">Export Gridview data to Excel (.xlsx) without using HtmlTextWriter in Asp.NET</a> appeared first on <a rel="nofollow" href="https://www.aakarsoft.com">Robotic Process Automation | RPA Company in Mumbai, India</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>You can use export data by using&nbsp;<a href="http://epplus.codeplex.com/" target="_blank" rel="noreferrer noopener" aria-label=" (opens in a new tab)">EPPlus.dll</a>.</p>



<p>Following is the sample code.</p>



<p><code>public void ExportToExcel()<br>{<br>DataView dv = new DataView();<br>System.Data.DataTable tbl = new System.Data.DataTable();<br>dv = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty); // To access the data associated with Gridview<br>tbl = dv.ToTable();</code></p>



<p>//Following code is copied from&nbsp;<a href="http://stackoverflow.com/questions/10058058/create-excel-workbook-in-asp-net" target="_blank" rel="noreferrer noopener" aria-label=" (opens in a new tab)">StackOverFlow</a></p>



<p><code>using (ExcelPackage pck = new ExcelPackage())<br>{<br>//Create the worksheet<br>ExcelWorksheet ws = pck.Workbook.Worksheets.Add(“Demo”);</code></p>



<p><code>//Load the datatable into the sheet, starting from cell A1. Print the column names on row 1<br>ws.Cells["A1"].LoadFromDataTable(tbl, true);</code></p>



<p>//Format the header for column 1-3<br><code>using (ExcelRange rng = ws.Cells["A1:G1"])<br>{<br>rng.Style.Font.Bold = true;<br>rng.Style.Fill.PatternType = ExcelFillStyle.Solid;</code></p>



<p>//Set Pattern for the background to Solid<br><code>rng.Style.Fill.BackgroundColor.SetColor(Color.FromArgb(79, 129, 189));</code></p>



<p>//Set color to dark blue<br><code>rng.Style.Font.Color.SetColor(Color.White);<br>}</code></p>



<p>//Example how to Format Column 1 as numeric<br><code>using (ExcelRange col = ws.Cells[2, 1, 2 + tbl.Rows.Count, 1])<br>{<br>col.Style.Numberformat.Format = “#,##0.00″;<br>col.Style.HorizontalAlignment = ExcelHorizontalAlignment.Right;<br>}</code></p>



<p>//Write it back to the client<br><code>Response.Clear();<br>Response.AddHeader(“content-disposition”, “attachment; filename=file.xlsx”);<br>Response.ContentType = “application/vnd.openxmlformats-officedocument.spreadsheetml.sheet”;<br>Response.BinaryWrite(pck.GetAsByteArray());<br>Response.End();<br>}<br>}</code><br></p>
<p>The post <a rel="nofollow" href="https://www.aakarsoft.com/export-gridview-data-to-excel-xlsx-without-using-htmltextwriter-in-asp-net/">Export Gridview data to Excel (.xlsx) without using HtmlTextWriter in Asp.NET</a> appeared first on <a rel="nofollow" href="https://www.aakarsoft.com">Robotic Process Automation | RPA Company in Mumbai, India</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
