From 8dc73421374e531b959f8b50c977b2459bbd395c Mon Sep 17 00:00:00 2001 From: Thomas Fussell Date: Thu, 1 Oct 2015 23:22:46 -0400 Subject: [PATCH] should fix issue #9 --- source/writer.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/source/writer.cpp b/source/writer.cpp index 40e830d1..ac3b78dc 100644 --- a/source/writer.cpp +++ b/source/writer.cpp @@ -167,9 +167,16 @@ std::string writer::write_workbook(const workbook &wb) for(auto relationship : wb.get_relationships()) { if(relationship.get_type() == relationship::type::worksheet) - { - std::string sheet_index_string = relationship.get_target_uri().substr(16); - std::size_t sheet_index = std::stoi(sheet_index_string.substr(0, sheet_index_string.find('.'))) - 1; + { + std::string sheet_index_string = relationship.get_target_uri(); + sheet_index_string = sheet_index_string.substr(0, sheet_index_string.find('.')); + sheet_index_string = sheet_index_string.substr(sheet_index_string.find_last_of('/')); + auto iter = sheet_index_string.end(); + iter--; + while (isdigit(*iter)) iter--; + auto first_digit = iter - sheet_index_string.begin(); + sheet_index_string = sheet_index_string.substr(first_digit + 1); + std::size_t sheet_index = std::stoi(sheet_index_string) - 1; auto ws = wb.get_sheet_by_index(sheet_index);