Skip to content

Determine the overall placement of tables #222

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

Closed
andcor opened this issue Oct 26, 2015 · 3 comments
Closed

Determine the overall placement of tables #222

andcor opened this issue Oct 26, 2015 · 3 comments

Comments

@andcor
Copy link

andcor commented Oct 26, 2015

Hi
I'm working on a python script which should be able to delete specific tables and paragraphs from a docx document. But I have a problem in that I cannot find out how to determine where in a document (relative to the paragraphs) a table is placed. Therefore I will have trouble finding and deleting the surrounding paragraphs after I have located a table that needs to be removed.
Is there any way to detect the flow of the document?

I have looked at the paragraph._p structure because issue #156 shows that this could be used to move a table in between specific paragraphs using the addnext() method. However, the getnext function of all my paragraphs seem to point to other paragraphs.

@scanny
Copy link
Contributor

scanny commented Oct 28, 2015

@andcor: I think what you're looking for is this: #40

It's been a while since I've looked at it and these workarounds tend to be a bit brittle since they depend on internals that are subject to change.

But why don't you have a look and see what you can do. If it works, let me know; if it doesn't and you fix it, let me know too and I'll update the snippet. If you get stuck let me know and I'll see if I can help things along :)

@andcor
Copy link
Author

andcor commented Oct 29, 2015

Hi.
That were exactly what I wanted. Now I can begin rewriting my code to remove all the workarounds that I needed to implement to overcome the obsticle that I didn't know the structure of the document.

Thanks and thanks for all the great work you have done with this package.

@scanny
Copy link
Contributor

scanny commented Oct 29, 2015

Glad to hear it worked out @andcor :)

@scanny scanny closed this as completed Oct 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants