Example #1
0
 //============================================================
 // <T>执行模版分页导出。<T>
 //============================================================
 public void SaveTemplate()
 {
     using (FXlsDocument xlsDoc = new FXlsDocument()) {
         int itemCount = lvwTemplate.CheckedItems.Count;
         for (int i = 0; i < itemCount; i++)
         {
             ListViewItem template = lvwTemplate.Items[i];
             FXmlNode     node     = template.Tag as FXmlNode;
             if (template.Checked)
             {
                 string source = node.Get("source");
                 string tag    = node.Get("tag");
                 string target = node.Get("target");
                 string name   = node.Get("name");
                 xlsDoc.LoadFile(_templateSource + source);
                 xlsDoc.SaveXmlPath((_templateTarget + target), tag);
             }
         }
     }
 }
Example #2
0
        //============================================================
        public void Process(string filename)
        {
            FXmlDocument xdoc           = new FXmlDocument();
            FXmlNode     nodeExportList = null;

            xdoc.LoadFile(filename);
            foreach (FXmlNode node in xdoc.Root.Nodes)
            {
                if ("ExcelExportList" == node.Name)
                {
                    nodeExportList = node;
                    string saveSource = node.Nvl("source_path");
                    string saveTarget = node.Nvl("target_path");
                    // 处理所有Excel文档
                    using (FXlsDocument xlsDox = new FXlsDocument()) {
                        foreach (FXmlNode enode in node.Nodes)
                        {
                            bool valid = enode.GetBoolean("valid");
                            if (valid)
                            {
                                // 读取设置
                                string source = enode.Nvl("source");
                                string tag    = enode.Nvl("tag");
                                string target = enode.Nvl("target");
                                string name   = enode.Nvl("name");
                                // 转换文件
                                xlsDox.LoadFile(saveSource + source);
                                xlsDox.SaveXmlPath((saveTarget + target), tag);
                                foreach (FXmlNode cnode in enode.Nodes)
                                {
                                    string copy = cnode.Text;
                                    if (null != copy)
                                    {
                                        xlsDox.SaveXmlPath(copy, tag);
                                    }
                                }
                            }
                        }
                    }
                }
                else if ("ConverterExportList" == node.Name)
                {
                    foreach (FXmlNode cnode in node.Nodes)
                    {
                        bool valid = cnode.GetBoolean("valid");
                        if (valid)
                        {
                            // 读取设置
                            string type = cnode.Nvl("type");
                            // 接口实现相应xml文件合并
                            ITplConverter ftpl = CreatConverter(type);
                            if (null != ftpl)
                            {
                                ftpl.LoadExportListConfig(nodeExportList);
                                ftpl.LoadConfig(cnode);
                                ftpl.Process();
                            }
                        }
                    }
                }
            }
        }