We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Set a multiline text value within a cell results in losing the line breaks

I have a text value which is multiple lines (As shown in VS text visualizer  is attached image) and I'm trying to put the contents into a Syncfusion spreadsheet (I've shown in the other image what is in an Excel Cell).   Howver I seem to lose the multiple lines when I set the cell using the following call. (Attached Image 3)


                    Dim sfv = Chr(34) & s.ToString & Chr(34)  
                    cs.SetValueRowCol(sfv, irow,2)

Am I using the wrong method to set the value and hence losing the formatting or do I need to encode in a different way to preserve the multiple lines ?

Attachment: excelmulti1_3bd00e2e.zip

1 Reply

KB Kanimozhi Bharathi Syncfusion Team January 27, 2020 11:49 AM UTC

Hi Spotty, 
 
You can achieve your requirement of multi-line text in Spreadsheet by using AutofitRows method and you can set the cell value using SetCellValue method of SpreadsheetGrid. Please find the code example for reference, 
 
 
private void Spreadsheet_WorkbookLoaded(object sender, WorkbookLoadedEventArgs args) 
{ 
  var range = spreadsheet.ActiveSheet.Range[2, 2]; 
  var value = "Personal Jump\r\nPrevious Jump:Yes\r\nTest"; 
  spreadsheet.ActiveGrid.SetCellValue(range, value); 
  range.AutofitRows(); 
  spreadsheet.ActiveGrid.SetRowHeight(2, 2, spreadsheet.ActiveSheet.GetRowHeightInPixels(2)); 
} 
 
 
Please let me know if you need any clarifications. 
 
Regards, 
Kanimozhi B 


Loader.
Up arrow icon