Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom stylesheet to html table #16

Closed
domino-blake opened this issue Sep 12, 2019 · 2 comments
Closed

Add custom stylesheet to html table #16

domino-blake opened this issue Sep 12, 2019 · 2 comments
Assignees

Comments

@domino-blake
Copy link

Is it possible to add a custom stylesheet to html table?
Looked through the docs but wasn't able to see any clear instructions

@thombashi thombashi self-assigned this Jan 1, 2020
@thombashi
Copy link
Owner

Unfortunately, there is no functionality to do that currently.
Did you expect an interface that can specify a class name to output table tags? or something else?
Would you describe your expectations for more detail?

@thombashi
Copy link
Owner

@domino-blake
You can output CSS with HtmlTablewriter/CssTablewriter of pytablewriter 0.51.0 or later.
I'm not so sure this is what you expected though.

Example:

from pytablewriter import HtmlTableWriter

writer = HtmlTableWriter()
writer.table_name = "write_css"
writer.headers = ["int"]
writer.value_matrix = [[1]]
writer.write_table(write_css=True)

Output:

<style type="text/css">
    .write-css thead th:nth-child(1) {
        text-align: left;
    }
    .write-css tbody tr:nth-child(1) td:nth-child(1) {
        text-align: right;
    }
</style>
<table class="write-css" id="write_css">
    <caption>write_css</caption>
    <thead>
        <tr>
            <th>int</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>1</td>
        </tr>
    </tbody>
</table>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants