年度变更建库软件5.0版本
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
2.0 KiB

4 months ago
using Aspose.Cells;
using KGIS.Framework.Platform;
using KGIS.Framework.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace kingo.Plugin.BGResultManager.Utility.Dic
{
public class ExportOwnerUnitCode
{
public string OutPath { get; set; }
public void Export(bool isBL=false)
{
if (string.IsNullOrWhiteSpace(OutPath))
return;
var sourcesfile = SysAppPath.GetCurrentAppPath() + @"工作空间\模板\字典模板\权属单位代码样式表.xlsx";
if (System.IO.File.Exists(sourcesfile))
{
#region 写入权属字典数据
Workbook workbook = new Workbook(sourcesfile);
workbook.CalculateFormula(true);
Worksheet sheet = workbook.Worksheets[0];
//获取权属字典
List<DataDicTionary> dicList = Platform.Instance.DicHelper.GetNoGroupDic2(DicTypeEnum.QSDM, null, true, isBL, '0');
if (dicList == null)
{ return;}
var pandinglist = dicList.Where(x => x.CODE.Length == 12).ToList();
for (var i = 0; i<pandinglist.Count(); i++)
{
pandinglist[i].CODE = pandinglist[i].CODE + "0000000";
}
WriteExcel(sheet, dicList);
workbook.Save(OutPath);
#endregion
}
}
private void WriteExcel(Worksheet sheet, List<DataDicTionary> dicList)
{
if (dicList == null)
return;
for (int i = 0; i < dicList.Count; i++)
{
Cell cell = sheet.Cells[i + 2, 0];
cell.PutValue(dicList[i].CODE);
cell = sheet.Cells[i + 2, 1];
cell.PutValue(dicList[i].NAME);
if (dicList[i].SubDic != null)
WriteExcel(sheet, dicList[i].SubDic);
}
}
}
}