Hello members,
Hope you are doing good!!
can any one guide me on
How to get count of numbers column from excel sheet using C#
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Jay Krishna ReddyRank #152 · 15.2K reputationPosted Aug 20, 2020, 2:14 AM EDT
using Excel = Microsoft.Office.Interop.Excel; Excel.Application xlApp = null; Excel.Workbook wb = null; Excel.Worksheet worksheet = null; int lastUsedRow = 0; int lastUsedColumn = 0; string srcFile = @"Path to your XLSX file"; xlApp = new Excel.ApplicationClass(); xlApp.Visible = false; wb = xlApp.Workbooks.Open(srcFile, 0, false, 5, "", "", false, Excel.XlPlatform.xlWindows, "", true, false, 0, true, false, false); worksheet = (Excel.Worksheet)wb.Worksheets[1]; Excel.Range range // Find the last real row lastUsedRow = worksheet.Cells.Find("*",System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value, Excel.XlSearchOrder.xlByRows,Excel.XlSearchDirection.xlPrevious, false,System.Reflection.Missing.Value,System.Reflection.Missing.Value).Row; // Find the last real column lastUsedColumn = worksheet.Cells.Find("*", System.Reflection.Missing.Value, System.Reflection.Missing.Value,System.Reflection.Missing.Value, Excel.XlSearchOrder.xlByColumns,Excel.XlSearchDirection.xlPrevious, false,System.Reflection.Missing.Value,System.Reflection.Missing.Value).Column; xlApp.Workbooks.Close(); xlApp.Quit(); Marshal.ReleaseComObject(worksheet); Marshal.ReleaseComObject(wb); Marshal.ReleaseComObject(xlApp); Hope this helps you...Darshan ShahRank #1,135 · 1.6K reputationPosted Aug 20, 2020, 2:16 AM EDT
Yogesh VedpathakRank #1,179 · 1.5K reputationPosted Aug 20, 2020, 2:36 AM EDT
Jay Krishna ReddyRank #152 · 15.2K reputationPosted Aug 20, 2020, 3:20 AM EDT
Leon DRank #851 · 2.6K reputationPosted Aug 20, 2020, 4:23 PM EDT