【修复】修复string和enum类型default值处理的bug

【修复】修复失误删除csv编码检测相关代码,导致加载非本地ansi编码的csv出错的bug
main
walon 2021-10-14 11:00:43 +08:00
parent 042c525f2e
commit 4308db1a83
7 changed files with 27 additions and 6 deletions

View File

@ -99,7 +99,7 @@ luban相较于常规的excel导表工具有以下核心优势
- 其他所有支持js的引擎和平台
- 扩展工具
- Excel2TextDiff。将excel转成文本后再diff清晰对比excel版本之间内容变化。
- **[开发中,马上...]LubanAssistant**Luban的Excel插件。支持把json、lua、xml等文本格式的配置数据加载到excel中批量编辑处理最后再保存回原文件较好地解决大型项目中多人合作数据编辑冲突合并的问题较好解决在编辑器中制作的配置难以在excel中批量修改的问题。
- **LubanAssistant**Luban的Excel插件。支持把json、lua、xml等文本格式的配置数据加载到excel中批量编辑处理最后再保存回原文件较好地解决大型项目中多人合作数据编辑冲突合并的问题较好解决在编辑器中制作的配置难以在excel中批量修改的问题。
## 增强的excel格式

View File

@ -333,7 +333,7 @@ namespace Luban.Job.Cfg.DataCreators
{
return null;
}
if (CheckIsDefault(type.IsNullable, d) && field?.DefalutDtypeValue != null)
if (CheckIsDefault(x.NamedMode, d) && field?.DefalutDtypeValue != null)
{
return field?.DefalutDtypeValue;
}
@ -346,7 +346,12 @@ namespace Luban.Job.Cfg.DataCreators
{
throw new InvalidExcelDataException("excel string类型在标题头对应模式下必须正好占据一个单元格");
}
var s = ParseString(x.Read(x.NamedMode));
var d = x.Read(x.NamedMode);
if (CheckIsDefault(x.NamedMode, d) && field?.DefalutDtypeValue != null)
{
return field.DefalutDtypeValue;
}
var s = ParseString(d);
if (s == null)
{
if (type.IsNullable)

View File

@ -151,7 +151,7 @@ namespace Luban.Job.Cfg.DataCreators
}
else
{
list.Add(f.CType.Apply(ExcelDataCreator.Ins, null, row.GetMultiRowStream(f.Name, sep, f.IsRowOrient), (DefAssembly)bean.AssemblyBase));
list.Add(f.CType.Apply(ExcelDataCreator.Ins, f, row.GetMultiRowStream(f.Name, sep, f.IsRowOrient), (DefAssembly)bean.AssemblyBase));
}
}
catch (DataCreateException dce)

View File

@ -17,9 +17,21 @@ namespace Luban.Job.Cfg.DataSources.Excel
private System.Text.Encoding DetectCsvEncoding(Stream fs)
{
Ude.CharsetDetector cdet = new Ude.CharsetDetector();
cdet.Feed(fs);
cdet.DataEnd();
fs.Seek(0, SeekOrigin.Begin);
if (cdet.Charset != null)
{
s_logger.Debug("Charset: {}, confidence: {}", cdet.Charset, cdet.Confidence);
return System.Text.Encoding.GetEncoding(cdet.Charset) ?? System.Text.Encoding.Default;
}
else
{
return System.Text.Encoding.Default;
}
}
public override void Load(string rawUrl, string sheetName, Stream stream)
{

View File

@ -12,7 +12,7 @@
<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.8.0" />
<PackageReference Include="Scriban" Version="4.0.1" />
<PackageReference Include="Scriban" Version="4.1.0" />
</ItemGroup>
<ItemGroup>

View File

@ -158,6 +158,9 @@
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="Ude.NetStandard, Version=1.0.2.0, Culture=neutral, PublicKeyToken=103cb45fc06c90e4, processorArchitecture=MSIL">
<HintPath>..\packages\Ude.NetStandard.1.2.0\lib\net45\Ude.NetStandard.dll</HintPath>
</Reference>
<Reference Include="YamlDotNet, Version=11.0.0.0, Culture=neutral, PublicKeyToken=ec19458f3c15af5e, processorArchitecture=MSIL">
<HintPath>..\packages\YamlDotNet.11.2.1\lib\net45\YamlDotNet.dll</HintPath>
</Reference>

View File

@ -13,5 +13,6 @@
<package id="System.Text.Json" version="5.0.2" targetFramework="net472" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net472" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net472" />
<package id="Ude.NetStandard" version="1.2.0" targetFramework="net472" />
<package id="YamlDotNet" version="11.2.1" targetFramework="net472" />
</packages>