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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

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

Thread ID:

Created:

Updated:

Platform:

Replies:

150937 Jan 24,2020 08:39 PM UTC Jan 27,2020 11:49 AM UTC WinForms 1
loading
Tags: Spreadsheet
Spotty
Asked On January 24, 2020 08:39 PM UTC

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

Kanimozhi Bharathi [Syncfusion]
Replied On 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 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon