Пример #1
0
void MYMENU_FormatClearStyle()
{
    int row, col;
    CellInfo* info = iterate_selection( table, &row, &col );
    while ( info != NULL ) {
        // history
        history_append( row, col );
        free_redo_history();
        clear_style( &(info->style) );
        info = iterate_selection( table, &row, &col );
    }
    auto_adapt_layout( table );
    update_selection_rect();
    update_table_view();
}
Пример #2
0
    void test_style()
    {
        xlnt::workbook wb;
        auto ws = wb.active_sheet();
        auto cell = ws.cell("A1");

        xlnt_assert(!cell.has_style());

        auto test_style = wb.create_style("test_style");
        test_style.number_format(xlnt::number_format::date_ddmmyyyy(), true);

        cell.style(test_style);
        xlnt_assert(cell.has_style());
        xlnt_assert_equals(cell.style().number_format(), xlnt::number_format::date_ddmmyyyy());
        xlnt_assert_equals(cell.style(), test_style);

        auto other_style = wb.create_style("other_style");
        other_style.number_format(xlnt::number_format::date_time2(), true);

        cell.style("other_style");
        xlnt_assert_equals(cell.style().number_format(), xlnt::number_format::date_time2());
        xlnt_assert_equals(cell.style(), other_style);

        auto last_style = wb.create_style("last_style");
        last_style.number_format(xlnt::number_format::percentage(), true);

        cell.style(last_style);
        xlnt_assert_equals(cell.style().number_format(), xlnt::number_format::percentage());
        xlnt_assert_equals(cell.style(), last_style);

        xlnt_assert_throws(cell.style("doesn't exist"), xlnt::key_not_found);

        cell.clear_style();

        xlnt_assert(!cell.has_style());
        xlnt_assert_throws(cell.style(), xlnt::invalid_attribute);
    }