Let excel be the configuration
$ dotnet add package ExcelConfigExcelConfig , best excel-file configuration.
📃 demo config
🔗 store server
🔗 ExcelConfig.StoreAPI Nuget
var cfg = new AppConfigFile("./999/app.config.xlsx");
Console.WriteLine(cfg.Text("ExcelConfigVersion"));
ExcelConfigHelper.SetDefault("Test0001", "ok");
ExcelConfigHelper.EnterPassword("Test0002");
ExcelConfigHelper.Enter("Test0003");
// interface IExcelConfig: support class AppConfigFile;AppConfigStreamFile;ExcelConfigFile;ExcelConfigStreamFile
string Text(string key)
decimal Number(string key)
IEnumerable<string> LoopArray(string key);
string[] Array(string key)
bool YesOrNo(string key)
void WriteText(string key, string value)
void WriteYesOrNo(string key, bool value)
string YES;
string NO ;
char ArraySplitChar;
string CONFIG_DEFAULT;
string CONFIG_SUFFIX;
string SHEET_Global;
string COLUMN_KEY;
string COLUMN_VALUE;
string CONFIG_PATH;
Password_Encrypt PasswordEncrypt; // delegate void Password_Encrypt(ref string password);
xlsx template, replace excel text likes {{key}}.
var template = new ExcelTemplateFile("./999/app.config.xlsx");
template.TemplateOut(new { TEST = "test text" }, "./test.xlsx");
var x = ExcelFile.Load("./999/app.config.xlsx", "Sheet1");
var xw = x.Read(2,3).Text;
// need SetKeyField
foreach (var line in x.ReadAllLine())
{
foreach (var line_key in line.Keys)
Console.WriteLine(line_key + ": " +line.Text(line_key));
}
using (var cfg = new AppConfigStreamFile(AppConfig.EmptyStream()))
{
cfg.WriteText("test", "TestOK");
using (var f = File.Create("3.xlsx")) cfg.ToStream(f);
}
using (var template = new ExcelTemplateStreamFile(File.Open("./999/app.config.xlsx", FileMode.Open, FileAccess.Read, FileShare.ReadWrite)))
{
using (var fs2 = File.Create("test.xlsx"))
template.TemplateOut(new { TEST = "Test OK" }, fs2);
}
reference:
1: MiniExcel 1.41.2 #Apache License 2.0 nuget link
(revised statement: delete net2.0 nosupport; use yacomp. )