pydantic-xlsx icon indicating copy to clipboard operation
pydantic-xlsx copied to clipboard

Different Model to Excel transformation

Open gbieli opened this issue 3 years ago • 0 comments

Hi, For my project I would need another model to excel transformation like described below.

Let's say I have this model:

class Project(XlsxModel):
    project_name: str
    customer_name: str

    class Config:
        allow_population_by_field_name = True

        @classmethod
        def alias_generator(cls, string: str) -> str:
            return ''.join(word.capitalize() for word in string.split('_'))

project_example = Project(project_name="Test Project", customer_name="Example Customer")
project_example.to_file("project_example.xlsx")

this would result in:

ProjectName CustomerName
Test Project Example Customer

I would like to have something like this:

ProjectName Test Project
CustomerName Example Customer

Is this possilbe somehow?

Regards, Gérard

gbieli avatar May 02 '22 08:05 gbieli