public IList <JSYD> GetJSYDByZJDDataSourceViewModel(ZJDDataSourceViewModel model) { ObservableCollection <ZJDXZDM> zjdXZDM = ZJDXZDMCustom.GetExcelToZJDXZDM(model.ZJDXZDMTablePath); ObservableCollection <JTCY> hzs = JTCYCustom.GetExcelToHZS(model.JTCYTablePath); //户主必须要先检查 zjdDao.ChecSFZ(hzs, model); ObservableCollection <JSYD> jsyds = JSYDCustom.GetExcelToJSYDS(model.JSYDTablePath); IWorkbook workbook = ExcelRead.ReadExcel(model.NFTablePath); ObservableCollection <NF> nfs = NFCustom.GetExcelToNFS(workbook.GetSheetAt(0)); ObservableCollection <Floor> floors = FloorCustom.GetExcelToFloors(workbook.GetSheetAt(1)); ObservableCollection <Zdinfo> zdinfos = ZdinfoCustom.GetMDBToZdinfos(model.ZdinfoMDBPath); Dictionary <string, JSYD> jsydDic = MyUtils.Utils.GetGroupDic("ZDNUM", jsyds); JSYDCustom.SetZdinfo(jsydDic, zdinfos); ObservableCollection <JSYD> gyrs = JSYDCustom.GetExcelToGYRS(model.JSYDTablePath); JSYDCustom.SetHZs(jsyds, gyrs, hzs); JSYDCustom.SetNF(jsydDic, nfs); JSYDCustom.SetFloor(jsydDic, floors); JSYDCustom.SetZJDXZDM(jsydDic, zjdXZDM); ObservableCollection <QZB> qzbs = QZBCustom.GetMDBToQZB(model.QZ_BSMDBPath); JSYDCustom.SetQZBs(jsyds, qzbs); ObservableCollection <JZXInfo> jzxs = JZXInfoCustom.GetMDBToJZX(model.QZ_BSMDBPath); JSYDCustom.SetJZXs(jsyds, jzxs); return(jsyds); }
public Dictionary <int, Clazz> GetExcelTitleToClazzMap(string path, string mapFile, int titleIndex, string classForName) { IWorkbook workbook = ExcelRead.ReadExcel(path); ISheet sheetAt = workbook.GetSheetAt(0); return(this.GetExcelTitleToClazzMap(sheetAt, mapFile, titleIndex, classForName)); }
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"); }
public async Task <IActionResult> LocalizarCEP(IFormFile file) { //Start Bot ExcelRead.ReadExcel(file); return(Ok("Seu Arquivo será processado.")); }
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"); }
/// <summary> /// tidy switching value parameters /// </summary> private static void TidySwitchingValueParameters(string filePath, OutputInfo outputInfo) { _dt = ExcelRead.ReadExcel(filePath, "switching value"); if (_dt == null) { return; } TidySwitchingValueParameters(_dt, outputInfo); }
/// <summary> /// tidy analog quantity parameters /// </summary> private static void TidyAnalogQuantityParameters(string filePath, OutputInfo outputInfo) { _dt = ExcelRead.ReadExcel(filePath, "analog quantity"); if (_dt == null) { return; } TidyAnalogQuantityParameters(_dt, outputInfo); }
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)); }
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)); }
static void Main(string[] args) { // The code provided will print ‘Hello World’ to the console. // Press Ctrl+F5 (or go to Debug > Start Without Debugging) to run your app. String path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); List <String> arr = new List <string>(); arr = ExcelRead.ReadExcel(path + "\\Testdata.Xlsx", 1); foreach (String item in arr) { Console.WriteLine(item); } // Console.Read(); Console.WriteLine(System.IO.Directory.GetCurrentDirectory()); Console.ReadKey(); // Go to http://aka.ms/dotnet-get-started-console to continue learning how to build a console app! }
/// <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"); }
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; }
/// <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); }
internal static Dictionary <string, Jsyd> ExcelToJsyd(string path) { Dictionary <string, Jsyd> dictionary = new Dictionary <string, Jsyd>(); IWorkbook workbook = ExcelRead.ReadExcel(path); ISheet sheetAt = workbook.GetSheetAt(0); for (int i = 4; i <= sheetAt.LastRowNum; i++) { Jsyd jsyd = new Jsyd(); IRow row = sheetAt.GetRow(i); if (row != null) { for (int j = 0; j < 50; j++) { ICell cell = row.GetCell(j); if (cell != null && cell.CellType != CellType.Blank) { cell.SetCellType(CellType.String); string text = cell.StringCellValue.Trim(); int num = j; if (num != 1) { switch (num) { case 30: { double num2; if (double.TryParse(text, out num2)) { jsyd.Zdmj = num2; } break; } case 31: { double num2; if (double.TryParse(text, out num2)) { jsyd.Syqmj = num2; } break; } case 34: { double num2; if (double.TryParse(text, out num2)) { jsyd.Czmj = num2; } break; } } } else { jsyd.Zdnum = text; if (text.Length == 19) { dictionary.Add(text, jsyd); } } } } } } return(dictionary); }