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

Draft
iyumot wants to merge 4 commits into
mini-software:masterfrom
FundOffice:extent
Draft

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 4 commits into
mini-software:masterfrom
FundOffice:extent

Conversation

@iyumot
Copy link
Copy Markdown

@iyumot iyumot commented May 15, 2026

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);

`

with 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

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

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

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
Comment thread src/MiniExcel.OpenXml/Templates/OpenXmlValueExtractorHook.cs
Comment thread src/MiniExcel.OpenXml/Templates/OpenXmlValueExtractorHook.cs
Comment thread src/MiniExcel.OpenXml/Templates/OpenXmlValueExtractorHook.cs
Comment thread src/MiniExcel.OpenXml/Templates/OpenXmlValueExtractorHook.cs
Comment on lines +138 to +139
if (await HookSheetProcess(outputFileArchive, realSheetName, templateSharedStrings, sheetIdx, allSheetInfos, templateSheet, templateFullName, inputValues, cancellationToken).ConfigureAwait(false))
break;
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.

medium

Breaking the loop when HookSheetProcess returns true prevents any subsequent template sheets from being processed. If a template contains multiple sheets and one of them uses the expansion logic, all sheets following it will be missing from the output file. Furthermore, sheetIdx is passed by value, so the caller's index is not updated after expansion, which would cause file name conflicts if the loop were to continue.

@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.

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.

3 participants