Пример #1
0
        bool ParsePath(excel_path_full path)
        {
            int column = 0;

            foreach (var it in indexPathAll)
            {
                var cell_path = new excel_path_cell();
                path.Paths.Add(cell_path);
                foreach (var sectionIt in it)
                {
                    excel_section section_path = new excel_section();
                    cell_path.CellPath.Add(section_path);
                    section_path.Index   = sectionIt.index;
                    section_path.Section = sectionIt.GetRealSection();

                    if (!type2PBEnumType.TryGetValue(sectionIt.dataType, out excel_section.Types.DATA_TYPE pbType))
                    {
                        ConsoleError(msgName, -1, "不支持的数据类型,列[" + GetExcelColumn(column) + "],dataType=" + sectionIt.dataType.ToString());
                        return(false);
                    }
                    section_path.DataType = pbType;
                }
                column++;
            }
            return(true);
        }
Пример #2
0
 bool ParsePath(excel_path_full path)
 {
     foreach (var it in indexPathAll)
     {
         var cell_path = new excel_path_cell();
         path.Paths.Add(cell_path);
         foreach (var sectionIt in it)
         {
             excel_section section_path = new excel_section();
             cell_path.CellPath.Add(section_path);
             section_path.Index   = sectionIt.index;
             section_path.Section = ByteString.CopyFromUtf8(sectionIt.GetRealSection());
         }
     }
     return(true);
 }
Пример #3
0
        public static void Test2()
        {
            excel_path_full pathInfo = new excel_path_full();
            excel_path_cell tempCellPath;
            excel_section   tempSection;

            //id
            tempCellPath = new excel_path_cell();
            pathInfo.Paths.Add(tempCellPath);
            tempSection = new excel_section();
            tempCellPath.CellPath.Add(tempSection);
            tempSection.Section  = "id";
            tempSection.DataType = excel_section.Types.DATA_TYPE.Int32;
            //count
            tempCellPath = new excel_path_cell();
            pathInfo.Paths.Add(tempCellPath);
            tempSection = new excel_section();
            tempCellPath.CellPath.Add(tempSection);
            tempSection.Section  = "count";
            tempSection.DataType = excel_section.Types.DATA_TYPE.String;
            //value1
            tempCellPath = new excel_path_cell();
            pathInfo.Paths.Add(tempCellPath);
            tempSection = new excel_section();
            tempCellPath.CellPath.Add(tempSection);
            tempSection.Section  = "value";
            tempSection.Index    = 1;
            tempSection.DataType = excel_section.Types.DATA_TYPE.Int32;
            //value2
            tempCellPath = new excel_path_cell();
            pathInfo.Paths.Add(tempCellPath);
            tempSection = new excel_section();
            tempCellPath.CellPath.Add(tempSection);
            tempSection.Section  = "value";
            tempSection.Index    = 2;
            tempSection.DataType = excel_section.Types.DATA_TYPE.Int32;
            //skill-id
            tempCellPath = new excel_path_cell();
            pathInfo.Paths.Add(tempCellPath);
            tempSection = new excel_section();
            tempCellPath.CellPath.Add(tempSection);
            tempSection.Section = "skill";
            tempSection.Index   = 1;
            tempSection         = new excel_section();
            tempCellPath.CellPath.Add(tempSection);
            tempSection.Section  = "id";
            tempSection.Index    = 0;
            tempSection.DataType = excel_section.Types.DATA_TYPE.Double;
            //skill-rate
            tempCellPath = new excel_path_cell();
            pathInfo.Paths.Add(tempCellPath);
            tempSection = new excel_section();
            tempCellPath.CellPath.Add(tempSection);
            tempSection.Section = "skill";
            tempSection.Index   = 1;
            tempSection         = new excel_section();
            tempCellPath.CellPath.Add(tempSection);
            tempSection.Section  = "rate";
            tempSection.Index    = 0;
            tempSection.DataType = excel_section.Types.DATA_TYPE.Int32;
            //skill2-id
            tempCellPath = new excel_path_cell();
            pathInfo.Paths.Add(tempCellPath);
            tempSection = new excel_section();
            tempCellPath.CellPath.Add(tempSection);
            tempSection.Section = "skill";
            tempSection.Index   = 2;
            tempSection         = new excel_section();
            tempCellPath.CellPath.Add(tempSection);
            tempSection.Section  = "id";
            tempSection.Index    = 0;
            tempSection.DataType = excel_section.Types.DATA_TYPE.Double;
            //skill2-rate
            tempCellPath = new excel_path_cell();
            pathInfo.Paths.Add(tempCellPath);
            tempSection = new excel_section();
            tempCellPath.CellPath.Add(tempSection);
            tempSection.Section = "skill";
            tempSection.Index   = 2;
            tempSection         = new excel_section();
            tempCellPath.CellPath.Add(tempSection);
            tempSection.Section  = "rate";
            tempSection.Index    = 0;
            tempSection.DataType = excel_section.Types.DATA_TYPE.Int32;

            string[] descList =
            {
                "7", "aa6", "5", "4", "3.111", "2", "10.22", "11"
            };

            GetInstance().excelScript.ImportPath(pathInfo, "test_python_all");
            GetInstance().excelScript.AddLineData(descList);

            test_python_all all = new test_python_all();

            all.MergeFrom(GetInstance().excelScript.OutputData());
            Console.WriteLine("all=" + all.ToString());
        }