Closed sukoi26 closed 7 years ago
This is my first time actually seeing custom properties. This one should be easy enough to fix. You manage to find all of the bugs in my library!
I have the same problem: xlnt:: error : unhandled case http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties
Thanks @engineer84. I'll be looking into this soon.
This is fixed on the latest commit to master. Do note that the custom properties are not round-tripped yet. They won't cause an error when reading a file that contains them and can be accessed via xlnt::workbook::custom_property.
That rocks! Everything is working now. Much appreciated.
Perfect! No round trip needed by me. Thanks so much. Works now
On Jan 2, 2017, at 5:28 PM, Thomas Fussell notifications@github.com<mailto:notifications@github.com> wrote:
This is fixed on the latest commit to master. Do note that the custom properties are not round-tripped yet. They won't cause an error when reading a file that contains them and can be accessed via xlnt::workbook::custom_property.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/tfussell/xlnt/issues/96#issuecomment-270031947, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AKh0Bfwb66nqJ2pM_5sEWqzR-gHkb-_Nks5rOYgNgaJpZM4LNg_H.
Sorry, please reopen as
1 0x00007ffff798c26e in xml::parser::next_expect (this=0x7fffffffc7b0, e=xml::parser::end_element, ns="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes", n="i4"
the parser check only the vt:lpwstr but ECMA said "
the code involved, i suggest to remove the if then on variant_child_element cause each name need an element but some case as link to analyse
void xlsx_consumer::read_properties(const path &part, const xml::qname &root)
{
static const auto &xmlns_vt = constants::namespace_("vt");
auto content_type = manifest().content_type(part);
std::unordered_map<std::string, std::string> properties;
expect_start_element(root, xml::content::complex);
while (in_element(root))
{
auto property_element = expect_start_element(xml::content::mixed);
if (property_element.name() != "property")
{
properties[property_element.name()] = read_text();
}
else
{
auto property_name = parser().attribute("name");
auto variant_child_element = expect_start_element(xml::content::simple);
**if (variant_child_element == xml::qname(xmlns_vt, "lpwstr"))
{
properties[property_name] = read_text();
}**
expect_end_element(variant_child_element);
}
skip_remaining_content(property_element);
expect_end_element(property_element);
}
expect_end_element(root);
if (content_type == "application/vnd.openxmlformats-officedocument.custom-properties+xml")
{
for (const auto &prop : properties)
{
target_.custom_property(prop.first, prop.second);
}
}
}
I thought I could get away with only implementing vt:lpwstr. I'll at least come up with a way for the properties you've attached to be parsed correctly. Thanks for coming up with a code solution too.
after the revision https://github.com/tfussell/xlnt/commit/7e391d9ef2668317f3abfbc7f19a1d5973e0af88 i note major improvement in read/save.
concern save: still pid count nok (stay = 2) missing variant value
<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/custom-properties" xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">
<property name="ScaleCrop" fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="2">
<vt:lpwstr></vt:lpwstr>
</property>
<property name="AppVersion" fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="2">
<vt:lpwstr>15.0300</vt:lpwstr>
</property>
<property name="ShareDoc" fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="2">
<vt:lpwstr></vt:lpwstr>
</property>
<property name="DocSecurity" fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="2">0</property>
<property name="HyperlinksChanged" fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="2">
<vt:lpwstr></vt:lpwstr>
</property>
<property name="LinksUpToDate" fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="2">
<vt:lpwstr></vt:lpwstr>
</property>
</Properties>
i f i read the saved file EXCEL warm
Part removed: part /xl/styles.xml error XML. (Styles) Error Line 54, column 27
Record repaired: Information cell in part /xl/worksheets/sheet1.xml
Patch for the bug bool (any bool is i4 writing) consummer.cpp
if (element == qn("vt", "i4"))
{
value = variant(std::stoi(text));
}
++ if (element == qn("vt", "bool"))
++ {
++ bool bvalue = std::stoi(text);
++ value = variant(bvalue);
++ }
no so good a bool could be a number or a text
if (element == qn("vt", "bool"))
{
// bool could be "0" or "false"
bool bvalue;
if (text[0] == '0' or text[0] == 'f' or text[0]=='F') bvalue = false;
else bvalue = true;
value = variant(bvalue);
}
closed
in first, i have a xml string as
give error to decode .
In second, the file custom.xml cannot be parsed. "Properties expected"