Skip to content

When the sheet name is specified as $Property$, it auto splits into multiple sheets if the property is enumerable, Supports template for nested objects #959

Open
iyumot wants to merge 15 commits into
mini-software:masterfrom
FundOffice:extent
Open

When the sheet name is specified as $Property$, it auto splits into multiple sheets if the property is enumerable, Supports template for nested objects #959
iyumot wants to merge 15 commits into
mini-software:masterfrom
FundOffice:extent

Conversation

@iyumot

@iyumot iyumot commented May 15, 2026

Copy link
Copy Markdown

with template

image image

model

public record struct Identity(int Type, string Id);

private class Fund
{
    public int Id { get; set; }
    public string? Name { get; set; }
    public Identity Identity { get; set; }
    public DateOnly SetupDate { get; set; }

    public List<NetValue> NetValues { get; set; } = [];
}

public record NetValue(DateOnly Date, decimal Value);

data

var value = new
{
    Funds = fundList.Select(x => new
    {
        x.Id,
        x.Name,
        x.Identity,
        x.SetupDate,
        x.NetValues,
        SheetName = x.Name
    })
};

specify sheetname by SheetName property, if not exist set as what in $$ plus 1,2,3

result
image
image
image

Resolves #300

k1k-xxsc added 2 commits May 15, 2026 09:10
{{Funds.Id}} {{Funds.Name}} {{Funds.Identity.Id}} {{Funds.Identity.Type}} {{Funds.SetupDate.Year}}

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces multi-sheet expansion capabilities and enhanced object flattening with circular reference protection to the OpenXml template engine. The reviewer identified several critical bugs, including a double increment of the sheet index that breaks file relationships and a loop termination issue that prevents processing multiple template sheets. Additionally, feedback was provided regarding redundant type checks, inefficient regex instantiation, unnecessary decimal parsing, and missing namespace imports required for cross-platform compilation.

Comment thread src/MiniExcel.OpenXml/Templates/OpenXmlValueExtractorHook.cs Outdated
Comment thread src/MiniExcel.OpenXml/Templates/OpenXmlValueExtractorHook.cs Outdated
Comment thread src/MiniExcel.OpenXml/Templates/OpenXmlValueExtractorHook.cs Outdated
Comment thread src/MiniExcel.OpenXml/Templates/OpenXmlValueExtractorHook.cs Outdated
Comment thread src/MiniExcel.OpenXml/Templates/OpenXmlValueExtractorHook.cs Outdated
Comment thread src/MiniExcel.OpenXml/Templates/OpenXmlTemplate.cs Outdated
@michelebastione michelebastione marked this pull request as draft May 15, 2026 06:44
@michelebastione

Copy link
Copy Markdown
Collaborator

Thank you for your contribution, I will try to evaluate it as soon as possible. Please change the title and description to include a more detailed description of the intents of the PR.

@iyumot iyumot changed the title Extent When the sheet name is specified as $Property$, it auto splits into multiple sheets if the property is enumerable, Supports template binding for nested objects May 15, 2026
@iyumot iyumot changed the title When the sheet name is specified as $Property$, it auto splits into multiple sheets if the property is enumerable, Supports template binding for nested objects When the sheet name is specified as $Property$, it auto splits into multiple sheets if the property is enumerable, Supports template for nested objects May 15, 2026
@michelebastione

Copy link
Copy Markdown
Collaborator

Hello @iyumot, I apologize but I haven't had the time to properly analyse the PR.
I did skim a little bit through it though and noticed all comments were written in Chinese. I kindly request you to translate them to English for facilitating the work of international comtributors and for keeping the codebase consistent.

@michelebastione michelebastione self-assigned this May 19, 2026
@michelebastione

Copy link
Copy Markdown
Collaborator

Hello @iyumot could you please address my previous comment concerning the Chinese comments in your code? Thank you.

k1k-xxsc and others added 4 commits May 28, 2026 09:23
# Conflicts:
#	src/MiniExcel.OpenXml/Templates/OpenXmlTemplate.cs
Simplified value extarctor hook: moved reference comparer to polyfills file, moved XNamespaces to static fields, moved `GetFormattedValue` to OpenXmlTemplate.Impl file (and reused it in `GenerateCellValues` function), renamed methods, refactored "Core" flatten method into local function, removed some superfluous comments, changed schemas and filenames from raw strings to constants, removed preprocessor instructions, added `RecursivePropertiesMaxDepth` to `OpenXmlConfiguration`, and other minor changes and clean ups.
@michelebastione michelebastione marked this pull request as ready for review June 7, 2026 00:04
@michelebastione michelebastione marked this pull request as draft June 7, 2026 00:11
@michelebastione

Copy link
Copy Markdown
Collaborator

@iyumot @k1k-xxsc Please grant mantainers access to modify the PR.

@iyumot

iyumot commented Jun 7, 2026

Copy link
Copy Markdown
Author

This pull request comes from an organization repository, and it seems the maintainer permission setting is unavailable here. I've sent you an invitation, but I'm not sure if there are other ways to get this done.

@iyumot

iyumot commented Jun 7, 2026

Copy link
Copy Markdown
Author

or you can use my code whatever you want and close this pr

iyumot and others added 2 commits June 7, 2026 12:48
…the object itself was not added to the replacement list. For example, for {{f.Latest.Date}}, the key date did not exist in the dictionary, resulting in the field not being assigned a value during template export.

test is in  MiniExcelTemplateTests.cs TestExtend2
…pr/959

# Conflicts:
#	src/MiniExcel.OpenXml/Templates/OpenXmlValueExtractorHook.cs
#	tests/MiniExcel.OpenXml.Tests/SaveByTemplate/MiniExcelTemplateTests.cs
@michelebastione

Copy link
Copy Markdown
Collaborator

Thanks for the invite, I will accept it for ease of collaboration this time.

@michelebastione michelebastione marked this pull request as ready for review June 7, 2026 13:41
@michelebastione

Copy link
Copy Markdown
Collaborator

@iyumot Please add instructions on how to use the feature to the readme

Added support for generating sheets based on enumerable values in the template.

Signed-off-by: iyu <iyumot@163.com>
@iyumot

iyumot commented Jun 9, 2026 via email

Copy link
Copy Markdown
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SaveAsByTemplate support level 2 non-enumerable property value

3 participants