


In order to find the used range we use "UsedRange" property of xlWorkSheet.
#Local class on using excel on mac how to
How to get the range of occupied cells in excel sheetįor reading entire content of an Excel file in C#, we have to know how many cells used in the Excel file. If you want to select multiple cell value from Excel sheet, you can code like this.Įxcel.Range rng = (Excel.Range) excelSheet.get_Range(excelSheet.Cells, Reading Named Ranges in Excel Worksheet.get_Range Method If you want to select a specific cell in Excel sheet, you can code like this.Įxcel.Worksheet excelSheet = workbook.ActiveSheet Įxcel.Range rng = (Excel.Range)excelSheet.Cells XlWorkSheet = (Excel.Worksheet)_Item(1) Īfter get the selcted worksheet, next step is to specify the used range in worksheet XlWorkBook = 0, true, 5, "", "", true, .XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0) Next step is to open the Excel file and get the specified worksheet. Select Microsoft Excel 15.0 Object Library of COM leftside menu and click OK button.Īfter import the reference library, we have to initialize the Excel application Object. Select Add Reference dialogue from Project menu of your Visual Studio. How to use COM Interop to Create an Excel Spreadsheetįorm the following pictures you can find how to add Excel reference library in your project. NET, you have to add the Microsoft Excel 15.0 Object Library to you project.Ĭreate a new project in your Visual Studio and add a Command Button to your C# Form. To access the object model from Visual C#. Also you can see how to find Named Ranges in Excel and get the range of occupied cells (Used area) in excel sheet. The following program illustrates how to open an existing Excel spreadsheet in C# using.
