Click here to Skip to main content
15,896,111 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
Follwing Example cell 5,6&7 having empty..after cell 8 itself continue the data..i want to show the grid contains only the numeric values after that empty cells...

in other excell sheet having 5 empty cells..means after that numeric value only i want to show in grid...

cell  Data 1      Data 2        Data 3
1.    filename    blabla.csv
2.    Suplier     Unknown
3.    date
4.    batch        12345
5.
6.
7.
8.    Data_MI	  Data_MI_Log	 Data_WI
9.    31.6227766	1.5	  0
10.   31.74680322	1.5017	  0
11.   ....            ...         ....
12.   ....             ....       ....
----------------------------------------------------------------
This code working on (row count 8 exactly)fetching the text also after that empty cell count so
please kindly rechange the code......


C#
<public datatable="" mode="hold" />    {
        DataTable tblSource = new DataTable();
        tblSource = GetExcelData();

        DataTable tblExtract = new DataTable();
        DataRow drExtractRow;

        tblExtract.Columns.Add("Data_MI");
        tblExtract.Columns.Add("Data_MI_Log");
        tblExtract.Columns.Add("Data_WI");

        int intRecCount = 0;
        foreach (DataRow drSourceRow in tblSource.Rows)
        {
            intRecCount = intRecCount + 1;

            if (intRecCount < 8)
            {
                //Lbl_filenamevalue.Text = tblSource.Rows[0]["f2"].ToString().Trim();
                Lbl_filenamevalue.Text = HiddenField1.Value;
                SuplierLabel.Text = tblSource.Rows[1]["f2"].ToString().Trim();
                string date = tblSource.Rows[2]["f2"].ToString().Trim();
                if (date != null && date != "")
                {
                    DateTime strdate = Convert.ToDateTime(tblSource.Rows[2]["f2"].ToString().Trim());
                    DatLabel.Text = strdate.ToString("dd-MMM-yyyy");
                }
                else
                {
                    DatLabel.Text = DateTime.Now.ToString("dd-MMM-yyyy");
                }
                BatchIDLabel.Text = tblSource.Rows[3]["f2"].ToString().Trim();
            }

            else
            {
                drExtractRow = tblExtract.NewRow();
                drExtractRow["Data_MI"] = drSourceRow["f1"].ToString() != "";
                if (drSourceRow["f2"] != null && drSourceRow["f2"].ToString() != "")
                {
                    drExtractRow["Data_MI_Log"] = drSourceRow["f2"];
                }
                else
                {
                    double log_mi = Double.Parse(drSourceRow["f1"].ToString());
                    double roundoff = Math.Log10(log_mi);
                    drExtractRow["Data_MI_Log"] = Math.Round((decimal)roundoff, 3);
                }
                drExtractRow["Data_WI"] = drSourceRow["f3"].ToString() != ""; ;
                tblExtract.Rows.Add(drExtractRow);
            }
        }
        tblSource.Clear();
        return tblExtract;

    }>
Posted
Updated 3-Jan-12 4:10am
v2
Comments
Wendelius 3-Jan-12 10:11am    
Pre tags added

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