import xlsxwriter import numpy as np def write_excel(order_list, path, sheet_name='Sheet1'): book = xlsxwriter.Workbook(path) table = book.add_worksheet(sheet_name) style = book.add_format({ "fg_color": "yellow", # 单元格的背景颜色 "font_color": "red" # 字体颜色 }) for index, data in enumerate(order_list): if data[1] > 11: table.write_row(index, 0, data, style) else: table.write_row(index, 0, data) book.close() if __name__ == '__main__': d = np.array([[10, 11, 12], [20, 21, 22], [30, 31, 32]]) path = './1.xls' write_excel(d, path)