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.Count Number of none empty cells in Excel using C# in ASP.Net<p>Will you please explain in more details and what about the value of X.</p>https://www.aspforums.net:443/Threads/192612/Count-Number-of-none-empty-cells-in-Excel-using-C-in-ASPNet/https://www.aspforums.net:443/Threads/192612/Count-Number-of-none-empty-cells-in-Excel-using-C-in-ASPNet/Fri, 06 May 2016 08:35:51 GMTCount Number of none empty cells in Excel using C# in ASP.Net<p>X is also a value it is not empty... The count must include that also..&nbsp;</p>https://www.aspforums.net:443/Threads/192612/Count-Number-of-none-empty-cells-in-Excel-using-C-in-ASPNet/https://www.aspforums.net:443/Threads/192612/Count-Number-of-none-empty-cells-in-Excel-using-C-in-ASPNet/Fri, 06 May 2016 08:37:30 GMTCount Number of none empty cells in Excel using C# in ASP.Net<p>Then for first ro it is 5 and for second row it is 6.</p>https://www.aspforums.net:443/Threads/192612/Count-Number-of-none-empty-cells-in-Excel-using-C-in-ASPNet/https://www.aspforums.net:443/Threads/192612/Count-Number-of-none-empty-cells-in-Excel-using-C-in-ASPNet/Fri, 06 May 2016 08:39:38 GMTCount Number of none empty cells in Excel using C# in ASP.Net<p>For the first row it should be 4 and for second row it is 5.</p> <p>TC No is the for like S.NO so you can ignore it.&nbsp;</p>https://www.aspforums.net:443/Threads/192612/Count-Number-of-none-empty-cells-in-Excel-using-C-in-ASPNet/https://www.aspforums.net:443/Threads/192612/Count-Number-of-none-empty-cells-in-Excel-using-C-in-ASPNet/Fri, 06 May 2016 08:45:20 GMTCount Number of none empty cells in Excel using C# in ASP.Net<p>Hi <a class="username" rel="vygi0913">vygi0913</a>,</p> <p>Here i have created sample that full fill your requirement. You can refer the below article to read the data from excel to dataset.</p> <h1 class="header"><a title="Read Excel file using OLEDB Data Provider in C# .Net'a" href="http://www.aspsnippets.com/Articles/Read-Excel-file-using-OLEDB-Data-Provider-in-C-Net.aspx">Read Excel file using OLEDB Data Provider in C# .Net</a></h1> <p><span style="text-decoration: underline;">Code</span></p> <pre class="brush: csharp">private void btnGetCount_Click(object sender, EventArgs e) { &nbsp;&nbsp;&nbsp; string strExcelConn = &#34;Provider=Microsoft.Jet.OLEDB.4.0; Data Source=&#34; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; + @&#34;D:\Test.xls&#34; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; + &#34;; Extended Properties=&#39;Excel 8.0;HDR=Yes&#39;&#34;; &nbsp;&nbsp;&nbsp; OleDbConnection connExcel = new OleDbConnection(strExcelConn); &nbsp;&nbsp;&nbsp; OleDbCommand cmdExcel = new OleDbCommand(); &nbsp;&nbsp;&nbsp; OleDbDataAdapter da = new OleDbDataAdapter(); &nbsp;&nbsp;&nbsp; cmdExcel.Connection = connExcel; &nbsp;&nbsp;&nbsp; connExcel.Open(); &nbsp;&nbsp;&nbsp; DataTable dtExcelSchema; &nbsp;&nbsp;&nbsp; dtExcelSchema = connExcel.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null); &nbsp;&nbsp;&nbsp; connExcel.Close(); &nbsp;&nbsp;&nbsp; DataSet ds = new DataSet(); &nbsp;&nbsp;&nbsp; string SheetName = dtExcelSchema.Rows[0][&#34;TABLE_NAME&#34;].ToString(); &nbsp;&nbsp;&nbsp; cmdExcel.CommandText = &#34;SELECT * From [&#34; + SheetName + &#34;]&#34;; &nbsp;&nbsp;&nbsp; da.SelectCommand = cmdExcel; &nbsp;&nbsp;&nbsp; da.Fill(ds); &nbsp;&nbsp;&nbsp; string nonEmptyCell = string.Empty; &nbsp;&nbsp;&nbsp; for (int row = 0; row &lt; ds.Tables[0].Rows.Count; row++) &nbsp;&nbsp;&nbsp; { string tcNo = ds.Tables[0].Rows[row].ItemArray[0].ToString(); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int count = 0; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (int column = 1; column &lt; ds.Tables[0].Rows[row].ItemArray.Length; column++) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string value = ds.Tables[0].Rows[row][column].ToString(); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!string.IsNullOrEmpty(value)) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; count++; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; nonEmptyCell += &#34;TC NO &#34; + tcNo + &#34; has &#34; + count + &#34; non empty cells. \n&#34;; &nbsp;&nbsp;&nbsp; } &nbsp;&nbsp;&nbsp; lblCount.Text = nonEmptyCell; }</pre> <p><span style="text-decoration: underline;">Screenshot</span></p> <p><img src="https://i.imgur.com/qvAfVk9.jpg" alt="" width="472" height="255" /></p>https://www.aspforums.net:443/Threads/192612/Count-Number-of-none-empty-cells-in-Excel-using-C-in-ASPNet/https://www.aspforums.net:443/Threads/192612/Count-Number-of-none-empty-cells-in-Excel-using-C-in-ASPNet/Fri, 06 May 2016 09:39:39 GMT