tfussell / xlnt

:bar_chart: Cross-platform user-friendly xlsx library for C++11+
Other
1.49k stars 418 forks source link

alignment in style doesn't work #570

Open Phymin opened 3 years ago

Phymin commented 3 years ago

Hi,

I create a function to create a style to use for cells

xlnt::style ReportGenerator::getTitleStyle(xlnt::workbook& wb)
{
    auto style = wb.create_style("title");
    auto ft = xlnt::font();
    ft.bold(true);
    ft.size(24);
    style.font(ft);
    style.fill(xlnt::fill::solid(xlnt::color::green()));
    style.alignment(xlnt::alignment().horizontal(xlnt::horizontal_alignment::center));

    return style;
}

And I use this style like this: ws.cell("A1").style(titleStyle), the font and fill in the style is working, but the alignment in the style is not working, and if I add ws.cell("A1").aligment(xlnt::alignment().horizontal(xlnt::horizontal_alignment::center)) below the former code, the alignment of the cell is working. Do I miss something? or How should I make the alignment in the style working? Thank you!