How to read single Excel cell value

How to read single Excel cell value

Asked on January 10, 2019 in Excel.
Add Comment

  • 4 Answer(s)

    Just try this solution :

    Considering, it is a single value.So need to convert it to a string , but not an array of string.

    var cellValue = (string)(excelWorksheet.Cells[10, 2] as Excel.Range).Value;
    Answered on January 10, 2019.
    Add Comment

    Try this alternative key :

    using Microsoft.Office.Interop.Excel;
    string path = "C:\\Projects\\ExcelSingleValue\\Test.xlsx ";
    Application excel = new Application();
    Workbook wb = excel.Workbooks.Open(path);
    Worksheet excelSheet = wb.ActiveSheet;
    //Read the first cell
    string test = excelSheet.Cells[1, 1].Value.ToString();

         The above example is used in the Microsoft Excel 15.0 Object Library, but consistent with previous versions of Interop and alternative libraries.

    Answered on January 10, 2019.
    Add Comment

    Use this solution to read single Excel cell value :

    Microsoft.Office.Interop.Excel.Range Range_Number,r2;
    Range_Number = wsheet.UsedRange.Find("smth");
    string f_number="";
    r2 = wsheet.Cells;
    int n_c = Range_Number.Column;
    int n_r = Range_Number.Row;
    var number = ((Range)r2[n_r + 1, n_c]).Value;
    f_number = (string)number;
    Answered on January 10, 2019.
    Add Comment

    Create a cell reference on the same worksheet

    1.Click the cell in which you want to enter the formula.

    2.In the Formula Bar, type = (equal sign).

    3.Do one of the following:

    Reference one or more cells : To create a reference, select a cell or range of cells on the same worksheet. Cell references and the borders around the corresponding cells are color-coded to make it easier to work with them.

    You can drag the border of the cell selection to move the selection, or drag the corner of the border to expand the selection.

    Reference a defined name: To create a reference to a defined name, do one of the following:

    Type the name.

    Press F3, select the name in the Paste name box, and then click OK.

    4.Do one of the following:

    If you are creating a reference in a single cell, press Enter.

    If you are creating a reference in an array formula (such A1:G4), press Ctrl+Shift+Enter.

    The reference can be a single cell or a range of cells, and the array formula can be one that calculates single or multiple results.

    Answered on February 5, 2019.
    Add Comment

  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.