tfussell / xlnt

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

Throws file not found for drawing #632

Open huseyinkozan opened 2 years ago

huseyinkozan commented 2 years ago

Hi,

Throws file not found for drawing. File does not exist inside the archive, but there is a releation.

Ekran görüntüsü 2022-06-16 12-42-47

Ekran görüntüsü 2022-06-16 12-50-37

I cannot share the file because our customer owns it.

Don't know if it is the right way, but I have fixed by adding has_file() like;

    if (manifest.has_relationship(sheet_path, xlnt::relationship_type::drawings))
    {
        auto drawings_part = manifest.canonicalize({workbook_rel, sheet_rel,
            manifest.relationship(sheet_path, xlnt::relationship_type::drawings)});

        if (archive_->has_file(drawings_part))
        {
            auto receive = xml::parser::receive_default;
            auto drawings_part_streambuf = archive_->open(drawings_part);
            std::istream drawings_part_stream(drawings_part_streambuf.get());
            xml::parser parser(drawings_part_stream, drawings_part.string(), receive);
            parser_ = &parser;

            read_drawings(ws, drawings_part);
        }
    }

Also, added has_file() for other open calls.