Exemple #1
0
        public Dictionary <int, Clazz> GetExcelTitleToClazzMap(ISheet sheet, string mapFile, int titleIndex, string classForName)
        {
            Dictionary <string, int> titleList = this.getTitleList(sheet.GetRow(titleIndex));
            Dictionary <int, Clazz>  result;

            if (titleList == null)
            {
                result = null;
            }
            else
            {
                Dictionary <string, string> map         = ExcelRead.ReadExcelToDic(mapFile, 0);
                Dictionary <int, string>    functionMap = this.MapToMapKeyToValue(titleList, map);
                Dictionary <string, Clazz>  methodMap   = ReExcelUtils.MethodToLowerFunction(classForName);
                Dictionary <int, Clazz>     dictionary  = this.MapToMapKeyToValue(functionMap, methodMap);
                result = dictionary;
            }
            return(result);
        }
Exemple #2
0
        /// <summary>
        /// 代码关系转换 为文字关系
        /// </summary>
        /// <param name="hzs"></param>
        private static void DMToText(IList <JTCY> hzs)
        {
            int value;
            Dictionary <string, string> yhzgxDic = ExcelRead.ReadExcelToDic(System.AppDomain.CurrentDomain.BaseDirectory + "家庭关系代码.xls", 0);

            foreach (JTCY hz in hzs)
            {
                foreach (JTCY jtcy in hz.jTCies)
                {
                    string sex = jtcy.XB;
                    if (sex != null)
                    {
                        if (int.TryParse(sex, out value))
                        {
                            if (value % 2 == 0)
                            {
                                jtcy.XB = "男";
                            }
                            else
                            {
                                jtcy.XB = "女";
                            }
                        }
                    }
                    string yhzgx = jtcy.YHZGX;

                    if (!Utils.IsStrNull(yhzgx) && yhzgxDic.TryGetValue(yhzgx, out yhzgx))
                    {
                        jtcy.YHZGX = yhzgx;
                    }
                    string sfgyr = jtcy.SFGYR;
                    if (sfgyr == "1" || sfgyr == "是")
                    {
                        jtcy.SFGYR = "是";
                    }
                    else
                    {
                        jtcy.SFGYR = "否";
                    }
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// 导出 农村土地家庭承包农户基本情况信息表(一)
        /// </summary>
        /// <param name="hzs"></param>
        public static bool ExportBsicInformationExcel(IList <JTCY> hzs, string saveDir)
        {
            Dictionary <string, string> dklbDic = new Dictionary <string, string>();

            dklbDic.Add("10", "承包地");
            dklbDic.Add("21", "自留地");
            dklbDic.Add("22", "机动地");
            dklbDic.Add("23", "开荒地");
            dklbDic.Add("99", "其他集体土地");


            if (Utils.IsStrNull(saveDir))
            {
                return(false);
            }
            string basicInformationExxcelTemplete       = System.AppDomain.CurrentDomain.BaseDirectory + "CBDTemplete\\农村土地家庭承包农户基本情况信息表(一)模板.xls";
            Dictionary <int, XMLTable>     ClazzDic     = XMLRead.GetXmlToXMLTabl(System.AppDomain.CurrentDomain.BaseDirectory + "CBDTemplete\\WriteJTCYBaicInformationExcel.xml");
            Dictionary <string, XMLObject> xmlObjectDic = XMLRead.XmlToObjects(System.AppDomain.CurrentDomain.BaseDirectory + "CBDTemplete\\WriteJTCYBaicInformationExcel.xml");



            string basicInformationExxcelTemplete2       = System.AppDomain.CurrentDomain.BaseDirectory + "CBDTemplete\\农村土地承包经营权(家庭承包)台帐(二)模板.xls";
            Dictionary <int, XMLTable>     ClazzDic2     = XMLRead.GetXmlToXMLTabl(System.AppDomain.CurrentDomain.BaseDirectory + "CBDTemplete\\WriteDKBaicInformationExcel.xml");
            Dictionary <string, XMLObject> xmlObjectDic2 = XMLRead.XmlToObjects(System.AppDomain.CurrentDomain.BaseDirectory + "CBDTemplete\\WriteDKBaicInformationExcel.xml");


            string cbfbm;

            if (Utils.CheckListExists(hzs))
            {
                DMToText(hzs);
                foreach (JTCY hz in hzs)
                {
                    string cbfdz = hz.DZ;
                    if (!cbfdz.EndsWith("组"))
                    {
                        cbfdz = cbfdz.Substring(0, cbfdz.LastIndexOf("组")) + "组";
                    }
                    int index = cbfdz.IndexOf("镇");
                    if (index == -1)
                    {
                        index = cbfdz.IndexOf("乡");
                    }
                    hz.DZ = cbfdz.Substring(index + 1, cbfdz.Length - index - 1);
                    XMLTable  xmlTable = ClazzDic[0];
                    IWorkbook workbook = ExcelRead.ReadExcel(basicInformationExxcelTemplete);
                    ISheet    sheet    = workbook.GetSheetAt(0);
                    //家庭成员表行数据插入
                    ExcelWrite.WriteObjects(sheet, xmlTable, hz.jTCies);
                    //家庭成员表 文字替换
                    ExcelWrite.ReplaceTextByXMLObject(sheet, hz, xmlObjectDic);
                    ExcelWrite.Save(workbook, saveDir + "//TZ-" + hz.CBFBM.Substring(0, 14) + " " + cbfdz + "\\TZ4 -" + hz.CBFBM + "-1农村土地家庭承包农户基本情况信息表(一).xls");

                    //写地块表
                    Dictionary <string, string> tdlylxDic = ExcelRead.ReadExcelToDic(System.AppDomain.CurrentDomain.BaseDirectory + "CBDTemplete\\土地利用类型映射表.xlsx", 0);
                    IList <DK> dks = hz.DKs;
                    if (dks == null)
                    {
                        continue;
                    }
                    foreach (DK dk in dks)
                    {
                        if (dk.DKLB == "21")
                        {
                            dk.ZLDMJ = Math.Round(dk.HTMJ, 2).ToString("f2");
                        }
                        else
                        {
                            dk.ELCBMJ = Math.Round(dk.HTMJ, 2).ToString("f2");
                        }


                        string dklb = dk.DKLB;
                        if (dklb != null)
                        {
                            if (dklbDic.TryGetValue(dklb, out dklb))
                            {
                                //地块类别无法识别的情况
                                dk.DKLB = dklb;
                            }
                        }
                        string tdlylx = dk.TDLYLX;
                        if (tdlylx != null)
                        {
                            if (tdlylxDic.TryGetValue(tdlylx, out tdlylx))
                            {
                                dk.TDLYLX = tdlylx;
                            }
                        }
                    }
                    IWorkbook workbook2 = ExcelRead.ReadExcel(basicInformationExxcelTemplete2);
                    ISheet    sheet2    = workbook2.GetSheetAt(0);
                    ExcelWrite.ReplaceTextByXMLObject(sheet2, hz, xmlObjectDic);
                    ExcelWrite.WriteObjects(sheet2, ClazzDic2[0], hz.DKs);


                    for (int a = 0; a < dks.Count; a++)
                    {
                        IRow row = sheet.GetRow(a + 5);
                    }

                    ExcelWrite.Save(workbook2, saveDir + "//TZ-" + hz.CBFBM.Substring(0, 14) + " " + cbfdz + "\\TZ4 -" + hz.CBFBM + "-2农村土地承包经营权(家庭承包)台帐(二).xls");
                }
                return(true);
            }
            return(false);
        }
Exemple #4
0
        /// <summary>
        /// 写入界址标示表word
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="jzxinfos"></param>
        /// <param name="configName"></param>
        public static void CreateBSB(XWPFDocument doc, IList <JZXInfo> jzxinfos)
        {
            //得到配置数据
            Dictionary <String, String> jzxConfigDic = ExcelRead.ReadExcelToDic(bsbReflect, 0);
            Dictionary <String, String> zlDic        = ExcelRead.ReadExcelToDic(jzxZLRelfect, 0);


            // Dictionary<String, Clazz> clazzMap = ReflectUtils.ConfigNameToClazzMapCache(configName);
            IList <String> errors = new List <String>();


            //每页显示的个数
            String pageRowStr;

            jzxConfigDic.TryGetValue("pageRow", out pageRowStr);
            int pageRow = int.Parse(pageRowStr);

            //从第几张表开始
            String tableIndexStr;

            jzxConfigDic.TryGetValue("tableIndex", out tableIndexStr);
            int tableIndex           = int.Parse(tableIndexStr);
            IList <XWPFTable> tables = doc.Tables;
            XWPFTable         table;

            //总共有几张标示表
            String bsTableTotalStr;

            jzxConfigDic.TryGetValue("tableTotal", out bsTableTotalStr);
            int bsTableTotal = int.Parse(bsTableTotalStr);
            //得到表格
            int jzxCount = jzxinfos.Count;

            String startRowStr;

            jzxConfigDic.TryGetValue("startRow", out startRowStr);

            int startRow = int.Parse(startRowStr);

            for (int a = 0; a < (jzxCount + 1) / pageRow + 1; a++)
            {
                if (a == bsTableTotal)
                {//到达最大的表格数就不再进行
                    MessageBox.Show("界址点个数超过了最大的个数了,宗地编码是" + jzxinfos[0].BZDH);
                    return;
                }
                table = tables[a + tableIndex];
                if (jzxCount < pageRow)
                {
                    JzxWriteBSB_Page(table, startRow, jzxinfos, 0, jzxCount, jzxConfigDic, zlDic);
                }
                else
                {
                    JzxWriteBSB_Page(table, startRow, jzxinfos, a * (pageRow - 1), (a + 1) * (pageRow - 1), jzxConfigDic, zlDic);
                }
            }
            //移除没有用的表格
            int index = jzxCount / pageRow + 1;

            for (int a = index; a < 3; a++)
            {
                doc.RemoveBodyElement(19 + ((index) * 3));
                doc.RemoveBodyElement(19 + ((index) * 3));
                doc.RemoveBodyElement(19 + ((index) * 3));
            }
        }
Exemple #5
0
 public static Dictionary <string, string> GetfileDic(string fileName)
 {
     LoadFile.fileDic = ExcelRead.ReadExcelToDic(fileName, 0);
     return(LoadFile.fileDic);
 }