none
How to using c# script to extract data from Excel RRS feed

  • Question

  • Hi Masters,

    I have an issues,source file is EXCEL file,and the data include ‘\n’ as below, and I need split the data from cell and insert three different columns, very grateful.

    Tuesday, February 18, 2020 2:43 AM

Answers

  •  for (int i = 1; i <= 5; i++)
                {
                    //Acquire first data
                    str = dt.Rows[0][i].ToString();
                    
                    //split the data and insert variables;
                    strArray = str.Split('\n');
                    count = strArray.Length;
                    ActualorForecast = strArray[0];
                    Quarter = strArray[1];
                    //Actual has no period
                    string Period;
                    if (count == 2)
                    {
                        Period = "";
                    }
                    else
                    {
                        Period = strArray[2];
                    }
                    
                    
                    //split new data merge togather
                    for (int j = 1; j <= dt.Rows.Count-1; j++)
                    {
                        
                        if (dt.Rows[j][i] is DBNull)
                        {
                            val = 0;
                        }
                        else
                        {
                            val = Convert.ToSingle(dt.Rows[j][i]);
    
                        }
                        dtAcc.Rows.Add(dt.Rows[j][0],val, ActualorForecast, Quarter, Period, Comp, Dept, Acct, Prod, Proj, GEO, BU);
                        
                    }
                }

    • Marked as answer by arlsen Wednesday, February 26, 2020 3:43 AM
    Wednesday, February 26, 2020 3:43 AM