Skip to content

【Feature Request】 Support Adding Sample Data When Exporting Templates #607

@blackWins

Description

@blackWins

Feature Description

I hope Magicodes.IE can support automatically populating sample data in templates (such as Excel, Word, etc.) when exporting them, instead of only exporting empty templates. This will help users intuitively understand the template usage and data format, improving the template's usability.

Background & Rationale

Currently, templates exported by Magicodes.IE are usually blank. Users need to fill in data based on documentation or personal experience. For complex templates or users unfamiliar with the system, this may lead to high learning costs and operational difficulties. If templates include sample data, users can quickly grasp the meaning and filling specifications of each field, thereby improving work efficiency.

Feature Details

Sample Data Sources

Allow specifying sample data (e.g., an object or dictionary) via parameters when exporting templates.
Provide default sample data for common field types (e.g., name, age, date, etc.).

Sample Data Display

Sample data should be populated in the corresponding positions of the template, consistent with the format of actual data.
Optional: Add annotations or markers next to sample data to indicate it’s for demonstration, helping users distinguish from real data.

Flexibility

Users can choose whether to include sample data (default: not included).
Support customizing the content and format of sample data.

Example Code

// Export Excel template with sample data
var sampleData = new List<MyData>
{
    new MyData { Id = 1, Name = "Zhang San", Age = 25, CreateTime = DateTime.Now },
    new MyData { Id = 2, Name = "Li Si", Age = 30, CreateTime = DateTime.Now }
};
// Call template export method and pass sample data
var result = await _excelImporter.GenerateTemplateBytes<MyData>(sampleData);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions