Skip to content

Instantly share code, notes, and snippets.

@rafaqz
Last active December 18, 2015 17:39
Show Gist options
  • Save rafaqz/5820452 to your computer and use it in GitHub Desktop.
Save rafaqz/5820452 to your computer and use it in GitHub Desktop.
Adds better case handling to feeds xls. Probably should make an issue on drupal.org...
diff --git a/FeedsExcelParser.inc b/FeedsExcelParser.inc
index 3a0e5da..29d66c0 100644
--- a/FeedsExcelParser.inc
+++ b/FeedsExcelParser.inc
@@ -102,7 +102,7 @@ class FeedsExcelParser extends FeedsParser{
$cellIterator->setIterateOnlyExistingCells(false); // Loop all cells, even if it is not set
foreach($cellIterator as $cell){
if(!is_null($cell)){
- $headers[] = trim($cell->getCalculatedValue());
+ $headers[] = trim(drupal_strtolower($cell->getCalculatedValue()));
}
}
break;
@@ -213,6 +213,15 @@ class FeedsExcelParser extends FeedsParser{
return FALSE;
}
+
+ /**
+ * Hack copied From FeedsCSVParser.inc
+ * Override parent::getSourceElement() to use only lower keys.
+ */
+ public function getSourceElement(FeedsSource $source, FeedsParserResult $result, $element_key) {
+ return parent::getSourceElement($source, $result, drupal_strtolower($element_key));
+ }
+
/**
* Source form.
*
@@ -257,4 +266,4 @@ class FeedsExcelParser extends FeedsParser{
);
return $form;
}
-}
\ No newline at end of file
+}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment