Example #1
0
File: JTCY.cs Project: YB9527/CG
        public static void ExportJTCYTable(IList <JTCY> hzs, string saveDirPath)
        {
            Dictionary <int, XMLTable> xmlJtcyDkDic = XMLRead.GetXmlToXMLTabl("Model/JTCY.Excel.hbm.xml");
            XMLTable    xmlTable = xmlJtcyDkDic[0];
            IWorkbook   workbook = ExcelRead.ReadExcel("ChengDuGaoXingZaiJiDiModel/家庭成员表模板.xls");
            ISheet      sheet    = workbook.GetSheetAt(0);
            List <JTCY> jtcys    = new List <JTCY>();

            foreach (JTCY hz in hzs)
            {
                jtcys.AddRange(hz.JTCies);
            }
            ExcelWrite.WriteObjects(sheet, xmlTable, jtcys);
            //合并户主的单元格
            int rowIndex = xmlTable.RowStartIndex;

            foreach (JTCY hz in hzs)
            {
                ExcelWrite.SetValue(sheet.GetRow(rowIndex), 0, rowIndex - 4 + "");
                ExcelWrite.SetValue(sheet.GetRow(rowIndex), 1, hz.XM);
                int lastRow = rowIndex + hz.JTCies.Count;
                sheet.AddMergedRegion(new CellRangeAddress(rowIndex, lastRow - 1, 0, 0));
                sheet.AddMergedRegion(new CellRangeAddress(rowIndex, lastRow - 1, 1, 1));
                rowIndex = lastRow;
            }

            ExcelWrite.Save(workbook, saveDirPath + "\\家庭成员表.xls");
        }
Example #2
0
        public static IList <T> GetExcelToObject <T>(ISheet sheet, string XMLPath)
        {
            XMLTable xmlTable = XMLRead.GetXmlToXMLTabl(XMLPath)[0];
            ExcelReflectModel <T> reflectModel = new ExcelReflectModel <T>(sheet, xmlTable);
            IList <T>             list         = ExcelUtils.SheetToObjectsByXMLTable <T>(reflectModel);

            return(list);
        }
Example #3
0
        public static IList <JTTDSYQZ> GetJTTDSYQZS(string excelPath)
        {
            XMLTable xmlTable = XMLRead.GetXmlToXMLTabl(ExcelRelect)[0];
            ExcelReflectModel <JTTDSYQZ> model = new ExcelReflectModel <JTTDSYQZ>(excelPath, xmlTable);
            IList <JTTDSYQZ>             list  = ExcelUtils.SheetToObjectsByXMLTable <JTTDSYQZ>(model);

            return(list);
        }
Example #4
0
        public static void ExportJSYDTable(IList <JSYD> jsyds, string saveDirPath)
        {
            string jsydExcelPath = "ChengDuGaoXingZaiJiDiModel/建设用地表共用宗模板.xls";
            Dictionary <int, XMLTable> xmlJtcyDkDic = XMLRead.GetXmlToXMLTabl("Model/JSYD.Excel.hbm.xml");
            IWorkbook workbook = ExcelRead.ReadExcel(jsydExcelPath);
            ISheet    sheet    = workbook.GetSheetAt(0);

            ExcelWrite.WriteObjects <JSYD>(sheet, xmlJtcyDkDic[0], jsyds);
            ExcelWrite.Save(workbook, saveDirPath + "\\建设用地表.xls");
        }
Example #5
0
        public void ExportCun_GongShi(IList <JTSYQ> jtsyqs, XZDM xzdm, string dir)
        {
            Dictionary <int, XMLTable> ClazzDic = XMLRead.GetXmlToXMLTabl(JTSYQCustom.Cun_GongGao_Reflect);
            XMLTable  xmlTable = ClazzDic[1];
            IWorkbook workbook = ExcelRead.ReadExcel(JTSYQCustom.Cun_GongShi);
            ISheet    sheet    = workbook.GetSheetAt(0);
            //文字替换
            Dictionary <string, XMLObject> xmlobjectDic = XMLRead.XmlToObjects(JTSYQCustom.FanKuiYiJianShuXMLRelfect, false);

            xzdm.JTSYQ_DasTatal = (xzdm.JTSYQ_GSEndTime - xzdm.JTSYQ_GSStartTime).Days;
            ExcelWrite.ReplaceTextByXMLObject(sheet, xzdm, xmlobjectDic);

            //行数据插入
            ExcelWrite.WriteObjects(sheet, xmlTable, jtsyqs);

            ExcelWrite.Save(workbook, dir + "//" + System.IO.Path.GetFileName(JTSYQCustom.Cun_GongShi));
        }
Example #6
0
        public void ExportCun_JiTiTuDiDiaoChaBiao(IList <JTSYQ> jtsyqs, string saveDir)
        {
            Dictionary <int, XMLTable> ClazzDic = XMLRead.GetXmlToXMLTabl(JTSYQCustom.JiTiTuDiDiaoChaBiao_Reflect);

            foreach (JTSYQ jtsyq in jtsyqs)
            {
                jtsyq.XZDM = XZDMCustom.GetXzdm(XZDMCustom.JTSYQBianMaToXZDM(jtsyq.BM));
                // JTSYQCustom.SetContainsFeatureArea(jtsyq);
            }

            XMLTable  xmlTable = ClazzDic[1];
            IWorkbook workbook = ExcelRead.ReadExcel(JTSYQCustom.JiTiTuDiDiaoChaBiao);
            ISheet    sheet    = workbook.GetSheetAt(0);

            //行数据插入
            ExcelWrite.WriteObjects(sheet, xmlTable, jtsyqs);
            ExcelWrite.Save(workbook, saveDir + "//" + System.IO.Path.GetFileName(JTSYQCustom.JiTiTuDiDiaoChaBiao));
        }
Example #7
0
        /// <summary>
        /// 导出农房表
        /// </summary>
        /// <param name="nfs"></param>
        /// <param name="saveDirPath"></param>
        public static void ExportNFTable(IList <NF> nfs, string saveDirPath)
        {
            List <NF>    allNF    = new List <NF>();
            List <Floor> allFloor = new List <Floor>();

            foreach (NF nf in nfs)
            {
                //allNF.AddRange(nf.NFS);
                //allFloor.AddRange(nf.Floors);
            }
            Dictionary <int, XMLTable> xmlJtcyDkDic = XMLRead.GetXmlToXMLTabl("Model/NF.Excel.hbm.xml");
            XMLTable  xmlTable = xmlJtcyDkDic[0];
            IWorkbook workbook = ExcelRead.ReadExcel("ChengDuGaoXingZaiJiDiModel/农房表模板.xls");
            ISheet    sheet    = workbook.GetSheetAt(0);

            ExcelWrite.WriteObjects(sheet, xmlTable, allNF);
            //导出分层表
            ExcelWrite.WriteObjects(workbook.GetSheetAt(1), XMLRead.GetXmlToXMLTabl("Model/Floor.Excel.hbm.xml")[0], allFloor);

            ExcelWrite.Save(workbook, saveDirPath + "\\农房表.xls");
        }
Example #8
0
        public void  ExportZu_ZhongDiBiao(JTSYQ jtsyqGroup, string saveDir)
        {
            //   JTSYQCustom.SetContainsFeatureArea(jtsyqGroup);

            Dictionary <int, XMLTable> ClazzDic = XMLRead.GetXmlToXMLTabl(JTSYQCustom.DangZhongDi_Reflect);


            XMLTable  xmlTable = ClazzDic[1];
            IWorkbook workbook = ExcelRead.ReadExcel(JTSYQCustom.DangZhongDi);
            ISheet    sheet    = workbook.GetSheetAt(0);

            //行数据插入
            IList <JTSYQ> list = new List <JTSYQ>();

            list.Add(jtsyqGroup);
            double area = jtsyqGroup.Area;

            jtsyqGroup.Area = jtsyqGroup.Area * 10000;
            ExcelWrite.WriteObjects(sheet, xmlTable, list);
            ExcelWrite.Save(workbook, saveDir + "//" + jtsyqGroup.BM + ".xls");
            jtsyqGroup.Area = area;
        }
Example #9
0
        public static XMLTable GetWriteExcelXMLTable()
        {
            XMLTable xmlTable = XMLRead.GetXmlToXMLTabl(ExcelWriteXMLPath)[0];

            return(xmlTable);
        }
Example #10
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);
        }
Example #11
0
File: ZJDDao.cs Project: YB9527/CG
        public void ExportZJD_CHBG(JSYD jsyd, string saveDir)
        {
            string       docTempletePath = JSYDCustom.CHBGDocPath;
            XWPFDocument doc             = WordRead.Read(docTempletePath);

            Dictionary <string, XMLObject> xzdmXML = XMLRead.XmlToObjects(JSYDCustom.ZJDXZDMMLPath);

            WordWrite.ReplaceText(doc, xzdmXML, jsyd.ZJDXZDM);

            Dictionary <string, XMLObject> jsydXML = XMLRead.XmlToObjects(JSYDCustom.JSYDXMLPath);

            WordWrite.ReplaceText(doc, jsydXML, jsyd);

            Dictionary <string, XMLObject> jtcyXML = XMLRead.XmlToObjects(JSYDCustom.JTCYXMLPath);

            WordWrite.ReplaceText(doc, jtcyXML, jsyd.HZs[0]);

            Dictionary <string, XMLObject> nfXML = XMLRead.XmlToObjects(JSYDCustom.NFXMLPath);

            WordWrite.ReplaceText(doc, nfXML, jsyd.NFs[0]);

            Dictionary <string, string> replaceDic = new Dictionary <string, string>();

            replaceDic.Add("Company", "四川旭普信息产业发展有限公司");
            string zdnum = jsyd.ZDNUM;

            replaceDic.Add("Qjbh", zdnum.Substring(6, 3) + "-" + zdnum.Substring(9, 3) + "-" + zdnum.Substring(12, 2) + "-" + zdnum.Substring(14, 5));
            foreach (NF nf in jsyd.NFs)
            {
                if (replaceDic.ContainsKey("JZJG"))
                {
                    replaceDic["JZJG"] = replaceDic["JZJG"] + "、" + nf.JG;
                }
                else
                {
                    replaceDic.Add("JZJG", nf.JG);
                }
            }
            StringBuilder sb = new StringBuilder();

            foreach (Floor f in jsyd.Floors)
            {
                sb.Append("S" + f.SZC + " = " + f.CJZMJ + "  平方米    ");
            }
            replaceDic.Add("FCMJ", sb.ToString());

            XMLTable  xmlTable = XMLRead.GetXmlToXMLTabl(JSYDCustom.FloorXMLPath)[0];
            XWPFTable table    = WordWrite.ReplaceTable_Font <Floor>(doc, xmlTable, jsyd.Floors);
            int       rowX     = xmlTable.RowStartIndex + jsyd.Floors.Count;

            while (table.Rows.Count - rowX > 1)
            {
                table.RemoveRow(rowX);
            }


            WordWrite.ReplaceText(doc, replaceDic);
            string saveName = GetZJDSaveFileName(jsyd, saveDir, docTempletePath);

            WordWrite.SaveToFile(doc, saveName);
        }