Excel cell with several lines from .Net

1

I am dumping information from a SQL Server table into an Excel file.

One of the fields that I overturn is a field of observations that may contain line changes.

If I dump the information without more the result is the following:

oRng = oSheet_Electronicos.Range(String.Format("{0}{1}", columna(nColumnaIniciobloque), nFila), String.Format("{0}{1}", columna(nColumnaFinbloque), nFila))
dataStr = New String(0, 1) {} ''2 Valores
dataStr(0, 0) = _fila("Documento")
dataStr(0, 1) = _fila("Observaciones")
oRng.WrapText = False
oRng.Value2 = dataStr
oRng.NumberFormat = "@"
oRng.NumberFormatLocal = "@"
oRng.EntireColumn.AutoFit()

The line change is done after the first "." so the idea is that on the first line write "THIS IS THE FIRST LINE." and in the second write "THIS IS THE SECOND LINE.".

This only happens after assigning the value to the cell by doing:

oRng = oSheet_Electronicos.Range(String.Format("{0}{1}", columna(nColumnaIniciobloque), nFila), String.Format("{0}{1}", columna(nColumnaFinbloque), nFila))
oRng.WrapText = False
oRng.EntireColumn.AutoFit()
oRng.WrapText = True
oRng.EntireColumn.AutoFit()

I find it strange to have to do this to the cell so that he finds out about the change.

Any ideas?

    
asked by Jaime Capilla 08.03.2017 в 12:31
source

1 answer

-2

Concatenates the control character that results in the function

CARACTER(10)

and it will give you a break line.

Ex:

mistring1 + CARACTER(10) + mistring2 + CARACTER(10) 

Result:

mistring1
mistring2
    
answered by 16.03.2017 в 22:37