Quantcast
Channel: 🎛️ Dash - Plotly Community Forum
Viewing all articles
Browse latest Browse all 6271

HTML table with three columns with different alignments

$
0
0

I’m trying to generate an HTML table and have the first two columns with text-alignment right and the third column text-alignment center.

I generate my table as follows:

Generate a dataframe from a SQL query:

def Generate_DF(filepath):
sql_file = open(filepath)
sql_as_string = sql_file.read()
DF = pd.read_sql(sql_as_string, mydb)
sql_file.close()
return DF

Then generate html.Table from the dataframe:

def generate_table(dataframe, max_rows=26):
return html.Table(
# Header
[html.Tr([html.Th(col,style = {“font-size”:“12px”}) for col in dataframe.columns]) ] +
# Body
[html.Tr([ html.Td(dataframe.iloc[i][col], style = {“font-size”:“11px”}
) for col in dataframe.columns ] ) for i in range(min(len(dataframe), max_rows))])

It seems like the table I generate has a uniform style for each column.

Is it possible to assign different styles to different columns in the same html.table ?

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 6271

Trending Articles