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 : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Excel exporting line break

Thread ID:





100473 Aug 9,2011 03:29 PM UTC Aug 11,2011 07:21 AM UTC ASP.NET Web Forms (Classic) 2
Tags: XlsIO
victor elizondo
Asked On August 9, 2011 03:29 PM UTC

Hello everybody.

I have a problem.

I have a code snippet:
this.GridGroupingControl1.DataSource = DATATABLE;

GridExcelExport excel = new GridExcelExport(this.GridGroupingControl1, "Namefile.xls");

excel.ExportNestedTable = true;

I have syncfusion version

GridGroupingControl1 is a Syncfusion Control

In that syncfusion grid I have a row with information with a line break ( the image about it is attached file) but when EXPORTING to Excel ( in the image says IMPORTING, sorry) doesn't respect the line break in the XLS file.

I don't know if in syncfusion exists a WRAPTEXT property for XLS sheet, or in SQL I must save in a register an ALT-ENTER key combination to make the line break( Actually I don't know how to do this), so this is my request for you.

Best Regards, hope you can help me.

line break_a174f768_c0596675.zip

victor elizondo
Replied On August 11, 2011 01:09 AM UTC

I've founded a solution to my problem I want to share it.


ExcelEngine engine = new ExcelEngine();
IApplication application = engine.Excel;
IWorkbook workbook = application.Workbooks.Create();
IWorksheet sheet = workbook.Worksheets[0];

//This is for showing the datatable dtExcel HEADER in the excel
char Numero = '1';
char Letra = 'A';

for (int g = 0; g < dtExcel.Columns.Count; g++)
string cell = Letra.ToString() + Numero.ToString();
sheet.Range[cell].Text = dtExcel.Columns[g].ColumnName.Replace("
", "");
sheet.Range[cell].CellStyle.WrapText = true;
sheet.Range[cell].CellStyle.Color = System.Drawing.Color.MediumSeaGreen;
sheet.Range[cell].CellStyle.Font.Bold = true;
sheet.Range[cell].CellStyle.Font.FontName = "Verdana";
sheet.Range[cell].CellStyle.Font.Size = 8;

//This is for showing the datatable dtExcel in the excel
Numero = '2';
for (int i = 0; i < dtExcel.Rows.Count; i++)

Letra = 'A';
for (int j = 0; j < dtExcel.Columns.Count; j++)
string cell = Letra.ToString() + Numero.ToString();
sheet.Range[cell].Text = dtExcel.Rows[i][j].ToString().Replace("
", "");
sheet.Range[cell].CellStyle.WrapText = true;
sheet.Range[cell].CellStyle.Font.FontName = "Verdana";
sheet.Range[cell].CellStyle.Font.Size = 8;

if (dtExcel.Rows[i][j].ToString().Length >= 20 && dtExcel.Rows[i][j].ToString().Length <= 50)
sheet.Range[cell].ColumnWidth = 15;

if (dtExcel.Rows[i][j].ToString().Length >= 50 && dtExcel.Rows[i][j].ToString().Length <= 100)
sheet.Range[cell].ColumnWidth = 20;

if (dtExcel.Rows[i][j].ToString().Length >= 100)
sheet.Range[cell].ColumnWidth = 50;

//Increasing the ABC letters
//Increasing the numbers (1,2,3,4...)

workbook.SaveAs(Request.PhysicalApplicationPath + @"FileName.xls");

engine.ThrowNotSavedOnDestroy = true;
System.Diagnostics.Process.Start(Request.PhysicalApplicationPath + @"FileName.xls");



Sridhar [Syncfusion]
Replied On August 11, 2011 07:21 AM UTC

Hi victor,

Thank you very much for using Syncfusion products.

We are very happy to see that your problem is solved at your side specified in your previous update. Please let us know if you require any further clarifications , get back to us with the required sample file and we are happy to help you out.



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.

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