Esempio n. 1
0
        /// <summary>
        /// 解析多列式
        /// </summary>
        ///
        /// <param name="table"></param>
        /// <param name="contentArr"></param>
        private void ParseMultiColType(ETable table, String[] contentArr)
        {
            if (contentArr.Length > 1)
            {
                List <string[]> porpList = new List <string[]>();
                for (int i = 1; i < contentArr.Length; i++)
                {
                    String linestr = contentArr[i].Trim();
                    // System.out.println("linestr="+linestr);
                    if (linestr.StartsWith("#"))
                    {
                        linestr = linestr.Substring(1);
                        String[] lineArr = SplitString(linestr);
                        porpList.Add(lineArr);
                    }
                }
                String[] columnNames = new String[porpList.Count];
                for (int col = 0; col < columnNames.Length; col++)
                {
                    columnNames[col] = porpList[col][1];
                }
                table.SetColumnNames(columnNames);

                for (int row = 2; row < porpList[0].Length; row++)
                {
                    String[] data = new String[columnNames.Length];
                    for (int col_0 = 0; col_0 < data.Length; col_0++)
                    {
                        data[col_0] = porpList[col_0][row];
                    }
                    table.GetDatas().Add(data);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 解析横表式
        /// </summary>
        ///
        /// <param name="table"></param>
        /// <param name="contentArr"></param>
        private void ParseRowType(ETable table, String[] contentArr)
        {
            String headStr = contentArr[0].Trim();

            String[] headerArr   = SplitString(headStr.Substring("@".Length));
            String[] columnNames = new String[headerArr.Length];
            System.Array.Copy((Array)(headerArr), 0, (Array)(columnNames), 0, columnNames.Length);
            table.SetColumnNames(columnNames);
            if (contentArr.Length > 1)
            {
                for (int i = 1; i < contentArr.Length; i++)
                {
                    String linestr = contentArr[i].Trim();
                    System.Console.Out.WriteLine("datastr=" + linestr);

                    if (linestr.StartsWith("%"))
                    {
                        // 类型
                        String[] lineArr = SplitString(linestr.Substring(1));
                        String[] type    = new String[lineArr.Length];
                        System.Array.Copy((Array)(lineArr), 0, (Array)(type), 0, type.Length);
                        table.SetTypes(type);
                    }
                    else if (linestr.StartsWith("$"))
                    {
                        // 梁纲引导符 单位
                        String[] lineArr_0 = SplitString(linestr.Substring(1));
                        String[] unites    = new String[lineArr_0.Length];
                        System.Array.Copy((Array)(lineArr_0), 0, (Array)(unites), 0, unites.Length);
                        table.SetUnites(unites);
                    }
                    else if (linestr.StartsWith(":"))
                    {
                        // 限值引导符
                        String[] lineArr_1   = SplitString(linestr.Substring(1));
                        String[] limitValues = new String[lineArr_1.Length];
                        System.Array.Copy((Array)(lineArr_1), 0, (Array)(limitValues), 0, limitValues.Length);
                        table.SetLimitValues(limitValues);
                    }
                    else if (linestr.StartsWith("#"))
                    {
                        // 数据值

                        String[] lineArr_2 = SplitString(linestr.Substring(1));
                        String[] data      = new String[lineArr_2.Length];
                        System.Array.Copy((Array)(lineArr_2), 0, (Array)(data), 0, data.Length);
                        table.GetDatas().Add(data);
                    }
                    //else if (linestr.StartsWith("//"))
                    //{

                    //}
                }
            }
        }