code: def wr_xlsx(fout_xlsx, data_xlsx, **kws):
      
      from goatools.wr_tbl_class import WrXlsx
      # optional keyword args: fld2col_widths hdrs prt_if sort_by fld2fmt prt_flds
      items_str = kws.get("items", "items") if "items" not in kws else kws["items"]
      if data_xlsx:
          # Open xlsx file
          xlsxobj = WrXlsx(fout_xlsx, data_xlsx[0]._fields, **kws)
          worksheet = xlsxobj.add_worksheet()
          # Write title (optional) and headers.
          row_idx = xlsxobj.wr_title(worksheet)
          row_idx = xlsxobj.wr_hdrs(worksheet, row_idx)
          row_idx_data0 = row_idx
          # Write data
          row_idx = xlsxobj.wr_data(data_xlsx, row_idx, worksheet)
          # Close xlsx file
          xlsxobj.workbook.close()
          sys.stdout.write("  {N:>5} {ITEMS} WROTE: {FOUT}\n".format(
              N=row_idx-row_idx_data0, ITEMS=items_str, FOUT=fout_xlsx))
      else:
          sys.stdout.write("      0 {ITEMS}. NOT WRITING {FOUT}\n".format(
              ITEMS=items_str, FOUT=fout_xlsx))
docs: Write a spreadsheet into a xlsx file.