Coder Social home page Coder Social logo

go-docx's Introduction

cover

Hi I'm Lukas

I want to change the world, give me the source code.

  • 🔬 I'm a M.Sc. in Computer Science.
  • 🔭 I’m currently working as Cloud Platform Engineer @inovex.
  • 👯 I love to develop software in my spare time, preferably open source.
  • 💻 Long time Linux fanboy.
  • ⚒️ I love to craft code in Golang.
  • 🐱 I do have two cats. They are really bad at pair programming tho (just look at the picture above to see the enthusiasm 😆).

go-docx's People

Contributors

gsbecerrag avatar lukasjarosch avatar sashamelentyev avatar zhasulan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

go-docx's Issues

Documents corrupted

On certain Microsoft Office versions, the rendered documents can only be opened after repairing them.

This issue needs to be investigated and resolved

function to get all placeholders in file

I am working on tool to use docx files as templates and the package have cut a lot of effort so thanks for your work
i think it would be better if there was a function that return an array with all placeholders in template or even better map with place holder with n of occurrence of the place holder
thanks in advance

PlaceholderMap (or Word) does not adhere to '\n' character

It does not seem to be possible to add a 'newline' character (\n or \r\n if you will) within a table cell of a Word table.

Current formatting:

var location string
	for _, host := range res.HostInfo {
		for i := range host.Ports {
			location += (host.Address + ":" + host.Ports[i].PortNumber + " (" + host.Ports[i].Proto + ")" + "\n") // also tried \r\n and \t
		}
	}

Output seems only to add some kind of whitespace within the cell:

locations1

This might be the dumbest issue ever written, so sorry beforehand. Is there any way to enforce this newline?

Error if placeholder has leading or tailing whitespace(-s) inside of delimiters

Example:

  • My docx template I have { organization} (pay attention to leading whitespace) and {address} placeholders
  • My placeholder map have organization and address fields

Than program falls with error:

...: not all placeholders were replaced, want=2, have=1

I tried to run with debugger to see which behaviour going on under the hood. I found out that stripXmlTags method deletes whitespaces from placeholder. But inside of docx.Open() method you have another behaviour which does not trim whitespaces.

This results to placeholders dismatch and throwing an error.

Is it possible to avoid line break collapse?

Hello,
I'm trying to use a value that's a literal string with some line breaks in it. Currently the line breaks gets collapsed and the string no longer looks the way I expect it to.

docx.PlaceholderMap{
   "PLACEHOLDER_KEY":    `here is my string
with different 
items on 
multiple lines
`,
}

turns into
here is my string with different items on multiple lines

Is it possible to preserve line breaks in placeholder values?

Document tag truncated

The generated document is invalid if the template file contains a spell-checking mark (curly red underline).

image

Word error message is as follows:
image

Data in word\document.xml is truncated:
w:rsidRDefault="00DB7D3C"/><w:sectPr w:rsidR="00DB7D3C"><w:pgSz w:w="11906" w:h="16838"/><w:pgMar w:top="1417" w:right="1417" w:bottom="1134" w:left="1417" w:header="708" w:footer="708" w:gutter="0"/><w:cols w:space="708"/><w:docGrid w:linePitch="360"/></w:sectPr></w:body></w:docum

Please see content of template.docx and test.docx file attached.

test.docx
template.docx

Inserting of new runs / paragraphs / docx-files

Only replacing placeholders might not always be enough. One might face the task to insert a sub-template into the document.

This currently cannot be done since replacements will always occur inside <w:t> tags but new content will most likely be added on a paragraph (<w:p>) level.

Many paragraphs.

Hi,
Is it possible to replace the placeholder with array of strings, where each array member would be in a new paragraph? Maybe it's possible to do it some other way?
If so, maybe you can give an example.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.