docs: def write(data, file_name, worksheet_names=None):
      '''
      Writes 2D tables to file.
  
      Args:
          data: 2D list of tables/worksheets.
          file_name: Name of the output file (determines type).
          worksheet_names: A list of worksheet names (optional).
      '''
      if re.search(XML_EXT_REGEX, file_name):
          return write_xml(data, file_name, worksheet_names=worksheet_names)
      elif re.search(XLSX_EXT_REGEX, file_name):
          return write_xlsx(data, file_name, worksheet_names=worksheet_names)
      elif re.search(XLS_EXT_REGEX, file_name):
          return write_xls(data, file_name, worksheet_names=worksheet_names)
      elif re.search(CSV_EXT_REGEX, file_name):
          return write_csv(data, file_name)
      else:
          return write_csv(data, file_name)