Ejemplo n.º 1
0
        private List<TemplateStruct> GetTemplateStructList(XmlNode root)
        {
            List<TemplateStruct> list = new List<TemplateStruct>();

            foreach (XmlNode node in root.ChildNodes)
            {
                if (node.ChildNodes.Count != 0)
                {
                    XmlNode item = node.ChildNodes[0];

                    if (item.NodeType != XmlNodeType.Element) continue;

                    TemplateStruct t = new TemplateStruct();

                    t.NodeName = item.LocalName;
                    t.Attributes = new List<string>();

                    foreach (XmlAttribute att in item.Attributes)
                    {
                        t.Attributes.Add(att.LocalName);
                    }

                    list.Add(t);
                }
            }

            return list;
        }
Ejemplo n.º 2
0
        private Dictionary<string, TemplateStruct> GetExcelStructList(MSExcel.Workbook wbook)
        {
            Dictionary<string, TemplateStruct> list = new Dictionary<string, TemplateStruct>();

            int count = wbook.Worksheets.Count;

            for (int i = 0; i < count; i++)
            {
                MSExcel.Worksheet sheet = wbook.Worksheets[i + 1];

                TemplateStruct ts = new TemplateStruct();

                ts.NodeName = sheet.Name;
                ts.Attributes = new List<string>();
                ts.Types = new List<string>();

                list[ts.NodeName] = ts;

                for (int j = 0; j < ExcelMaxCol; j++)
                {
                    MSExcel.Range r = sheet.get_Range(getCell(StructRow, j + StructCol));

                    if (string.IsNullOrEmpty(r.Value2))
                    {
                        break;
                    }

                    ts.Attributes.Add(r.Value2);

                    MSExcel.Range r2 = sheet.get_Range(getCell(TypeRow, j + StructCol));

                    if (string.IsNullOrEmpty(r.Value2))
                    {
                        ts.Types.Add("System.String");
                    }
                    else
                    {
                        ts.Types.Add(r2.Value2);
                    }
                }
            }

            return list;
        }