title: How to not exceed the maximum number of fonts when generating XLS spreadsheets
body: <p>I am taking several comma delimited CSV files and using them to generate an XLS spreadsheet in which the names of the files become separate tabs in the spreadsheet. The code I have produces the results I want except for when opening the spreadsheet I get the following warning: "Some text formatting may have changed in this file because the maximum number of fonts was exceeded. It may help to close other documents and try again." I am pretty sure that the problem arises from the code trying to change the format of cells beyond the 65536 row limit, but I'm not sure how to limit the row changes. I need no more than a few hundred rows across four columns.</p>
  
  <pre><code>import csv, glob, xlwt, sys, os
  csvFiles = os.path.join(LogFileFolder, "*")
  wb = xlwt.Workbook()
  colNames = ['iNFADS_FAC','CAT','Crosswalk_FAC','FAC']
  for filename in glob.glob(csvFiles):
      (f_path, f_name) = os.path.split(filename)
      (f_short_name, f_extension) = os.path.splitext(f_name)
      ws = wb.add_sheet(f_short_name)
      with open(filename, 'rb') as csvf: 
          csvReader = csv.reader(csvf)
          for rowx, row in enumerate(csvReader): 
              for colx, value in enumerate(row):
                  if value in colNames:
                      ws.write(rowx, colx, value, xlwt.easyxf(
                          "border: top medium, right medium, bottom double, left medium; 
                          font: bold on; pattern: pattern solid, fore_color pale_blue; 
                          align: vert centre, horiz centre"))
                  elif value not in colNames:
                      ws.write(rowx, colx, float(value), 
                          xlwt.easyxf("align: vert centre, horiz centre"))
  ##This second "xlwt.easyxf(align...)" part is the offending section of the code, if
  ##I remove just that part then the problem goes away. Is there a way to keep
  ##it within the 65536 limit here?
                  else:
                      pass
  wb.set_active_sheet = 1      
  outXLS = os.path.join(LogFileFolder, "FAC-CAT Code Changes.xls")
  wb.save(outXLS) 
  </code></pre>