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

Cannot insert table correctly #483

Closed
dreddsa5dies opened this issue Feb 6, 2023 · 3 comments
Closed

Cannot insert table correctly #483

dreddsa5dies opened this issue Feb 6, 2023 · 3 comments

Comments

@dreddsa5dies
Copy link

Description

Cannot insert table correctly.
I looked issue, but not work for me.

Expected Behavior

Insert table after the paragraph

Actual Behavior

the table inserts after all paragraph

para := doc.InsertParagraphAfter(p)

	for _, docum := range docs {
		para = doc.InsertParagraphAfter(para)
		run := para.AddRun()
		run.Properties().SetBold(true)
		run.AddText("Name " + docum.Name)

		para = doc.InsertParagraphAfter(para)
		_ = para.AddRun()

		for _, mAndT := range docum.Data {
			para = doc.InsertParagraphAfter(para)
			run := para.AddRun()
			run.AddText("Operation " + mAndT.Name)

			para = doc.InsertParagraphAfter(para)
			_ = para.AddRun()

			// table
			table := doc.InsertTableAfter(para)
			table.Properties().SetWidthPercent(100) //nolint:gomnd
			borders := table.Properties().Borders()
			borders.SetAll(wml.ST_BorderSingle, color.Auto, measurement.Point)

			row := table.AddRow()
			row.AddCell().AddParagraph().AddRun().AddText("Tag")
			row.AddCell().AddParagraph().AddRun().AddText("Description")

			for _, tag := range mAndT.Tags {
				row = table.AddRow()
				row.AddCell().AddParagraph().AddRun().AddText(tag)
				row.AddCell().AddParagraph().AddRun().AddText(mAndT.Tags[tag])
			}
		}
	}
@github-actions
Copy link

github-actions bot commented Feb 6, 2023

Welcome! Thanks for posting your first issue. The way things work here is that while customer issues are prioritized,
other issues go into our backlog where they are assessed and fitted into the roadmap when suitable.
If you need to get this done, consider buying a license which also enables you to use it in your commercial products.
More information can be found on https://unidoc.io/

@sampila
Copy link
Collaborator

sampila commented Feb 8, 2023

Hi @dreddsa5dies,

Could you share a runnable code snippet?

Thanks.

@dreddsa5dies
Copy link
Author

Hi! Thank you for your promptness. The code is presented above.

        para := doc.InsertParagraphAfter(p)
	for _, docum := range docs {
		para = doc.InsertParagraphAfter(para)
		run := para.AddRun()
		run.Properties().SetBold(true)
		run.AddText("Name " + docum.Name)

		para = doc.InsertParagraphAfter(para)
		_ = para.AddRun()

		for _, mAndT := range docum.Data {
			para = doc.InsertParagraphAfter(para)
			run := para.AddRun()
			run.AddText("Operation " + mAndT.Name)
                        
                         // ----------------> I want table here

			para = doc.InsertParagraphAfter(para)
			_ = para.AddRun()

			// table
			table := doc.InsertTableAfter(para)
			table.Properties().SetWidthPercent(100) //nolint:gomnd
			borders := table.Properties().Borders()
			borders.SetAll(wml.ST_BorderSingle, color.Auto, measurement.Point)

			row := table.AddRow()
			row.AddCell().AddParagraph().AddRun().AddText("Tag")
			row.AddCell().AddParagraph().AddRun().AddText("Description")

			for _, tag := range mAndT.Tags {
				row = table.AddRow()
				row.AddCell().AddParagraph().AddRun().AddText(tag)
				row.AddCell().AddParagraph().AddRun().AddText(mAndT.Tags[tag])
			}
		}
	}

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