【特性】LubanAssistant支持多行列表。以及修复对list,int之类简单原生数据未加sep=,的问题
parent
ac01206f78
commit
6c50e66915
|
|
@ -25,6 +25,11 @@ namespace Luban.Job.Cfg.DataSources.Excel
|
||||||
|
|
||||||
public string Sep { get; private set; }
|
public string Sep { get; private set; }
|
||||||
|
|
||||||
|
public string SepOr(string sep)
|
||||||
|
{
|
||||||
|
return string.IsNullOrEmpty(Sep) ? sep : Sep;
|
||||||
|
}
|
||||||
|
|
||||||
public string Default { get; private set; }
|
public string Default { get; private set; }
|
||||||
|
|
||||||
public bool SelfMultiRows { get; private set; }
|
public bool SelfMultiRows { get; private set; }
|
||||||
|
|
|
||||||
|
|
@ -140,7 +140,8 @@ namespace LubanAssistant
|
||||||
int usedRowNum = sheet.UsedRange.Rows.Count;
|
int usedRowNum = sheet.UsedRange.Rows.Count;
|
||||||
if (usedRowNum > titleRowNum + 1)
|
if (usedRowNum > titleRowNum + 1)
|
||||||
{
|
{
|
||||||
Range allDataRange = sheet.Range[$"A{titleRowNum + 2},A{usedRowNum}"].EntireRow;
|
//Range allDataRange = sheet.Range[sheet.Cells[titleRowNum + 1, 1], sheet.Cells[$"A{titleRowNum + 2},A{usedRowNum}"].EntireRow;
|
||||||
|
Range allDataRange = sheet.Range[sheet.Cells[titleRowNum + 2, 1], sheet.Cells[usedRowNum, sheet.UsedRange.Columns.Count]];
|
||||||
allDataRange.ClearContents();
|
allDataRange.ClearContents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -149,7 +150,6 @@ namespace LubanAssistant
|
||||||
foreach (var rec in tableDataInfo.MainRecords)
|
foreach (var rec in tableDataInfo.MainRecords)
|
||||||
{
|
{
|
||||||
var fillVisitor = new FillSheetVisitor(sheet, nextRowIndex);
|
var fillVisitor = new FillSheetVisitor(sheet, nextRowIndex);
|
||||||
//FillRecord(sheet, ref nextRowIndex, title.RootTitle, rec);
|
|
||||||
nextRowIndex += rec.Data.Apply(fillVisitor, title);
|
nextRowIndex += rec.Data.Apply(fillVisitor, title);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ namespace LubanAssistant
|
||||||
|
|
||||||
private readonly Range _cells;
|
private readonly Range _cells;
|
||||||
|
|
||||||
private readonly int _startRowIndex;
|
private int _startRowIndex;
|
||||||
|
|
||||||
public FillSheetVisitor(Worksheet sheet, int startRowIndex)
|
public FillSheetVisitor(Worksheet sheet, int startRowIndex)
|
||||||
{
|
{
|
||||||
|
|
@ -118,6 +118,7 @@ namespace LubanAssistant
|
||||||
|
|
||||||
public int Accept(DBean type, Title x)
|
public int Accept(DBean type, Title x)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (x.SubTitleList.Count > 0)
|
if (x.SubTitleList.Count > 0)
|
||||||
{
|
{
|
||||||
if (type.Type.IsAbstractType)
|
if (type.Type.IsAbstractType)
|
||||||
|
|
@ -147,6 +148,7 @@ namespace LubanAssistant
|
||||||
throw new Exception($"title:{x.Name} 不支持 值为null的普通bean");
|
throw new Exception($"title:{x.Name} 不支持 值为null的普通bean");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
int rowCount = 1;
|
||||||
if (type.ImplType != null)
|
if (type.ImplType != null)
|
||||||
{
|
{
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
@ -162,7 +164,7 @@ namespace LubanAssistant
|
||||||
{
|
{
|
||||||
//if (fieldTitle.SubTitleList.Count > 0)
|
//if (fieldTitle.SubTitleList.Count > 0)
|
||||||
//{
|
//{
|
||||||
data.Apply(this, fieldTitle);
|
rowCount = Math.Max(rowCount, data.Apply(this, fieldTitle));
|
||||||
//}
|
//}
|
||||||
//else
|
//else
|
||||||
//{
|
//{
|
||||||
|
|
@ -172,25 +174,68 @@ namespace LubanAssistant
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return rowCount;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Current(x).Value = type.Apply(ToExcelStringVisitor.Ins, x.Sep);
|
Current(x).Value = type.Apply(ToExcelStringVisitor.Ins, x.Sep);
|
||||||
}
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public int Accept(DArray type, Title x)
|
public int Accept(DArray type, Title x)
|
||||||
|
{
|
||||||
|
if (x.SelfMultiRows)
|
||||||
|
{
|
||||||
|
int oldStartRow = _startRowIndex;
|
||||||
|
int totalRow = 0;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
foreach (var ele in type.Datas)
|
||||||
|
{
|
||||||
|
totalRow += ele.Apply(this, x);
|
||||||
|
_startRowIndex = oldStartRow + totalRow;
|
||||||
|
}
|
||||||
|
return totalRow;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_startRowIndex = oldStartRow;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
Current(x).Value = type.Apply(ToExcelStringVisitor.Ins, x.Sep);
|
Current(x).Value = type.Apply(ToExcelStringVisitor.Ins, x.Sep);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public int Accept(DList type, Title x)
|
public int Accept(DList type, Title x)
|
||||||
|
{
|
||||||
|
if (x.SelfMultiRows)
|
||||||
|
{
|
||||||
|
int oldStartRow = _startRowIndex;
|
||||||
|
int totalRow = 0;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
foreach (var ele in type.Datas)
|
||||||
|
{
|
||||||
|
totalRow += ele.Apply(this, x);
|
||||||
|
_startRowIndex = oldStartRow + totalRow;
|
||||||
|
}
|
||||||
|
return totalRow;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_startRowIndex = oldStartRow;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
Current(x).Value = type.Apply(ToExcelStringVisitor.Ins, x.Sep);
|
Current(x).Value = type.Apply(ToExcelStringVisitor.Ins, x.Sep);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public int Accept(DSet type, Title x)
|
public int Accept(DSet type, Title x)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
using Bright.Common;
|
|
||||||
using Bright.Time;
|
|
||||||
using Luban.Job.Cfg.Defs;
|
|
||||||
using Luban.Job.Cfg.Utils;
|
|
||||||
using Luban.Job.Common.Defs;
|
|
||||||
using Luban.Server.Common;
|
|
||||||
using Microsoft.Office.Interop.Excel;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace LubanAssistant
|
|
||||||
{
|
|
||||||
static class LoadUtil
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -594,7 +594,6 @@
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="ExcelUtil.cs" />
|
<Compile Include="ExcelUtil.cs" />
|
||||||
<Compile Include="FillSheetVisitor.cs" />
|
<Compile Include="FillSheetVisitor.cs" />
|
||||||
<Compile Include="LoadUtil.cs" />
|
|
||||||
<Compile Include="Properties\AssemblyInfo.cs">
|
<Compile Include="Properties\AssemblyInfo.cs">
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
using Luban.Job.Cfg.DataSources.Excel;
|
using Luban.Job.Cfg.DataSources.Excel;
|
||||||
using Luban.Job.Cfg.DataVisitors;
|
using Luban.Job.Cfg.DataVisitors;
|
||||||
using Luban.Job.Cfg.Defs;
|
using Luban.Job.Cfg.Defs;
|
||||||
|
using Luban.Job.Cfg.TypeVisitors;
|
||||||
using Luban.Job.Cfg.Utils;
|
using Luban.Job.Cfg.Utils;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
@ -124,16 +125,28 @@ namespace LubanAssistant
|
||||||
|
|
||||||
public string Accept(DArray type, string sep)
|
public string Accept(DArray type, string sep)
|
||||||
{
|
{
|
||||||
|
if (string.IsNullOrEmpty(sep) && type.Type.ElementType.Apply(IsNotSepTypeVisitor.Ins))
|
||||||
|
{
|
||||||
|
sep = ",";
|
||||||
|
}
|
||||||
return string.Join(sep, type.Datas.Select(d => d.Apply(this, sep)));
|
return string.Join(sep, type.Datas.Select(d => d.Apply(this, sep)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Accept(DList type, string sep)
|
public string Accept(DList type, string sep)
|
||||||
{
|
{
|
||||||
|
if (string.IsNullOrEmpty(sep) && type.Type.ElementType.Apply(IsNotSepTypeVisitor.Ins))
|
||||||
|
{
|
||||||
|
sep = ",";
|
||||||
|
}
|
||||||
return string.Join(sep, type.Datas.Select(d => d.Apply(this, sep)));
|
return string.Join(sep, type.Datas.Select(d => d.Apply(this, sep)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Accept(DSet type, string sep)
|
public string Accept(DSet type, string sep)
|
||||||
{
|
{
|
||||||
|
if (string.IsNullOrEmpty(sep) && type.Type.ElementType.Apply(IsNotSepTypeVisitor.Ins))
|
||||||
|
{
|
||||||
|
sep = ",";
|
||||||
|
}
|
||||||
return string.Join(sep, type.Datas.Select(d => d.Apply(this, sep)));
|
return string.Join(sep, type.Datas.Select(d => d.Apply(this, sep)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue