Click here to Skip to main content
14,977,910 members
Please Sign up or sign in to vote.
1.80/5 (2 votes)
See more:
Hi All,
I need to read excel cell value in like value of cell A1 or M33 etc.
Thanks in advance.

Try This Out ,May be would help to you...

if (!Page.IsPostBack)
                Excel.Application appExl;
                Excel.Workbook workbook;
                Excel.Worksheet NwSheet;
                Excel.Range ShtRange;
                appExl = new Excel.ApplicationClass();

                  //Opening Excel file(myData.xlsx)
                workbook = appExl.Workbooks.Open(Server.MapPath("myData.xlsx"), Missing.Value, Missing.Value,Missing.Value,Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,Missing.Value, Missing.Value, Missing.Value, Missing.Value);

                NwSheet = (Excel.Worksheet)workbook.Sheets.get_Item(1);
                int Cnum = 0;
                int Rnum = 0;
                ShtRange = NwSheet.UsedRange; //gives the used cells in sheet
                  //Reading Excel file.
               //Creating datatable to read the containt of the Sheet in File.
                DataTable dt = new DataTable();

                for (Rnum = 2; Rnum <= ShtRange.Rows.Count; Rnum++)
                    DataRow dr = dt.NewRow();
//Reading Each Column value From sheet to datatable Colunms                  
                    for (Cnum = 1; Cnum <= ShtRange.Columns.Count; Cnum++)
                       dr[Cnum - 1] = (ShtRange.Cells[Rnum, Cnum] as Excel.Range).Value2.ToString();
                    dt.Rows.Add(dr); // adding Row into DataTable

                workbook.Close(true, Missing.Value, Missing.Value);

                 gvOne.DataSource = dt;//DataSource to GrigView(Id:gvOne)
Badrinath_subudhi 1-Jun-14 0:46am
I have a value "91223456789033" in excel sheet, But when i open excel sheet it is showing as
9.12235E+13. and when i upload this value , it is storing as "9.12235E+13". How to solve this issue?
The power of Google: About 5,850,000 results (0.42 seconds)[^].
Ambesha 23-Oct-12 5:55am
PRASHANT KUMAR LAL 23-Oct-12 5:56am
I browse but not getting appropriate solution.
CPallini 23-Oct-12 6:04am
You should browse better (downvoting won't help you).
Nelek 23-Oct-12 6:21am
BlackMilan 23-Oct-12 6:33am
Looks like strike dead from too much results ;-)
Member 7873103 22-Sep-16 1:08am
i have 15 digit double in my one cell/column but C# code reading only 7 digit.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900