Commits

Luke Plant  committed c6da8a5

Pulled out 'workbook_to_string' function

  • Participants
  • Parent commits 92c748b
  • Branches bookings

Comments (0)

Files changed (2)

File 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)

File cciw/utils/xl.py

 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()