def issue_report(): issue_lable = list( Issue_Milestone_Count.objects.filter(milestone="3.6.0", project_id="BOOT3X").values()) print("issue_lable", issue_lable) table = HTMLTable(caption='Issue统计') table.append_header_rows(())
def compare_two_results(branch_result, master_result, output_path='tmp', html_name='analysis.html'): logging.basicConfig(filename='{}/analysis.log'.format(output_path), level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s') table = HTMLTable(caption=os.path.splitext(html_name)[0]) table.append_header_rows((('case', 'compare kml', 'compare memory',),)) threads = 'multi_ekf' row = 1 for areas in os.listdir(os.path.join(branch_result, threads)): table.append_header_rows(((areas, '', '',),)) table[row][0].attr.colspan = 3 row = row + 1 for cases in os.listdir(os.path.join(branch_result, threads, areas)): branch_case_dir = os.path.join(branch_result, threads, areas, cases) master_case_dir = os.path.join(master_result, threads, areas, cases) now = int(round(time.time() * 1000)) now = time.strftime('%Y%m%d%H%M%S', time.localtime(now / 1000)) case_name = '{}_{}_{}_{}_branch'.format(now, threads, areas, cases) generate_compare_table(table, row, cases, branch_case_dir, master_case_dir, case_name, output_path) # generate_report_table(table, row, cases, branch_case_dir, case_name, output_path) html_path = os.path.join(output_path, html_name) generate_html_file(table, html_path) generate_pdf_file(html_path)
def to_html(table: pd.DataFrame): table = table.astype(str) t = HTMLTable() l = list() t.append_header_rows([table.columns.values.tolist()]) for index, row in table.iterrows(): l.append(row.to_list()) t.append_data_rows(l) t.set_cell_style({ 'border-color': '#aaaaaa', 'border-width': '1px', 'border-style': 'solid', 'border-collapse': 'collapse', 'padding': '4' }) t.set_header_row_style({'background-color': '#c9d200'}) return t.to_html()
def output_html(rowData): """ :param rowData: 行数据, 元祖数据,逗号分隔,格式为( ('2020/10/18', 'HO1234', '上海', '上海', '10:00~12:00', '可兑换'), ('2020/10/18', 'HO1234', '上海', '上海', '10:00~12:00', '可兑换'),) :return: html 内容 """ nowTime = time.strftime('%Y-%m-%d %H:%M:%S') # 标题 table = HTMLTable(caption='吉祥航空畅心飞余票概览(%s更新)' % nowTime) table.append_header_rows( (('日期', '始发城市', '目的城市', '航班', '航线', '时间', '耗时', '畅飞卡座位'), )) # 表格内容 table.append_data_rows(rowData) # 表格样式,即<table>标签样式 table.set_style({ 'border-collapse': 'collapse', 'word-break': 'keep-all', 'white-space': 'nowrap', 'font-size': '14px', }) # 统一设置所有单元格样式,<td>或<th> table.set_cell_style({ 'border-color': '#000', 'border-width': '1px', 'border-style': 'solid', 'padding': '5px', }) # 表头样式 table.set_header_row_style({ 'color': '#fff', 'background-color': '#48a6fb', 'font-size': '18px', }) # 覆盖表头单元格字体样式 table.set_header_cell_style({ 'padding': '15px', }) html = table.to_html() return html
def list_to_html_table(in_list): table = HTMLTable(caption="表格的标题") title = in_list[0] # print(temp) table.append_header_rows((title, ())) content = in_list[1:] table.append_data_rows(content) # 表格样式,即<table>标签样式 table.set_style({ 'border-collapse': 'collapse', 'word-break': 'keep-all', 'white-space': 'nowrap', 'font-size': '13px', 'font-family': 'Microsoft Yahei UI', }) # 表头样式 table.set_header_row_style({ 'font-size': '13px', }) # 统一设置所有单元格样式,<td>或<th> table.set_cell_style({ 'border-color': '#000', 'border-width': '1px', 'border-style': 'solid', 'padding': '3px', }) # 覆盖表头单元格字体样式 table.set_header_cell_style({ 'padding': '5px', }) # 遍历数据行,满足特定条件,行标记特殊颜色 for row in table.iter_data_rows(): if str(row[4].value) != "" and str(row[4].value).find("预计") == -1: row.set_style({ 'background-color': '#ccffcc', }) html = table.to_html() html = html.replace('\"', '\'') # print(html) return html
Description: Changelog: ''' from HTMLTable import ( HTMLTable, ) # 标题 table = HTMLTable(caption='果园收成表') # 表头行 table.append_header_rows(( ('名称', '产量 (吨)', '环比', ''), ('', '', '增长量 (吨)', '增长率 (%)'), )) # 合并单元格 table[0][0].attr.rowspan = 2 table[0][1].attr.rowspan = 2 table[0][2].attr.colspan = 2 # 数据行 table.append_data_rows(( ('荔枝', 11, 1, 10), ('芒果', 9, -1, -10), ('香蕉', 6, 1, 20), )) # 标题样式
from astroquery.gaia import Gaia from HTMLTable import HTMLTable table = HTMLTable(caption='Ten stars nearest sun') # item_list = ('name', 'source_id', 'parallax', 'ra', 'dec', 'ecl_lon', 'ecl_lat', # 'pm', 'pmra', 'pmdec', 'pseudocolour', 'phot_g_mean_flux', # 'phot_g_mean_mag', 'phot_bp_mean_flux', # 'phot_bp_mean_mag', 'phot_rp_mean_flux', # 'phot_rp_mean_mag', 'dr2_radial_velocity') item_list = ('name', 'source_id', 'parallax', 'distance', 'ra', 'dec', 'ecl_lon', 'ecl_lat', 'phot_g_mean_mag', 'phot_bp_mean_mag', 'phot_rp_mean_mag') table.append_header_rows((item_list, )) Gaia.ROW_LIMIT = 10 query = """SELECT * FROM gaiaedr3.gaia_source WHERE parallax >= 300 ORDER BY parallax ASC """ star_name = [ 'Epsilon Eridani (Ran)', 'Ross 248 (HH Andromedae)', 'Ross 154 (V1216 Sagittarii)', 'Luyten 726-8 B', 'Luyten 726-8 A', 'Sirius', 'Lalande 21185', 'Wolf 359 (CN Leonis)', "Barnard's Star (BD+04°3561a)", 'Proxima Centauri' ] assert len(star_name) == 10 job = Gaia.launch_job_async(query)
from GMM import GMM if __name__ == "__main__": print("\t============ Chap9 EM for GMM ============") ds = DS.DATAUtil() x_train, y_train = ds.load(True, r".\dataset.dat") model = GMM() model.train(x_train) y_pred = model.predict(x_train) y_train = ds.y_int2str(y_train) table = HTMLTable(caption='Iris Data Cluster') table.append_header_rows(( ('No.', 'A1', 'A2', 'A3', 'A4', 'Classification', ''), ('', '', '', '', '', 'Label-C', 'Predict-C'), )) table[0][0].attr.rowspan = 2 table[0][1].attr.rowspan = 2 table[0][2].attr.rowspan = 2 table[0][3].attr.rowspan = 2 table[0][4].attr.rowspan = 2 table[0][5].attr.colspan = 2 for i in range(x_train.shape[0]): table.append_data_rows( ((f"{i}", x_train[i, 0], x_train[i, 1], x_train[i, 2], x_train[i, 3], y_train[i], str(y_pred[i])), )) """ table.append_data_rows(( ('1', 5.1, 3.5, 1.4, 0.2, 'setosa', 'abc'),
def run(self): try: pythoncom.CoInitialize() date = str(datetime.today().date()) obj = Dispatch('Outlook.Application') mail = obj.CreateItem(0) mail.Subject = 'Report of Received CQCs ' + date to_list = [] cc_list = [] cc_list.extend(self.engTable[self.engTable['GM_RCV'] == 'Y'] ['EMAIL'].to_list()) for i, row in self.df.iterrows(): if row['PE'] in self.engTable['NAME'].values: r = self.engTable[self.engTable['NAME'] == row['PE']].iloc[0] email = r['EMAIL'] if email not in to_list: to_list.append(email) email = r['MANAGER_EMAIL'] if email not in cc_list: cc_list.append(email) atts = r['ATTENTION_NAME'] for att in atts.split(';'): if att != '': email = self.engTable[self.engTable['NAME'] == att]['EMAIL'].iloc[0] if email not in to_list: to_list.append(email) elif row['PE'] != '': name, email, mgr, mgr_email = self.cs.getFullInfo( row['PE']) if email != '' and (email not in to_list): to_list.append(email) if mgr_email != '' and (mgr_email not in cc_list): cc_list.append(mgr_email) if name != '' and email != '' and mgr != '' and mgr_email != '': try: self.engTable.loc[len(self.engTable)] = [ name, email, 'PE', mgr, mgr_email, '', '', '' ] self.engTable.to_csv('tables/EmployeeTable.csv', index_label=False, index=False) except Exception as err: print(err) if row['CQE'] in self.engTable['NAME'].values: r = self.engTable[self.engTable['NAME'] == row['CQE']].iloc[0] email = r['EMAIL'] if email not in to_list: to_list.append(email) email = r['MANAGER_EMAIL'] if email not in cc_list: cc_list.append(email) atts = r['ATTENTION_NAME'] for att in atts.split(';'): if att != '': email = self.engTable[self.engTable['NAME'] == att]['EMAIL'].iloc[0] if email not in to_list: to_list.append(email) elif row['CQE'] != '': name, email, mgr, mgr_email = self.cs.getFullInfo( row['CQE']) if email != '' and (email not in to_list): to_list.append(email) if mgr_email != '' and (mgr_email not in cc_list): cc_list.append(mgr_email) if name != '' and email != '' and mgr != '' and mgr_email != '': try: self.engTable.loc[len(self.engTable)] = [ name, email, 'CQE', mgr, mgr_email, '', '', '' ] self.engTable.to_csv('tables/EmployeeTable.csv', index_label=False, index=False) except Exception as err: print(err) mail.To = ';'.join(to_list) mail.CC = ';'.join(cc_list) self.df = self.df.astype(str) table_cleared = self.df[self.df['Checkout'] == 'Y'] table_underway = self.df[(self.df['Status'] == 'P') & (self.df['Checkout'] == '')] table_ready = self.df[(self.df['Status'] == 'R') & (self.df['Checkout'] == '')] table_store = self.df[(self.df['Status'] == 'S') & (self.df['Checkout'] == '')] bg = ['#f9b500', '#7bb1db', '#c9d200', '#00a4a7'] output = [table_ready, table_underway, table_cleared, table_store] for i in range(4): t = HTMLTable() l = list() t.append_header_rows([output[i].columns.values.tolist()]) if len(output[i]) == 0: output[i] = None else: for index, row in output[i].iterrows(): l.append(row.to_list()) t.append_data_rows(l) t.set_cell_style({ 'border-color': '#aaaaaa', 'border-width': '1px', 'border-style': 'solid', 'border-collapse': 'collapse', 'padding': '4' }) t.set_header_row_style({'background-color': bg[i]}) output[i] = t.to_html() mail.HTMLBody = '<p>Dear Team,</p><p>Please refer to the list(s) of the ' + str( len(self.df) ) + ' CQC(s) that have been handled at the reception center today. For the un-checkout CQCs, please arrange resources for sample preparation and verification according to the instruction. For the CQCs that need sample cleaning, notification emails will be sent to the responsible engineers when the CQCs are ready to collect.<p> </p>' + ( ('<p style="color:black">' + str(len(table_ready)) + ' CQC(s) are waiting to be collected.</p>' + output[0]) if output[0] != None else '<p style="color:black">No CQC is waiting to be collected.</p>' ) + ( ('<p style="color:black">' + str(len(table_underway)) + ' CQC(s) are under preparation.</p>' + output[1]) if output[1] != None else '<p style="color:black">No CQC is under preparation.</p>' ) + ( ('<p style="color:black">' + str(len(table_cleared)) + ' CQC(s) have been checked out.</p>' + output[2]) if output[2] != None else '<p style="color:black">No CQC was checked out.</p>' ) + ( ('<p style="color:black">' + str(len(table_store)) + ' CQC(s) have been stored.</p>' + output[3]) if output[3] != None else '<p style="color:black">No CQC was stored.</p>' ) + '<p> </p><p> </p><p>If you are not the responsible contact for the product, please contact Van Fan for correction.</p><p> </p><p>Best Regards,</p><p>Tianjin Business Line Quality</p><p>CQC Operation Tracking System</p>' mail.Save() self.result_signal.emit('100') except Exception as err: print(err) self.result_signal.emit('101')
def create_HTML(): # 标题 table = HTMLTable(caption='测试报告') # 表头行 table.append_header_rows(( ('名称', '产量 (吨)', '环比', ''), ('', '', '增长量 (吨)', '增长率 (%)'), )) # 合并单元格 table[0][0].attr.rowspan = 2 table[0][1].attr.rowspan = 2 table[0][2].attr.colspan = 2 # 数据行 table.append_data_rows(( ('荔枝', 11, 1, 10), ('芒果', 9, -1, -10), ('香蕉', 6, 1, 20), )) # 标题样式 table.caption.set_style({ 'font-size': '15px', }) # 表格样式,即<table>标签样式 table.set_style({ 'border-collapse': 'collapse', 'word-break': 'keep-all', 'white-space': 'nowrap', 'font-size': '14px', }) # 统一设置所有单元格样式,<td>或<th> table.set_cell_style({ 'border-color': '#000', 'border-width': '1px', 'border-style': 'solid', 'padding': '5px', }) # 表头样式 table.set_header_row_style({ 'color': '#fff', 'background-color': '#48a6fb', 'font-size': '18px', }) table.set_header_cell_style({ 'padding': '15px', }) # 调小次表头字体大小 table[1].set_cell_style({ 'padding': '8px', 'font-size': '15px', }) # 遍历数据行,如果增长量为负,标红背景颜色 for row in table.iter_data_rows(): if row[2].value < 0: row.set_style({ 'background-color': '#ffdddd', }) html = table.to_html() with open("test.html", "w+") as f: f.write(html)
def build_excel_html(): from HTMLTable import HTMLTable # 生成表名 table = HTMLTable(caption='运维巡检系统本周报表\n') # 生成首行 table.append_header_rows((('事件', '对象', '触发条件', '当前值'), )) # 获取规则id对应异常数量的dict all_count_dict = get_method_count() # 将方法列为列表 column0 = list(all_count_dict) for j in column0: sql = "select id, method_name, reference_value, compare from %s where expression_name = '%s'" % ( rules_table, j) expression_id = mysql_conn.select(sql)[0][0] method_name = mysql_conn.select(sql)[0][1] reference_value = mysql_conn.select(sql)[0][2] compare = mysql_conn.select(sql)[0][3] sql = "select comments from %s where name = '%s'" % (methods_table, method_name) comments = mysql_conn.select(sql)[0][0] sql = "select gps_object, value from %s where expression_id = '%s' and status = 1" % ( problem_table, expression_id) result = mysql_conn.select(sql) for bb in range(0, all_count_dict[j]): gps_object = result[bb][0] value = result[bb][1] table.append_data_rows( ((comments, gps_object, str(compare) + str(reference_value), value), )) # 标题样式 table.caption.set_style({ 'font-size': '20px', }) # 表格样式,即<table>标签样式 table.set_style({ 'border-collapse': 'collapse', 'word-break': 'keep-all', 'white-space': 'nowrap', 'font-size': '14px', }) # 统一设置所有单元格样式,<td>或<th> table.set_cell_style({ 'border-color': '#000', 'border-width': '1px', 'border-style': 'solid', 'padding': '5px', 'text-align': 'center', # 单元格居中 }) # 表头样式 table.set_header_row_style({ 'color': '#fff', 'background-color': '#48a6fb', 'font-size': '18px', }) # 覆盖表头单元格字体样式 table.set_header_cell_style({ 'padding': '15px', }) html = table.to_html() return html
def gen_html(): # 标题 table = HTMLTable(caption='商品销量表') # 表头行 table.append_header_rows(( ('名称', '销量(件)', '环比', ''), ('', '', '增长量 (件)', '增长率 (%)'), )) # 合并单元格 table[0][0].attr.rowspan = 2 table[0][1].attr.rowspan = 2 table[0][2].attr.colspan = 2 # 数据行 table.append_data_rows(( ('牛仔裤', 110, 10, 20), ('T恤', 20, 20, -9), ('Nike鞋', 50, 22, 10), )) # 标题样式 table.caption.set_style({ 'font-size': '15px', }) # 表格样式,即<table>标签样式 table.set_style({ 'border-collapse': 'collapse', 'word-break': 'keep-all', 'white-space': 'nowrap', 'font-size': '14px', }) # 统一设置所有单元格样式,<td>或<th> table.set_cell_style({ 'border-color': '#000', 'border-width': '1px', 'border-style': 'solid', 'padding': '5px', }) # 表头样式 table.set_header_row_style({ 'color': '#fff', 'background-color': '#48a6fb', 'font-size': '18px', }) # 覆盖表头单元格字体样式 table.set_header_cell_style({ 'padding': '15px', }) # 调小次表头字体大小 table[1].set_cell_style({ 'padding': '8px', 'font-size': '15px', }) # 遍历数据行,如果增长量为负,标红背景颜色 for row in table.iter_data_rows(): if row[2].value < 0: row.set_style({ 'background-color': '#ffdddd', }) html = table.to_html() print(html)