Skip to content

Commit

Permalink
Root node no longer needed in XlsxWorkSheet class (#255)
Browse files Browse the repository at this point in the history
  • Loading branch information
jennybc authored Feb 10, 2017
1 parent a81ecd9 commit 5950a7c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/XlsxWorkSheet.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class XlsxWorkSheet {
XlsxWorkBook wb_;
std::string sheet_;
rapidxml::xml_document<> sheetXml_;
rapidxml::xml_node<>* rootNode_;
rapidxml::xml_node<>* sheetData_;
std::vector<XlsxCell> cells_;
std::string sheetName_;
Expand All @@ -30,6 +29,8 @@ class XlsxWorkSheet {
XlsxWorkSheet(XlsxWorkBook wb, int sheet_i, int nskip):
wb_(wb)
{
rapidxml::xml_node<>* rootNode;

if (sheet_i > wb.n_sheets()) {
Rcpp::stop("Can't retrieve sheet in position %d, only %d sheet(s) found.",
sheet_i + 1, wb.n_sheets());
Expand All @@ -39,13 +40,13 @@ class XlsxWorkSheet {
sheet_ = zip_buffer(wb.path(), sheetPath);
sheetXml_.parse<0>(&sheet_[0]);

rootNode_ = sheetXml_.first_node("worksheet");
if (rootNode_ == NULL) {
rootNode = sheetXml_.first_node("worksheet");
if (rootNode == NULL) {
Rcpp::stop("Sheet '%s' (position %d): Invalid sheet xml (no <worksheet>)",
sheetName_, sheet_i + 1);
}

sheetData_ = rootNode_->first_node("sheetData");
sheetData_ = rootNode->first_node("sheetData");
if (sheetData_ == NULL) {
Rcpp::stop("Sheet '%s' (position %d): Invalid sheet xml (no <sheetData>)",
sheetName_, sheet_i + 1);
Expand Down

0 comments on commit 5950a7c

Please sign in to comment.