示例#1
0
        private ExportBodyColumnMapping LoadExportBodyColumnMapping(XmlNode node, Export export)
        {
            //ColumnMapType mapType = ColumnMapType.ExcelHeader;
            //XmlNode mapTypeNode = node.Attributes.GetNamedItem("mapType");
            //if (mapTypeNode != null)
            //    mapType = "dataheader".EqualsIgnoreCase(mapTypeNode.Value.Trim()) ? ColumnMapType.DataHeader : ColumnMapType.ExcelHeader;

            ExportBodyColumnMapping column = new ExportBodyColumnMapping(export);

            foreach (XmlAttribute xa in node.Attributes)
            {
                switch (xa.Name)
                {
                case "col":
                    column.ColumnName = xa.Value.Trim();
                    break;

                case "prop":
                    column.PropertyName = xa.Value.Trim();
                    break;

                case "propType":
                    column.PropertyType = "normal".Equals(xa.Value.Trim(), StringComparison.OrdinalIgnoreCase) ? PropertyType.Normal : PropertyType.Expression;
                    break;

                case "title":
                    column.Title = xa.Value.Trim();
                    break;

                default:
                    break;
                }
            }
            return(column);
        }
示例#2
0
        private ExportBody LoadExportBody(XmlNode node, Export export)
        {
            ExportBody body = new ExportBody(export);

            foreach (XmlAttribute xa in node.Attributes)
            {
                switch (xa.Name)
                {
                case "outputTitle":
                    body.OutPutTitle = xa.Value.Trim().SafeToBool();
                    break;

                case "firstRowIndex":
                    body.FirstRowIndex = xa.Value.Trim().SafeToInt() - 1;
                    body.FirstRowIndex = body.FirstRowIndex < 0 ? 0 : body.FirstRowIndex;
                    break;

                case "fillMode":
                    if (xa.Value == "copy")
                    {
                        body.RowMode = FillRowMode.Copy;
                    }
                    else if (xa.Value == "fill")
                    {
                        body.RowMode = FillRowMode.Fill;
                    }
                    else
                    {
                        body.RowMode = FillRowMode.New;
                    }
                    break;

                default:
                    break;
                }
            }

            foreach (XmlNode xn in node.ChildNodes)
            {
                if ("#comment" == xn.Name)
                {
                    continue;
                }

                ExportBodyColumnMapping excolumn = LoadExportBodyColumnMapping(xn, export);
                body.Add(excolumn.ColumnName, excolumn);
            }

            return(body);
        }