tfussell / xlnt

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

Not able to install xlnt on Ubuntu 18.04 - CMake Error at third-party/libstudxml.build/CMakeLists.txt:52 (add_library): Cannot find source file: parser.cxx #563

Closed anooprana986 closed 3 years ago

anooprana986 commented 3 years ago

I am trying to use xlnt lirary but am unable to install it using the instructions given at: [https://tfussell.gitbooks.io/xlnt/content/docs/introduction/Installation.html]() These are the steps i have followed so far: Step 1: Downloaded xlnt-master from https://github.com/tfussell/xlnt Step 2: Extract xlnt-master.zip Step 3: go to terminal and went inside xlnt-master using cd xlnt-master Step 4: Created a new directory called 'build" and cd into it using mkdir build and then cd build Step 5: Then i typed cmake .. but this step/command gives me error whose screenshot i have attached below.

My questions are 1) How can i resolve this? 2) Assuming someone answer question 1 correctly and then should i type make -j8 ? What does this make -j8 do exactly. 3) Assuming the command make -j8 works how should i check if xlnt is properly working on my pc? For example how can i comfirm by writing one very simple .cpp file and then convert it to binary and execute it? Where should i put that lets say main.cpp file which contains my test/confirmation code? 4) My fourth question is now lets say i have a separate(independent) project that does not use xlnt yet. But now i want to integrate/use that(independent from xlnt) project with xlnt, then how can do that. I mean how can i use this library's functionality with my other project. Where and what files from the xlnt-master should i copy to my independent project in which directories for example and then what changes to make in my project's CMakeLists.txt file. error

zcwjr commented 3 years ago

git clone https://git.codesynthesis.com/libstudxml/libstudxml.git copy libstudxml to third-party/libstudxml

anooprana986 commented 3 years ago

Next when i try to run one example using xlnt in my separate project like

int main() {

    std::cout<<"Main started"<<std::endl; 
    const std::vector<std::pair<std::string, double>> amounts =
    {
        { "Anne", 17.31 },
        { "Brent", 21.99 },
        { "Catelyn", 94.47 },
        { "Diedrich", 101.05 }
    };

    xlnt::workbook wb;
    auto ws = wb.get_active_sheet();

    ws.get_cell("A1").set_value("Name");
    ws.get_cell("B1").set_value("Amount");

    std::size_t row = 2;
    auto money_format = xlnt::number_format::from_builtin_id(44);
    auto &style = wb.create_style("Currency");
    style.set_builtin_id(4);
    style.set_number_format(money_format);

    for (const auto &amount : amounts)
    {
        ws.get_cell(xlnt::cell_reference(1, row)).set_value(amount.first);
        ws.get_cell(xlnt::cell_reference(2, row)).set_value(amount.second);
        ws.get_cell(xlnt::cell_reference(2, row)).set_style("Currency");

        row++;
    }

    std::string sum_formula = "=SUM(B2:B" + std::to_string(row - 1) + ")";
    ws.get_cell(xlnt::cell_reference(2, row)).set_style("Currency");
    ws.get_cell(xlnt::cell_reference(2, row)).set_formula(sum_formula);

    wb.save("create.xlsx");
    return 0;

}

I get the following errors shown in the screenshot: error2

How can i resolve these? I checked the corresponding headers and there was no set_number_format or get_active_sheet methods there. Instead number_format and active_sheet are there inside the headers. But will i have to manually change these function names wherever they are used or are there new headers where these set_whatever_name methods are declared? Is there a link to all the new headers as well? Thanks for the help.

anooprana986 commented 3 years ago

Is there a separate mailing list(that is separate from github) in which people can clear their query?

On Fri, May 28, 2021 at 3:25 PM defwen1996 @.***> wrote:

git clone https://git.codesynthesis.com/libstudxml/libstudxml.git copy libstudxml to third-party/libstudxml

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/tfussell/xlnt/issues/563#issuecomment-850300858, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMU5IUKZPDBG7DPYP2V3RO3TP5R75ANCNFSM45VWVKKA .

zcwjr commented 3 years ago

Sorry, I don't know English very well. I just started to contact xlnt. I found that there are no functions you used in the new version. Maybe this is an obsolete function from a long time ago. You can try to find the old version, or these functions may be Python API