title: xlsxwriter catch an error before workbook.close()
body: <p>I have a script that saves 10 worksheets to an .xlsx using xlsxwriter.
  When I try to close the worksheet, I get an error: </p>
  
  <pre><code>"UnicodeDecodeError: 'ascii' codec can't decode byte 0xea in position 28: ordinal not in range(128)".
  </code></pre>
  
  <p>I try to catch the error when I write the lines to the sheet but without any success. As a result, my worksheet doesn't get saved at all and I can't handle with the exception for the line.</p>
  
  <p>Here is my code-</p>
  
  <pre><code>def xlsx_writer(name, data):
      worksheet1 = workbook.add_worksheet(name)
      line_number = 0
      for line in data:
          try:
              worksheet1.write_row(line_number, 0, line)
          except UnicodeDecodeError:
              line = [x.decode('utf-8') for x in line]
              worksheet1.write_row(line_number, 0, line)
  </code></pre>
  
  <p>How can I catch the error while writing every line and not when I close the workbook?</p>