Skip to content

Formula attribute added to support in rows with dto or dynamic attrib… - #679

Merged
shps951023 merged 2 commits into
mini-software:masterfrom
RaZer0k:master
Oct 15, 2024
Merged

Formula attribute added to support in rows with dto or dynamic attrib…#679
shps951023 merged 2 commits into
mini-software:masterfrom
RaZer0k:master

Conversation

@RaZer0k

@RaZer0k RaZer0k commented Oct 11, 2024

Copy link
Copy Markdown
Contributor

I added the support of formula rows values... i tested with =hyperlink("") without problems.
You can add the parameter "Type = ColumnType.Formula" into the DTO or create a dynamic columns setting with the "Type
= ColumnType.Formula" parameter.

var dColumns = new[]
{
    new DynamicExcelColumn("Url")
    {
        Width = 100,
        Type = ColumnType.Formula
    }
};

var config = new OpenXmlConfiguration
{
    TableStyles = TableStyles.None,
    AutoFilter = false,
    DynamicColumns = dColumns
};

MiniExcel.SaveAs(stream, _sheets, configuration: config);

Or

[ExcelColumn(Name = "Url Document", Type = ColumnType.Formula, Width = 16)] public string Url { get; set; }

Adding this column to use formula:

row.Add("Url", $"=HYPERLINK(\"{doc.Url ?? ""}\")");

Update: Added enum type for the new Type parameter

Comment thread src/MiniExcel/Attributes/ExcelColumnAttribute.cs Outdated
@shps951023
shps951023 merged commit f0fe803 into mini-software:master Oct 15, 2024
@shps951023

Copy link
Copy Markdown
Member

@RaZer0k ❤❤❤ Could we invite you to our team?

@RaZer0k

RaZer0k commented Oct 15, 2024

Copy link
Copy Markdown
Contributor Author

it would be a pleasure for me

@simon-reynolds

Copy link
Copy Markdown

Hi, is there any ETA on when this will be released to NuGet?

@Mines-Foundation-IT

Mines-Foundation-IT commented Jan 14, 2025

Copy link
Copy Markdown

@RaZer0k - Your fix works well but conflicts with EnableAutoWidth configuration setting.

Using version 1.36.0

I applied the attribute [ExcelColumn(Name = "CRM URL", Type = ColumnType.Formula)] to a class property. The formula part worked great but the EnableAutoWidth = true configuration value set the column width based on the text of the formula ("=HYPERLINK(URL, Label)") plus about 30%, instead of the label of the HYPERLINK.

image

Thank you for your great effort on this project!!

pull Bot pushed a commit to zilo555/MiniExcel that referenced this pull request Aug 29, 2026
mini-software#679)

* Formula attribute added to support in rows with dto or dynamic attributes

* Change Formula attribute to ColumnType (Value, Formula)

---------

Co-authored-by: Eulises Vargas <eulises.vargas@iconstruye.onmicrosoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

5 participants