title: Auto fit column length in xlsxwriter
body: <p>I am try below code to find the max length of the columns and adjust its width accordingly but am getting error stating:</p>
  
  <pre><code>UnicodeEncodeError: 'ascii' codec can't encode character u'\xae'
  in position 8: ordinal not in range(128)
  </code></pre>
  
  <p>Below is my code:</p>
  
  <pre><code># Iterate through each column and set the width == the max
  # length in that column A padding length of 2 is also added
  for i, col in enumerate(df1.columns): 
      # Find length of column i    
      column_len = df1[col].astype(str).str.len().max()
      # Setting the length if the column header is larger than the
      # max column value length
      column_len = max(column_len, len(col)) + 2
      # Set the column length        
      worksheet.set_column(i, i, column_len)
  </code></pre>