summaryrefslogtreecommitdiff
path: root/tablib
diff options
context:
space:
mode:
authorGreg Thornton <gthornton@cjadvertising.com>2011-07-14 13:47:07 -0500
committerGreg Thornton <gthornton@cjadvertising.com>2011-07-14 13:47:07 -0500
commitf6d7888d9e28222b8df9c5ba5359e358e9c1677b (patch)
tree5a4d58766e4fa3c43ae0c36987a4a97cc5a9bad7 /tablib
parentc19e2f2c5bcc2c3bf2b77594c00433704b7111af (diff)
downloadtablib-f6d7888d9e28222b8df9c5ba5359e358e9c1677b.tar.gz
Added xls detection.
Diffstat (limited to 'tablib')
-rw-r--r--tablib/formats/_xls.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/tablib/formats/_xls.py b/tablib/formats/_xls.py
index 1282a43..c801658 100644
--- a/tablib/formats/_xls.py
+++ b/tablib/formats/_xls.py
@@ -112,3 +112,11 @@ def dset_sheet(dataset, ws):
ws.write(i, j, col)
+def detect(stream):
+ """Returns True if given stream is valid XLS."""
+
+ try:
+ xlrd.open_workbook(file_contents=stream)
+ return True
+ except xlrd.XLRDError:
+ return False