code: def wr_data(self, xlsx_data, row_i, worksheet):
          
          fld2fmt = self.vars.fld2fmt
          # User may specify to skip rows based on values in row
          prt_if = self.vars.prt_if
          # User may specify a subset of columns to print or
          # a column ordering different from the _fields seen in the namedtuple
          prt_flds = self.wbfmtobj.get_prt_flds()
          get_wbfmt = self.wbfmtobj.get_wbfmt
          if self.vars.sort_by is not None:
              xlsx_data = sorted(xlsx_data, key=self.vars.sort_by)
          try:
              for data_nt in xlsx_data:
                  if prt_if is None or prt_if(data_nt):
                      wbfmt = get_wbfmt(data_nt)  # xlsxwriter.format.Format created w/add_format
                      # Print an xlsx row by printing each column in order.
                      for col_i, fld in enumerate(prt_flds):
                          try:
                              # If fld "format_txt" present, use val for formatting, but don't print.
                              val = getattr(data_nt, fld, "")
                              # Optional user-formatting of specific fields, eg, pval: "{:8.2e}"
                              # If field value is empty (""), don't use fld2fmt
                              if fld2fmt is not None and fld in fld2fmt and val != "" and val != "*":
                                  val = fld2fmt[fld].format(val)
                              worksheet.write(row_i, col_i, val, wbfmt)
                          except:
                              raise RuntimeError(self._get_err_msg(row_i, col_i, fld, val, prt_flds))
                      row_i += 1
          except RuntimeError as inst:
              import traceback
              traceback.print_exc()
              sys.stderr.write("\n  **FATAL in wr_data: {MSG}\n\n".format(MSG=str(inst)))
              sys.exit(1)
          return row_i
docs: Write data into xlsx worksheet.