How to perform line breaking of a String inside a cell in Excel with VB.NET?

0

How can I perform the line break of a String with multiple cities concatenated for each state listed in a cell of an Excel exported in VB.NET and using OfficeOpenXml and OfficeOpenXml.Drawing.

Spreadsheet Excerpt:

CodeSnippet:

Dimnome_cidadeAsString="São Paulo < br/> Guarulhos <br /> Campinas"
ws.Cells(cod_linha, cod_coluna).Value = nome_cidade                                                                ws.Cells(cod_linha, cod_coluna).StyleName = txt_estilo
cod_coluna += 1
    
asked by anonymous 26.05.2017 / 16:45

1 answer

1

To do this simply replace where you are adding <br /> to Environment.NewLine

Example:

Dim nome_cidade As String = string.Format("São Paulo {0} Guarulhos {0} Campinas", Environment.NewLine)
ws.Cells(cod_linha, cod_coluna).Value = nome_cidade                                                                
ws.Cells(cod_linha, cod_coluna).StyleName = txt_estilo
cod_coluna += 1
    
26.05.2017 / 17:15