tfussell / xlnt

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

need explanation with reference row #77

Closed sukoi26 closed 8 years ago

sukoi26 commented 8 years ago

in this code :

 auto ws1 = wb.get_active_sheet();
    ws1.set_title("range names");

        // set style
    auto cell = ws1.get_cell("A10");

    cell.set_fill(xlnt::fill::solid(xlnt::color::yellow()));
    ws1.get_cell("A10").set_value("Fill Yellow");

    ws1.get_cell("A11").set_value(xlnt::date(2010, 7, 13));

 //   for(xlnt::row_t row = 1; row < 40; row++)
    xlnt::row_t row = 1;
    for(xlnt::cell_reference(1, row); row < 40; row++)
    {
        // 10 c by  40 
        std::vector<int> to_append(10, 0);
        std::iota(std::begin(to_append), std::end(to_append), 0);
        ws1.append(to_append);
    }

the ws.append function write after the last cell row reference (11 here) how to write the values at the "A1" cell ? ws1 location of the reference cell

sukoi26 commented 8 years ago

I tried it without success

    xlnt::row_t row = 1;
    for(xlnt::cell_reference(1, row); row < 40; row++)

    {
        // 10 c by  40 l
        std::vector<int> to_append(10, 0);
        std::iota(std::begin(to_append), std::end(to_append), 0);
        //ws1.append(to_append);
        xlnt::cell_reference next(1, 1);

     for (auto cell : to_append)
        {
        ws1.get_cell(next).set_value(cell);
        std::cout << ws1.get_cell(next) << std::endl;
        next.set_column_index(next.get_column_index() + 1);
        }

    }
sukoi26 commented 8 years ago

closed, mistake from my part

    xlnt::row_t row = 1;
    for(xlnt::cell_reference(1, row); row < 40; row++)

    {
        // 10 c by  40 l
        std::vector<int> to_append(10, 0);
        std::iota(std::begin(to_append), std::end(to_append), 0);
        //ws1.append(to_append);
        xlnt::cell_reference next(1,row);

     for (auto cell : to_append)
        {
        ws1.get_cell(next).set_value(cell);
        std::cout << ws1.get_cell(next) << std::endl;
        next.set_column_index(next.get_column_index() + 1);
        }
}