Title: Table cells with form fields seem to be parsed incorrectly · Issue #689 · python-openxml/python-docx · GitHub
Open Graph Title: Table cells with form fields seem to be parsed incorrectly · Issue #689 · python-openxml/python-docx
X Title: Table cells with form fields seem to be parsed incorrectly · Issue #689 · python-openxml/python-docx
Description: Create and modify Word documents with Python. Contribute to python-openxml/python-docx development by creating an account on GitHub.
Open Graph Description: Create and modify Word documents with Python. Contribute to python-openxml/python-docx development by creating an account on GitHub.
X Description: Create and modify Word documents with Python. Contribute to python-openxml/python-docx development by creating an account on GitHub.
Opengraph URL: https://github.com/python-openxml/python-docx
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Table cells with form fields seem to be parsed incorrectly","articleBody":"Hi,\r\n\r\nIm using python-docx to extract info out of docx files. My code iterates over a 2 column table with where the first column is the \"key\" and the second column the \"value\". \r\n\r\nHowever, cells which have word \"form fields\" in them are not included in the table, which results in an incorrect table setup. My table in word looks like this\r\n\r\n```\r\nDate 01-01-2019 (not a form field)\r\nInitals A.B.\r\nName TestName\r\nPC 111111\r\n````\r\n\r\nIn the second column, all values are form fields except the first one. I have the following code to debug this:\r\n\r\n```\r\nfor i in range(0,14):\r\n print doc.tables[0]._cells[i].text\r\n```\r\n\r\nWhich shows me:\r\n```\r\nDate\r\n01-01-2019\r\nInitials\r\nName\r\nPC\r\n...\r\n```\r\n\r\nSo it seems that something goes wrong while parsing the form fields in the table and instead of inserting an empty field or a blank or whatever, it just moves on with the next cell and creates a corrupted table structure.\r\n\r\nMy questions\r\n1) Are there any plans for supporting form fields in the near future?\r\n2) Wouldn't it be better if the library throws an exception or somehow indicates something went wrong with parsing, instead of building a corrupted internal table state?\r\n\r\nFor reference, this is how a row looks like in XML without form fields:\r\n\r\n```\r\n\t\t\t\t\u003cw:tc>\r\n\t\t\t\t\t\u003cw:tcPr>\r\n\t\t\t\t\t\t\u003cw:cnfStyle w:evenHBand=\"0\" w:evenVBand=\"0\" w:firstColumn=\"1\" w:firstRow=\"0\" w:firstRowFirstColumn=\"0\" w:firstRowLastColumn=\"0\" w:lastColumn=\"0\" w:lastRow=\"0\" w:lastRowFirstColumn=\"0\" w:lastRowLastColumn=\"0\" w:oddHBand=\"0\" w:oddVBand=\"0\" w:val=\"001000000000\"/>\r\n\t\t\t\t\t\t\u003cw:tcW w:type=\"dxa\" w:w=\"1951\"/>\r\n\t\t\t\t\t\u003c/w:tcPr>\r\n\t\t\t\t\t\u003cw:p w14:paraId=\"42042D40\" w14:textId=\"77777777\" w:rsidR=\"008014F0\" w:rsidRDefault=\"008014F0\">\r\n\t\t\t\t\t\t\u003cw:r>\r\n\t\t\t\t\t\t\t\u003cw:t xml:space=\"preserve\">Date \u003c/w:t>\r\n\t\t\t\t\t\t\u003c/w:r>\r\n\t\t\t\t\t\u003c/w:p>\r\n\t\t\t\t\u003c/w:tc>\r\n\t\t\t\t\u003cw:tc>\r\n\t\t\t\t\t\u003cw:tcPr>\r\n\t\t\t\t\t\t\u003cw:tcW w:type=\"dxa\" w:w=\"6496\"/>\r\n\t\t\t\t\t\u003c/w:tcPr>\r\n\t\t\t\t\t\u003cw:p w14:paraId=\"3548CF69\" w14:textId=\"64ED0FF3\" w:rsidP=\"000D46F4\" w:rsidR=\"008014F0\" w:rsidRDefault=\"003A3175\">\r\n\t\t\t\t\t\t\u003cw:pPr>\r\n\t\t\t\t\t\t\t\u003cw:tabs>\r\n\t\t\t\t\t\t\t\t\u003cw:tab w:pos=\"1760\" w:val=\"left\"/>\r\n\t\t\t\t\t\t\t\u003c/w:tabs>\r\n\t\t\t\t\t\t\t\u003cw:cnfStyle w:evenHBand=\"0\" w:evenVBand=\"0\" w:firstColumn=\"0\" w:firstRow=\"0\" w:firstRowFirstColumn=\"0\" w:firstRowLastColumn=\"0\" w:lastColumn=\"0\" w:lastRow=\"0\" w:lastRowFirstColumn=\"0\" w:lastRowLastColumn=\"0\" w:oddHBand=\"0\" w:oddVBand=\"0\" w:val=\"000000000000\"/>\r\n\t\t\t\t\t\t\u003c/w:pPr>\r\n\t\t\t\t\t\t\u003cw:r>\r\n\t\t\t\t\t\t\t\u003cw:t>17-4-2019\u003c/w:t>\r\n\t\t\t\t\t\t\u003c/w:r>\r\n\t\t\t\t\t\u003c/w:p>\r\n\t\t\t\t\u003c/w:tc>\r\n\t\t\t\u003c/w:tr>\r\n```\r\n\r\n\r\nAnd this is how it looks like with a form field\r\n\r\n```\r\n\u003cw:tr w14:paraId=\"7459588F\" w14:textId=\"77777777\" w:rsidR=\"00382944\" w:rsidRPr=\"00A21D4E\" w:rsidTr=\"00D85E3F\">\r\n\t\t\t\t\u003cw:tc>\r\n\t\t\t\t\t\u003cw:tcPr>\r\n\t\t\t\t\t\t\u003cw:cnfStyle w:evenHBand=\"0\" w:evenVBand=\"0\" w:firstColumn=\"1\" w:firstRow=\"0\" w:firstRowFirstColumn=\"0\" w:firstRowLastColumn=\"0\" w:lastColumn=\"0\" w:lastRow=\"0\" w:lastRowFirstColumn=\"0\" w:lastRowLastColumn=\"0\" w:oddHBand=\"0\" w:oddVBand=\"0\" w:val=\"001000000000\"/>\r\n\t\t\t\t\t\t\u003cw:tcW w:type=\"dxa\" w:w=\"1951\"/>\r\n\t\t\t\t\t\u003c/w:tcPr>\r\n\t\t\t\t\t\u003cw:p w14:paraId=\"552E8CDB\" w14:textId=\"2A99DF2E\" w:rsidR=\"00382944\" w:rsidRDefault=\"00382944\">\r\n\t\t\t\t\t\t\u003cw:r>\r\n\t\t\t\t\t\t\t\u003cw:t>Initials\u003c/w:t>\r\n\t\t\t\t\t\t\u003c/w:r>\r\n\t\t\t\t\t\u003c/w:p>\r\n\t\t\t\t\u003c/w:tc>\r\n\t\t\t\t\u003cw:sdt>\r\n\t\t\t\t\t\u003cw:sdtPr>\r\n\t\t\t\t\t\t\u003cw:alias w:val=\"Initials\"/>\r\n\t\t\t\t\t\t\u003cw:tag w:val=\"Initials\"/>\r\n\t\t\t\t\t\t\u003cw:id w:val=\"-1231847748\"/>\r\n\t\t\t\t\t\t\u003cw:placeholder>\r\n\t\t\t\t\t\t\t\u003cw:docPart w:val=\"5C7BC912E04B4694A18A39EF621426E0\"/>\r\n\t\t\t\t\t\t\u003c/w:placeholder>\r\n\t\t\t\t\t\t\u003cw:text/>\r\n\t\t\t\t\t\u003c/w:sdtPr>\r\n\t\t\t\t\t\u003cw:sdtEndPr/>\r\n\t\t\t\t\t\u003cw:sdtContent>\r\n\t\t\t\t\t\t\u003cw:tc>\r\n\t\t\t\t\t\t\t\u003cw:tcPr>\r\n\t\t\t\t\t\t\t\t\u003cw:tcW w:type=\"dxa\" w:w=\"6496\"/>\r\n\t\t\t\t\t\t\t\u003c/w:tcPr>\r\n\t\t\t\t\t\t\t\u003cw:p w14:paraId=\"75DE8320\" w14:textId=\"17F2800A\" w:rsidP=\"001B7C01\" w:rsidR=\"00382944\" w:rsidRDefault=\"003A3175\" w:rsidRPr=\"001B7C01\">\r\n\t\t\t\t\t\t\t\t\u003cw:pPr>\r\n\t\t\t\t\t\t\t\t\t\u003cw:cnfStyle w:evenHBand=\"0\" w:evenVBand=\"0\" w:firstColumn=\"0\" w:firstRow=\"0\" w:firstRowFirstColumn=\"0\" w:firstRowLastColumn=\"0\" w:lastColumn=\"0\" w:lastRow=\"0\" w:lastRowFirstColumn=\"0\" w:lastRowLastColumn=\"0\" w:oddHBand=\"0\" w:oddVBand=\"0\" w:val=\"000000000000\"/>\r\n\t\t\t\t\t\t\t\t\t\u003cw:rPr>\r\n\t\t\t\t\t\t\t\t\t\t\u003cw:lang w:val=\"en-US\"/>\r\n\t\t\t\t\t\t\t\t\t\u003c/w:rPr>\r\n\t\t\t\t\t\t\t\t\u003c/w:pPr>\r\n\t\t\t\t\t\t\t\t\u003cw:r>\r\n\t\t\t\t\t\t\t\t\t\u003cw:t>P.J.\u003c/w:t>\r\n\t\t\t\t\t\t\t\t\u003c/w:r>\r\n\t\t\t\t\t\t\t\u003c/w:p>\r\n\t\t\t\t\t\t\u003c/w:tc>\r\n\t\t\t\t\t\u003c/w:sdtContent>\r\n\t\t\t\t\u003c/w:sdt>\r\n\t\t\t\u003c/w:tr>\r\n```\r\n\r\nThanks ","author":{"url":"https://github.com/HenriHa","@type":"Person","name":"HenriHa"},"datePublished":"2019-06-24T20:41:35Z","url":"https://github.com/python-openxml/python-docx/issues/689"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/issues/:id(.:format) |
| route-controller | issues |
| route-action | show |
| fetch-nonce | v2:881a6703-c67d-3016-987c-04394cdce1e0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B43E:2C0A92:80E55B:94C909:6AFF6589 |
| html-safe-nonce | 15ca099e6b4a9909024a28a9c039bf604268d221df3a4568e1483afda5b424f3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNDNFOjJDMEE5Mjo4MEU1NUI6OTRDOTA5OjZBRkY2NTg5IiwidmlzaXRvcl9pZCI6IjIyODIwNTQ1MTg1OTYxMzQyODEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 0d2f961bb32546798d77f2d374f3a7994fa1dd883aa2dd33706e04822caa5501 |
| hovercard-subject-tag | repository:13592924 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/python-openxml/python-docx/issues/689 |
| twitter:image | https://opengraph.githubassets.com/ceb1727a713c057bb7edbfdc9dd3986b39dc6df234452ba5ae1eacc91a80dc31/python-openxml/python-docx |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ceb1727a713c057bb7edbfdc9dd3986b39dc6df234452ba5ae1eacc91a80dc31/python-openxml/python-docx |
| og:image:alt | Create and modify Word documents with Python. Contribute to python-openxml/python-docx development by creating an account on GitHub. |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 41b58589a1c4eda1e3c8904144a412b88ca4455f63ca2ad3629f2e9f3c3a1d12 |
| turbo-cache-control | no-cache |
| go-import | github.com/python-openxml/python-docx git https://github.com/python-openxml/python-docx.git |
| octolytics-dimension-user_id | 3403760 |
| octolytics-dimension-user_login | python-openxml |
| octolytics-dimension-repository_id | 13592924 |
| octolytics-dimension-repository_nwo | python-openxml/python-docx |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 13592924 |
| octolytics-dimension-repository_network_root_nwo | python-openxml/python-docx |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8968d6d6acc65d74e4df332d23932dd3fd0502a4 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width