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.81k stars 342 forks source link

write formula to Excel, formula treated as string #667

Open EanLee opened 2 months ago

EanLee commented 2 months ago

Excel Type

Upload Excel File

image

MiniExcel Version

1.34.1

Description

When you directly output formulas to an Excel file using MiniExcel, and then save it as a new file, the cells containing the formulas are treated as regular data, and the formulas themselves do not work. The formulas only become active after you manually enter the cells, edit the formulas, and press Enter.

And, I can’t find the relevant settings and instructions in the instructions for use in the readme.


var data = new List<Dictionary<string, object>>
{
    new Dictionary<string, object>
    {
        ["Institution"] = "Institution",
        ["Created"] = "Created",
        ["Formula"] = "Formula",
    },
    new Dictionary<string, object>
    {
        ["Institution"] = "BMC Inc.",
        ["Created"] = "2021-01-01",
        ["Formula"] = $"=SUM(A2:B2)"
    },
};

MiniExcel.SaveAs("test.xlsx", data, printHeader: false, overwriteFile: true, excelType: ExcelType.XLSX);
RaZer0k commented 1 month ago

Functionality waiting for Pull Request. PR 679: Formula Support