Visitar URL original
docs: Update front-page example for table style · Issue #164 · python-openxml/python-docx · GitHub
Skip to content

docs: Update front-page example for table style #164

Description

@trampas

it appears that the default table style has change, specifically the code on front page does not create tables that look like example.

Activity

  1. changed the title [-]Table Style changed[/-] [+]docs: Update front-page example for table style[/+] on Mar 26, 2015
  2. scanny commented on Mar 26, 2015

    @scanny
    Contributor

    Yes, this had to go when we added styles support in release 0.8.0. Trying to be "helpful" by picking a table style caused problems when folks used a starting document that didn't have that style defined. You can achieve the same result now with this:

    document.add_table(rows, cols, 'Light Shading Accent 1')

    Note that if that style is not defined in your document, python-docx will raise an exception.

    I'll leave this open to update the front-page example.

  3. trampas commented on Mar 26, 2015

    @trampas
    Author

    Thanks!

    Also on the style doing table.style='Light Shading Accent 1' will create a
    depreciated warning, thus the documents might need updated to indicate the
    new way...

    On Thu, Mar 26, 2015 at 3:14 PM, Steve Canny notifications@github.com
    wrote:

    Yes, this had to go when we added styles support in release 0.8.0. Trying
    to be "helpful" by picking a table style caused problems when folks used a
    starting document that didn't have that style defined. You can achieve the
    same result now with this:

    document.add_table(rows, cols, 'Light Shading Accent 1')

    Note that if that style is not defined in your document, python-docx will
    raise an exception.

    I'll leave this open to update the front-page example.

    —
    Reply to this email directly or view it on GitHub
    #164 (comment)
    .

  4. scanny commented on Mar 26, 2015

    @scanny
    Contributor

    I can't reproduce that behavior @trampas.

    Although I do get a deprecation warning for this:

    table = document.add_table(2, 2, 'LightShading-Accent1')

    The former is the table style name, where the latter is the table style id. The deprecation warning is triggered by using the style id, which will not be supported going forward.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions