Luke Plant avatar Luke Plant committed c6da8a5

Pulled out 'workbook_to_string' function

Comments (0)

Files changed (2)

cciw/officers/utils.py

 """
 Utility functions for officers app.
 """
-from StringIO import StringIO
-
 import xlwt
 
-from cciw.utils.xl import add_sheet_with_header_row
+from cciw.utils.xl import add_sheet_with_header_row, workbook_to_string
 
 
 def camp_officer_list(camp):
             yield row
 
     add_sheet_with_header_row(wkbk, "Officers", header_row, data_rows())
-
-    # Write out to string:
-    s = StringIO()
-    wkbk.save(s)
-    s.seek(0)
-    return s.read()
+    return workbook_to_string(wkbk)
 Simplified xlwt interface
 """
 from datetime import datetime, date
+from StringIO import StringIO
+
 import xlwt
 
 
             else:
                 style = xlwt.Style.default_style
             wksh.write(r + 1, c, val, style=style)
+
+
+def workbook_to_string(wkbk):
+    s = StringIO()
+    wkbk.save(s)
+    s.seek(0)
+    return s.read()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.