Comments (3)
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/
from unioffice.
Hi @knight-ni,
Probably you can try out this code and see if this code help
// Copyright 2022 UniDoc ehf. All rights reserved.
package main
import (
"fmt"
"os"
"github.com/unidoc/unioffice/common/license"
"github.com/unidoc/unioffice/document"
"github.com/unidoc/unioffice/measurement"
"github.com/unidoc/unioffice/schema/soo/wml"
)
func init() {
// Make sure to load your metered License API key prior to using the library.
// If you need a key, you can sign up and create a free one at https://cloud.unidoc.io
err := license.SetMeteredKey(os.Getenv(`UNIDOC_LICENSE_API_KEY`))
if err != nil {
panic(err)
}
}
var mapList = []map[string][]string{
map[string][]string{"Preferred programming language": []string{"Go", "Java", "PHP"}},
map[string][]string{"Which sport you love to play": []string{"Football", "Basketball", "Diving"}},
map[string][]string{"Another information": []string{"This A", "This B", "This C"}},
}
func main() {
doc := document.New()
defer doc.Close()
// Create numbering definition.
nd := doc.Numbering.AddDefinition()
// Add level to number definition with decimal format.
lvl := nd.AddLevel()
lvl.SetFormat(wml.ST_NumberFormatDecimal)
lvl.SetAlignment(wml.ST_JcLeft)
lvl.Properties().SetLeftIndent(0.5 * measurement.Distance(1) * measurement.Inch)
// Sets the numbering level format.
lvl.SetText("%1.")
for i := 0; i < len(mapList); i++ {
for key, val := range mapList[i] {
para := doc.AddParagraph()
para.SetNumberingDefinition(nd)
para.SetNumberingLevel(0)
para.AddRun().AddText(key)
// Add level to previous number definition.
lvl := nd.AddLevel()
lvl.SetFormat(wml.ST_NumberFormatDecimal)
lvl.SetAlignment(wml.ST_JcLeft)
lvl.Properties().SetLeftIndent(0.5 * measurement.Distance(2) * measurement.Inch)
// Sets the numbering level format.
lvl.SetText("%1.%2")
for i := 0; i < len(val); i++ {
para := doc.AddParagraph()
para.SetNumberingDefinition(nd)
para.SetNumberingLevel(1)
para.AddRun().AddText(val[i])
// Add more nested numbering.
if i == 0 && key == "Another information" {
// Create children numbering definition.
ndChild := doc.Numbering.AddDefinition()
// Add level to number definition with upper letter format.
lvl := ndChild.AddLevel()
lvl.SetFormat(wml.ST_NumberFormatUpperLetter)
lvl.SetAlignment(wml.ST_JcLeft)
lvl.Properties().SetLeftIndent(0.5 * measurement.Distance(3) * measurement.Inch)
// Sets the numbering level format.
lvl.SetText("%1.)")
for i := 1; i < 5; i++ {
p := doc.AddParagraph()
p.SetNumberingLevel(0)
p.SetNumberingDefinition(ndChild)
run := p.AddRun()
run.AddText(fmt.Sprintf("More Level %d", i))
}
}
}
}
}
doc.SaveToFile("paragraph-numbering.docx")
}
Best regards,
Alip
from unioffice.
Hi @knight-ni,
We closing this issue, feel free to re-open this issue if this not resolved yet.
Best regards,
Alip
from unioffice.
Related Issues (20)
- nil pointer when convert docx to pdf HOT 9
- Runtime error extracting text from Word document HOT 3
- No text in document after converting a Word document to PDF HOT 3
- How to split a run and/or paragraph while preserving styling HOT 3
- No text extracted from PowerPoint file HOT 2
- how to get the real content contained in the specified bookmark HOT 2
- AppProperties.Pages() doesn't always return the correct number of pages HOT 2
- Convert `.docx` to `.pdf` misses images HOT 2
- How to get the page size for a Word doc? HOT 7
- is there support for adding a comment to a word doc? HOT 1
- Unit tests? HOT 3
- Why do proofreading errors occur HOT 5
- panic: runtime error: index out of range [0] with length 0 while converting docx to pdf HOT 3
- May I ask if there is an implementation for inserting chart elements into pptx? HOT 1
- How to insert a table at a specified location in a word document HOT 2
- Are all Unidoc projects fully open source? HOT 2
- Chinese characters, a null pointer error will occur. HOT 7
- Support with Pongo2 or Jinja2 templating feature HOT 1
- Text watermark does not support settings such as font, size, color,layout, etc,image watermark does not support scaling parameters HOT 2
- The build directory failed when wps opened HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from unioffice.