ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Import Excel sheet with Images and save in database using Aspose.Cells library in ASP.Net<p>Refer below links.</p> <p><a href="https://archive.codeplex.com/?p=exportexcelgridview">https://archive.codeplex.com/?p=exportexcelgridview</a></p> <p><a href="https://forums.asp.net/t/1464349.aspx?Import+image+from+excel+to+datatable+">https://forums.asp.net/t/1464349.aspx?Import+image+from+excel+to+datatable+</a></p> <p>&nbsp;</p>https://www.aspforums.net:443/Threads/321577/Import-Excel-sheet-with-Images-and-save-in-database-using-AsposeCells-library-in-ASPNet/https://www.aspforums.net:443/Threads/321577/Import-Excel-sheet-with-Images-and-save-in-database-using-AsposeCells-library-in-ASPNet/Wed, 10 Jul 2019 08:07:59 GMTImport Excel sheet with Images and save in database using Aspose.Cells library in ASP.Net<p>Hello Sir,</p> <p>Below is the updated code,</p> <pre class="brush: csharp"> protected void Button2_Click(object sender, EventArgs e) { try { int i = 0; string filename = Server.MapPath(&#34;~/Folder/book1.xlsx&#34;); //Instantiating a Workbook object and open the uploaded file Workbook workbook = new Workbook(filename); //Obtaining the reference of first worksheet by passing its sheet index Worksheet worksheet = workbook.Worksheets[0]; MemoryStream ms = new MemoryStream(); Picture pic = null; int firstRow = 0; int firstColumn = 1; int lastRow = 6; int lastColumn = 5; int imageColumn = 4; //Exporting the contents to DataTable DataTable dataTable = worksheet.Cells.ExportDataTable(firstRow, firstColumn, lastRow, lastColumn, true); Byte[] bytes = null; foreach (DataRow dr in dataTable.Rows) { foreach (GridViewRow g1 in GridView1.Rows) { pic = GetPicture(worksheet.Pictures, i); //Convert picture to stream pic.ToImage(ms, new Aspose.Cells.Rendering.ImageOrPrintOptions()); ms.Position = 0; bytes = ms.ToArray(); i++; string ID = (g1.FindControl(&#34;lblId&#34;) as System.Web.UI.WebControls.Label).Text; string Customer = (g1.FindControl(&#34;lblName&#34;) as System.Web.UI.WebControls.Label).Text; string Country = (g1.FindControl(&#34;lblPrice&#34;) as System.Web.UI.WebControls.Label).Text; string Product = (g1.FindControl(&#34;lblDescription&#34;) as System.Web.UI.WebControls.Label).Text; string sql = &#34;insert into import (ID,Customer,Country,Product,Logo) VALUES (@ID,@Customer,@Country,@Product,@Logo)&#34;; SqlCommand cmd = new SqlCommand(sql, con); cmd.Parameters.Add(&#34;@ID&#34;, SqlDbType.Int).Value = ID; cmd.Parameters.Add(&#34;@Customer&#34;, SqlDbType.VarChar, 50).Value = Customer; cmd.Parameters.Add(&#34;@Country&#34;, SqlDbType.VarChar, 50).Value = Country; cmd.Parameters.Add(&#34;@Product&#34;, SqlDbType.VarChar, 50).Value = Product; cmd.Parameters.Add(&#34;@Logo&#34;, SqlDbType.Image).Value = bytes; con.Open(); cmd.ExecuteNonQuery(); con.Close(); } } } catch(Exception ex) { throw ex; } }</pre> <p>Using the above code I'm now able to successfully insert the data into database with specified images for respective rows.&nbsp;</p> <p><em>Thanks</em></p>https://www.aspforums.net:443/Threads/321577/Import-Excel-sheet-with-Images-and-save-in-database-using-AsposeCells-library-in-ASPNet/https://www.aspforums.net:443/Threads/321577/Import-Excel-sheet-with-Images-and-save-in-database-using-AsposeCells-library-in-ASPNet/Thu, 18 Jul 2019 05:58:45 GMT