maxwell
maxwell

Reputation: 83

In golang, How can I output a newline within a cell in xlsx

I am developing in Go language, echo framework.

I am using package "github.com/tealeg/xlsx" and "github.com/Luxurioust/excelize" to create and output xlsx.

After writing \n in the cell and outputting it, if I set "Wrap text", a newline will be displayed.

But they cannot set "Wrap text" to xlsx in the program.

How can I do in order to see newline when I output it? Or is there a package to solve that problem?

Thanks.

Upvotes: 2

Views: 2817

Answers (2)

raphael.oester
raphael.oester

Reputation: 124

If you want to use only the excelize package, it is possible to do so natively using the WrapText attribute. Code sample :

    style, err := f.NewStyle(
        &excelize.Style{
            Alignment: &excelize.Alignment{
                Vertical: "center",
                WrapText: true,
            },
        },
    )

Upvotes: 2

maxwell
maxwell

Reputation: 83

"Github.com / tealeg / xlsx"
There is an Alignment type in the field of the Style type,
I found WrapText in an Alignment type field.
If set to true, I could "Wrap Text".

Upvotes: 3

Related Questions