【调整】将Excel2TextDiff拆成独立项目
parent
c8cd68af61
commit
e54870fb02
|
|
@ -23,7 +23,7 @@
|
||||||
luban相较于常规的excel导表工具有以下核心优势:
|
luban相较于常规的excel导表工具有以下核心优势:
|
||||||
- 增强了excel格式。可以比较简洁地excel配置**任意复杂**的数据,像子结构、结构列表,以及更复杂的深层次的嵌套结构都能直接解析处理。
|
- 增强了excel格式。可以比较简洁地excel配置**任意复杂**的数据,像子结构、结构列表,以及更复杂的深层次的嵌套结构都能直接解析处理。
|
||||||
- 完备的类型系统和多原始数据支持(xml、json、lua、yaml),可以轻松表达和解析**任意复杂**的数据。意味着传统excel导表工具无法处理的技能、行为树、副本等等复杂配置,luban也能够统一处理了,彻底将程序从复杂的配置解析中解放出来。
|
- 完备的类型系统和多原始数据支持(xml、json、lua、yaml),可以轻松表达和解析**任意复杂**的数据。意味着传统excel导表工具无法处理的技能、行为树、副本等等复杂配置,luban也能够统一处理了,彻底将程序从复杂的配置解析中解放出来。
|
||||||
- 完善的工作流支持。如id的外键引用检查;资源合法性检查;灵活的数据源定义(拆表或者多表合一);灵活的分组导出机制;多种本地化支持;生成极快(日常迭代300ms以内);Excel2TextDiff工具方便diff查看excel文件的版本间差异;
|
- 完善的工作流支持。如id的外键引用检查;资源合法性检查;灵活的数据源定义(拆表或者多表合一);灵活的分组导出机制;多种本地化支持;生成极快(日常迭代300ms以内);[Excel2TextDiff](https://github.com/focus-creative-games/Excel2TextDiff)工具方便diff查看excel文件的版本间差异;
|
||||||
- **LubanAssistant Excel插件**。支持把json、lua、xml等文本格式的配置数据加载到excel中,批量编辑处理,最后再保存回原文件,较好地解决大型项目中多人合作数据编辑冲突合并的问题,较好解决在编辑器中制作的配置难以在excel中批量修改的问题。
|
- **LubanAssistant Excel插件**。支持把json、lua、xml等文本格式的配置数据加载到excel中,批量编辑处理,最后再保存回原文件,较好地解决大型项目中多人合作数据编辑冲突合并的问题,较好解决在编辑器中制作的配置难以在excel中批量修改的问题。
|
||||||
- 支持自定义代码与数据模板。强大的数据表达能力使得绝大多数项目的配置格式往往是luban的子集,因而有较低的项目迁移成本,利用模板重新适配代码和数据生成后,即使是研发已久或者上线项目也能从luban强大的数据处理能力中受益。
|
- 支持自定义代码与数据模板。强大的数据表达能力使得绝大多数项目的配置格式往往是luban的子集,因而有较低的项目迁移成本,利用模板重新适配代码和数据生成后,即使是研发已久或者上线项目也能从luban强大的数据处理能力中受益。
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<OutputType>Exe</OutputType>
|
|
||||||
<TargetFramework>net5.0</TargetFramework>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="CommandLineParser" Version="2.8.0" />
|
|
||||||
<PackageReference Include="ExcelDataReader" Version="3.6.0" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
||||||
|
|
@ -1,49 +0,0 @@
|
||||||
using ExcelDataReader;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
|
|
||||||
namespace Excel2TextDiff
|
|
||||||
{
|
|
||||||
class Excel2TextWriter
|
|
||||||
{
|
|
||||||
public void TransformToTextAndSave(string excelFile, string outputTextFile)
|
|
||||||
{
|
|
||||||
var lines = new List<string>();
|
|
||||||
using var excelFileStream = new FileStream(excelFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
|
||||||
string ext = Path.GetExtension(excelFile);
|
|
||||||
using (var reader = ext != ".csv" ? ExcelReaderFactory.CreateReader(excelFileStream) : ExcelReaderFactory.CreateCsvReader(excelFileStream))
|
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
|
||||||
lines.Add($"===[{reader.Name ?? ""}]===");
|
|
||||||
LoadRows(reader, lines);
|
|
||||||
} while (reader.NextResult());
|
|
||||||
}
|
|
||||||
File.WriteAllLines(outputTextFile, lines, System.Text.Encoding.UTF8);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LoadRows(IExcelDataReader reader, List<string> lines)
|
|
||||||
{
|
|
||||||
var row = new List<string>();
|
|
||||||
while (reader.Read())
|
|
||||||
{
|
|
||||||
row.Clear();
|
|
||||||
for (int i = 0, n = reader.FieldCount; i < n; i++)
|
|
||||||
{
|
|
||||||
object cell = reader.GetValue(i);
|
|
||||||
row.Add(cell != null ? cell.ToString() : "");
|
|
||||||
}
|
|
||||||
// 只保留到最后一个非空白单元格
|
|
||||||
int lastNotEmptyIndex = row.FindLastIndex(s => !string.IsNullOrEmpty(s));
|
|
||||||
if (lastNotEmptyIndex >= 0)
|
|
||||||
{
|
|
||||||
lines.Add(string.Join(',', row.GetRange(0, lastNotEmptyIndex + 1)));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// 忽略空白行,没必要diff这个
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,96 +0,0 @@
|
||||||
using CommandLine;
|
|
||||||
using CommandLine.Text;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
|
||||||
|
|
||||||
namespace Excel2TextDiff
|
|
||||||
{
|
|
||||||
class CommandLineOptions
|
|
||||||
{
|
|
||||||
[Option('t', SetName = "transform", HelpText = "transform excel to text file")]
|
|
||||||
public bool IsTransform { get; set; }
|
|
||||||
|
|
||||||
[Option('d', SetName = "diff", HelpText = "transform and diff file")]
|
|
||||||
public bool IsDiff { get; set; }
|
|
||||||
|
|
||||||
[Option('p', SetName = "diff", Required = false, HelpText = "3rd diff program. default TortoiseMerge")]
|
|
||||||
public string DiffProgram { get; set; }
|
|
||||||
|
|
||||||
[Option('f', SetName = "diff", Required = false, HelpText = "3rd diff program argument format. default is TortoiseMerge format:'/base:{0} /mine:{1}'")]
|
|
||||||
public string DiffProgramArgumentFormat { get; set; }
|
|
||||||
|
|
||||||
[Value(0)]
|
|
||||||
public IList<string> Files { get; set; }
|
|
||||||
|
|
||||||
[Usage()]
|
|
||||||
public static IEnumerable<Example> Examples => new List<Example>
|
|
||||||
{
|
|
||||||
new Example("tranfrom to text", new CommandLineOptions { IsTransform = true, Files = new List<string>{"a.xlsx", "a.txt" } }),
|
|
||||||
new Example("diff two excel file", new CommandLineOptions{ IsDiff = true, Files = new List<string>{"a.xlsx", "b.xlsx"}}),
|
|
||||||
new Example("diff two excel file with TortoiseMerge", new CommandLineOptions{ IsDiff = true, DiffProgram = "TortoiseMerge",DiffProgramArgumentFormat = "/base:{0} /mine:{1}", Files = new List<string>{"a.xlsx", "b.xlsx"}}),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
class Program
|
|
||||||
{
|
|
||||||
static void Main(string[] args)
|
|
||||||
{
|
|
||||||
var options = ParseOptions(args);
|
|
||||||
|
|
||||||
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
|
|
||||||
var writer = new Excel2TextWriter();
|
|
||||||
|
|
||||||
if (options.IsTransform)
|
|
||||||
{
|
|
||||||
if (options.Files.Count != 2)
|
|
||||||
{
|
|
||||||
Console.WriteLine("Usage: Excel2TextDiff -t <excel file> <text file>");
|
|
||||||
Environment.Exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
writer.TransformToTextAndSave(options.Files[0], options.Files[1]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (options.Files.Count != 2)
|
|
||||||
{
|
|
||||||
Console.WriteLine("Usage: Excel2TextDiff -d <excel file 1> <excel file 2> ");
|
|
||||||
Environment.Exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
var diffProgame = options.DiffProgram ?? "TortoiseMerge.exe";
|
|
||||||
|
|
||||||
var tempTxt1 = Path.GetTempFileName();
|
|
||||||
writer.TransformToTextAndSave(options.Files[0], tempTxt1);
|
|
||||||
|
|
||||||
var tempTxt2 = Path.GetTempFileName();
|
|
||||||
writer.TransformToTextAndSave(options.Files[1], tempTxt2);
|
|
||||||
|
|
||||||
ProcessStartInfo startInfo = new ProcessStartInfo();
|
|
||||||
startInfo.FileName = diffProgame;
|
|
||||||
string argsFormation = options.DiffProgramArgumentFormat ?? "/base:{0} /mine:{1}";
|
|
||||||
startInfo.Arguments = string.Format(argsFormation, tempTxt1, tempTxt2);
|
|
||||||
Process.Start(startInfo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static CommandLineOptions ParseOptions(String[] args)
|
|
||||||
{
|
|
||||||
var helpWriter = new StringWriter();
|
|
||||||
var parser = new Parser(ps =>
|
|
||||||
{
|
|
||||||
ps.HelpWriter = helpWriter;
|
|
||||||
});
|
|
||||||
|
|
||||||
var result = parser.ParseArguments<CommandLineOptions>(args);
|
|
||||||
if (result.Tag == ParserResultType.NotParsed)
|
|
||||||
{
|
|
||||||
Console.Error.WriteLine(helpWriter.ToString());
|
|
||||||
Environment.Exit(1);
|
|
||||||
}
|
|
||||||
return ((Parsed<CommandLineOptions>)result).Value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -3,8 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio Version 16
|
# Visual Studio Version 16
|
||||||
VisualStudioVersion = 16.0.29418.71
|
VisualStudioVersion = 16.0.29418.71
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Excel2TextDiff", "Excel2TextDiff\Excel2TextDiff.csproj", "{9477226F-469E-458F-A3AD-9115D777A65A}"
|
|
||||||
EndProject
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LubanAssistant", "LubanAssistant\LubanAssistant.csproj", "{353807D5-2074-42CD-AD69-F3F59D359E57}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LubanAssistant", "LubanAssistant\LubanAssistant.csproj", "{353807D5-2074-42CD-AD69-F3F59D359E57}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue