diff --git a/src/Luban.Job.Cfg/Source/DataSources/Excel/Title.cs b/src/Luban.Job.Cfg/Source/DataSources/Excel/Title.cs
index dc498b3..a220a4e 100644
--- a/src/Luban.Job.Cfg/Source/DataSources/Excel/Title.cs
+++ b/src/Luban.Job.Cfg/Source/DataSources/Excel/Title.cs
@@ -25,6 +25,11 @@ namespace Luban.Job.Cfg.DataSources.Excel
public string Sep { get; private set; }
+ public string SepOr(string sep)
+ {
+ return string.IsNullOrEmpty(Sep) ? sep : Sep;
+ }
+
public string Default { get; private set; }
public bool SelfMultiRows { get; private set; }
diff --git a/src/LubanAssistant/ExcelUtil.cs b/src/LubanAssistant/ExcelUtil.cs
index c8d2c03..06701b8 100644
--- a/src/LubanAssistant/ExcelUtil.cs
+++ b/src/LubanAssistant/ExcelUtil.cs
@@ -140,7 +140,8 @@ namespace LubanAssistant
int usedRowNum = sheet.UsedRange.Rows.Count;
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();
}
@@ -149,7 +150,6 @@ namespace LubanAssistant
foreach (var rec in tableDataInfo.MainRecords)
{
var fillVisitor = new FillSheetVisitor(sheet, nextRowIndex);
- //FillRecord(sheet, ref nextRowIndex, title.RootTitle, rec);
nextRowIndex += rec.Data.Apply(fillVisitor, title);
}
}
diff --git a/src/LubanAssistant/FillSheetVisitor.cs b/src/LubanAssistant/FillSheetVisitor.cs
index f2b0f62..1bcd7e5 100644
--- a/src/LubanAssistant/FillSheetVisitor.cs
+++ b/src/LubanAssistant/FillSheetVisitor.cs
@@ -17,7 +17,7 @@ namespace LubanAssistant
private readonly Range _cells;
- private readonly int _startRowIndex;
+ private int _startRowIndex;
public FillSheetVisitor(Worksheet sheet, int startRowIndex)
{
@@ -118,6 +118,7 @@ namespace LubanAssistant
public int Accept(DBean type, Title x)
{
+
if (x.SubTitleList.Count > 0)
{
if (type.Type.IsAbstractType)
@@ -147,6 +148,7 @@ namespace LubanAssistant
throw new Exception($"title:{x.Name} 不支持 值为null的普通bean");
}
}
+ int rowCount = 1;
if (type.ImplType != null)
{
int index = 0;
@@ -162,7 +164,7 @@ namespace LubanAssistant
{
//if (fieldTitle.SubTitleList.Count > 0)
//{
- data.Apply(this, fieldTitle);
+ rowCount = Math.Max(rowCount, data.Apply(this, fieldTitle));
//}
//else
//{
@@ -172,24 +174,67 @@ namespace LubanAssistant
}
}
}
+ return rowCount;
}
else
{
Current(x).Value = type.Apply(ToExcelStringVisitor.Ins, x.Sep);
+ return 1;
}
- return 1;
}
public int Accept(DArray type, Title x)
{
- Current(x).Value = type.Apply(ToExcelStringVisitor.Ins, x.Sep);
- return 1;
+ 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);
+ return 1;
+ }
}
public int Accept(DList type, Title x)
{
- Current(x).Value = type.Apply(ToExcelStringVisitor.Ins, x.Sep);
- return 1;
+ 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);
+ return 1;
+ }
}
public int Accept(DSet type, Title x)
diff --git a/src/LubanAssistant/LoadUtil.cs b/src/LubanAssistant/LoadUtil.cs
deleted file mode 100644
index de82754..0000000
--- a/src/LubanAssistant/LoadUtil.cs
+++ /dev/null
@@ -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
- {
-
- }
-}
diff --git a/src/LubanAssistant/LubanAssistant.csproj b/src/LubanAssistant/LubanAssistant.csproj
index 87b94f1..a56cff4 100644
--- a/src/LubanAssistant/LubanAssistant.csproj
+++ b/src/LubanAssistant/LubanAssistant.csproj
@@ -594,7 +594,6 @@
-
Code
diff --git a/src/LubanAssistant/ToExcelStringVisitor.cs b/src/LubanAssistant/ToExcelStringVisitor.cs
index 59666e6..b0df041 100644
--- a/src/LubanAssistant/ToExcelStringVisitor.cs
+++ b/src/LubanAssistant/ToExcelStringVisitor.cs
@@ -2,6 +2,7 @@
using Luban.Job.Cfg.DataSources.Excel;
using Luban.Job.Cfg.DataVisitors;
using Luban.Job.Cfg.Defs;
+using Luban.Job.Cfg.TypeVisitors;
using Luban.Job.Cfg.Utils;
using System;
using System.Collections.Generic;
@@ -124,16 +125,28 @@ namespace LubanAssistant
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)));
}
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)));
}
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)));
}