'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.



Solution 1:[1]

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,
            },
        },
    )

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1