mini-software / MiniExcel

Fast, Low-Memory, Easy Excel .NET helper to import/export/template spreadsheet (support Linux, Mac)
https://www.nuget.org/packages/MiniExcel/
Apache License 2.0
2.69k stars 329 forks source link

Optimize template generator format performance #173

Open shps951023 opened 3 years ago

shps951023 commented 3 years ago

Key Problem : if remove namesapcename, prefix will loss image

it need cost to check prefix case like <x:xxx> image

shps951023 commented 3 years ago

format c innerxml is better than formating row innerxml image

image

shps951023 commented 3 years ago
void Main()
{
    var value = Enumerable.Range(1, 1_000_000).Select(s => new {V=s});
    foreach (var element in value)
    {

    }

    var st = new Stopwatch();
    st.Start();

    var path = Path.GetTempPath() + Guid.NewGuid() + ".xlsx";
    MiniExcel.SaveAs(path,value,true);

    Console.WriteLine(st.ElapsedMilliseconds);
    Console.WriteLine(path);

    path = Path.GetTempPath() + Guid.NewGuid() + ".xlsx";

    var templatePath = Path.GetTempPath() + Guid.NewGuid() + ".xlsx";
    MiniExcel.SaveAs(templatePath, new[] { new {V="{{enums.V}}"}},true);

    st.Restart();
    MiniExcel.SaveAsByTemplate(path,templatePath, new {enums=value});
    Console.WriteLine(st.ElapsedMilliseconds);
    Console.WriteLine(path);
}

image

shps951023 commented 3 years ago
        static void Main(string[] args)
        {
            var value = Enumerable.Range(1, 1_000_00).Select(s => new { V = s });
            var path = Path.GetTempPath() + Guid.NewGuid() + ".xlsx";
            MiniExcel.SaveAsByTemplate(path, @"C:\Users\Wei\AppData\Local\Temp\52a2dca4-064f-4d6c-9d2f-3208a2f880e3.xlsx", new { enums = value });
            Console.WriteLine(path);
        }

image image image

shps951023 commented 3 years ago

Memory Usage image image