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

Asked

Viewed 673 times

2

How can I perform line breaking of a String with multiple cities concatenated to each state listed in an Excel cell exported in VB.NET and using Officeopenxml and Officeopenxml.Drawing.

Excerpt from the Spreadsheet: inserir a descrição da imagem aqui

Excerpt from the Code:

Dim nome_cidade As String = "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

1 answer

1

For such just replace where you are adding the <br /> for 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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.