ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2017 www.aspforums.com. All rights reserved.Import Excel Data using FileUpload Control To Database using AJAX jQueryHi @zzz,<br />Please try the following<br /><br /><a href = 'link(Threads/203246/Insert-data-into-database-using-jQuery-AJAX-and-ASPNet-Example/)'>Insert data into database using jQuery AJAX and ASP.Net Example</a><br /><br />It might help you.<br /><br />Cheers Andrea.http://www.aspforums.net/Threads/134232/Import-Excel-Data-using-FileUpload-Control-To-Database-using-AJAX-jQuery/http://www.aspforums.net/Threads/134232/Import-Excel-Data-using-FileUpload-Control-To-Database-using-AJAX-jQuery/Tue, 08 Nov 2016 23:50:50 GMTImport Excel Data using FileUpload Control To Database using AJAX jQuery<p>Sorry Andrea, it is not what Im looking for.</p>http://www.aspforums.net/Threads/134232/Import-Excel-Data-using-FileUpload-Control-To-Database-using-AJAX-jQuery/http://www.aspforums.net/Threads/134232/Import-Excel-Data-using-FileUpload-Control-To-Database-using-AJAX-jQuery/Wed, 09 Nov 2016 00:42:51 GMTImport Excel Data using FileUpload Control To Database using AJAX jQuery<p>Hi <a class="username" rel="zzz"> zzz</a>,</p> <p>I am working. Once done i will get back to you.</p>http://www.aspforums.net/Threads/134232/Import-Excel-Data-using-FileUpload-Control-To-Database-using-AJAX-jQuery/http://www.aspforums.net/Threads/134232/Import-Excel-Data-using-FileUpload-Control-To-Database-using-AJAX-jQuery/Wed, 09 Nov 2016 06:40:53 GMTImport Excel Data using FileUpload Control To Database using AJAX jQuery<p>Hi zzz,</p> <p>I have created a sample which full fill your requirement taking reference of below articles</p> <h1 class="header"><a href="http://www.aspsnippets.com/Articles/Read-and-Import-Excel-data-to-DataTable-using-ClosedXml-in-ASPNet-with-C-and-VBNet.aspx">Read and Import Excel data to DataTable using ClosedXml in ASP.Net with C# and VB.Net </a></h1> <h1 class="header"><a href="http://www.aspsnippets.com/Articles/Upload-multiple-files-with-Progress-Bar-using-Flash-in-ASPNet.aspx">Upload multiple files with Progress Bar using Flash in ASP.Net</a></h1> <p><span style="text-decoration: underline;">FilePath,cs</span></p> <pre class="brush: csharp">public static class FilePath { /// &lt;summary&gt; /// Gets or sets FilePath. /// &lt;/summary&gt; public static string FilePathDetail { get; set; } }</pre> <p><span style="text-decoration: underline;">Default.aspx</span></p> <pre class="brush: html">&lt;div&gt; &lt;asp:FileUpload ID=&#34;FileUpload1&#34; runat=&#34;server&#34; /&gt; &lt;br /&gt; &lt;asp:Button ID=&#34;btnDisplay&#34; Text=&#34;Display&#34; runat=&#34;server&#34; /&gt; &lt;br /&gt; &lt;br /&gt; &lt;table id=&#34;tblExcel&#34;&gt; &lt;/table&gt; &lt;/div&gt; &lt;div&gt; &lt;link rel=&#34;Stylesheet&#34; type=&#34;text/css&#34; href=&#34;CSS/uploadify.css&#34; /&gt; &lt;script type=&#34;text/javascript&#34; src=&#39;http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.3.min.js&#39;&gt;&lt;/script&gt; &lt;script type=&#34;text/javascript&#34; src=&#34;scripts/jquery.uploadify.js&#34;&gt;&lt;/script&gt; &lt;script type=&#34;text/javascript&#34;&gt; $(function () { $(&#34;#&lt;%=FileUpload1.ClientID%&gt;&#34;).fileUpload({ &#39;uploader&#39;: &#39;scripts/uploader.swf&#39;, &#39;cancelImg&#39;: &#39;images/cancel.png&#39;, &#39;buttonText&#39;: &#39;Browse Files&#39;, &#39;script&#39;: &#39;Upload.ashx&#39;, &#39;folder&#39;: &#39;uploads&#39;, &#39;fileDesc&#39;: &#39;Excel Files&#39;, &#39;fileExt&#39;: &#39;*.xlsx&#39;, &#39;multi&#39;: false, &#39;auto&#39;: true }); $(&#39;#btnDisplay&#39;).click(function () { $.ajax({ type: &#34;POST&#34;, url: &#34;Default.aspx/BindExcelData&#34;, data: &#39;{}&#39;, contentType: &#34;application/json; charset=utf-8&#34;, dataType: &#34;json&#34;, success: function (response) { $(&#34;#tblExcel&#34;).empty(); var xmlDoc = $.parseXML(response.d); var xml = $(xmlDoc); var details = xml.find(&#34;ExcelData&#34;); var table = $(&#34;#tblExcel&#34;); var row = $(table[0].insertRow(-1)); details.eq(0).children().each(function () { var headerCell = $(&#34;&lt;th /&gt;&#34;); headerCell.html(this.nodeName); row.append(headerCell); }); $(details).each(function () { row = $(table[0].insertRow(-1)); $(this).children().each(function () { var cell = $(&#34;&lt;td /&gt;&#34;); cell.html($(this).text()); row.append(cell); }); }); } }); return false; }); }); &lt;/script&gt; &lt;/div&gt;</pre> <p><span style="text-decoration: underline;">Default.aspx.cs</span></p> <pre class="brush: csharp">[WebMethod(EnableSession = true)] public static string BindExcelData() { string filePath = FilePath.FilePathDetail; DataTable dt = new DataTable(&#34;ExcelData&#34;); using (XLWorkbook workBook = new XLWorkbook(filePath)) { IXLWorksheet workSheet = workBook.Worksheet(1); bool firstRow = true; foreach (IXLRow row in workSheet.Rows()) { if (firstRow) { foreach (IXLCell cell in row.Cells()) { dt.Columns.Add(cell.Value.ToString()); } firstRow = false; } else { dt.Rows.Add(); int i = 0; foreach (IXLCell cell in row.Cells()) { dt.Rows[dt.Rows.Count - 1][i] = cell.Value.ToString(); i++; } } } } dt.Rows.RemoveAt(dt.Rows.Count - 1); string constr = ConfigurationManager.ConnectionStrings[&#34;constr&#34;].ConnectionString; SqlConnection con = new SqlConnection(constr); SqlCommand cmd; con.Open(); foreach (DataRow row in dt.Rows) { string query = &#34;INSERT INTO [CustomersWithOutIdentity] (&#34;; foreach (DataColumn column in dt.Columns) { query = query + column + &#34;,&#34;; } query = query.Remove(query.Length - 1); query = query + &#34;) VALUES (&#34;; for (int i = 0; i &lt; dt.Columns.Count; i++) { query = query + &#34;&#39;&#34; + row[dt.Columns[i]] + &#34;&#39;,&#34;; } query = query.Remove(query.Length - 1); query = query + &#34;)&#34;; cmd = new SqlCommand(query, con); cmd.ExecuteNonQuery(); } con.Close(); DataSet ds = new DataSet(); ds.Tables.Add(dt); return ds.GetXml(); }</pre> <p><span style="text-decoration: underline;">Upload.ashx</span></p> <pre class="brush: csharp">&lt;%@ WebHandler Language=&#34;C#&#34; Class=&#34;Upload&#34; %&gt; using System; using System.Web; using System.IO; using System.Web.SessionState; public class Upload : IHttpHandler, IRequiresSessionState { public void ProcessRequest(HttpContext context) { context.Response.ContentType = &#34;text/plain&#34;; context.Response.Expires = -1; try { HttpPostedFile postedFile = context.Request.Files[&#34;Filedata&#34;]; string savepath = &#34;&#34;; string tempPath = &#34;&#34;; tempPath = System.Configuration.ConfigurationManager.AppSettings[&#34;FolderPath&#34;]; savepath = context.Server.MapPath(tempPath); string filename = postedFile.FileName; FilePath.FilePathDetail = savepath + @&#34;\&#34; + filename; if (!Directory.Exists(savepath)) Directory.CreateDirectory(savepath); postedFile.SaveAs(savepath + @&#34;\&#34; + filename); } catch (Exception ex) { context.Response.Write(&#34;Error: &#34; + ex.Message); } } public bool IsReusable { get { return false; } } }</pre> <p><span style="text-decoration: underline;">ScreenShot</span></p> <p><img src="http://i988.photobucket.com/albums/af3/mudassarkhan/134232.gif" alt="" width="372" height="481" /></p>http://www.aspforums.net/Threads/134232/Import-Excel-Data-using-FileUpload-Control-To-Database-using-AJAX-jQuery/http://www.aspforums.net/Threads/134232/Import-Excel-Data-using-FileUpload-Control-To-Database-using-AJAX-jQuery/Thu, 10 Nov 2016 06:03:40 GMT