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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Information in a XLS sheet

Thread ID:

Created:

Updated:

Platform:

Replies:

100189 Jul 12,2011 12:53 AM UTC Aug 11,2011 12:55 PM UTC ASP.NET Web Forms (Classic) 8
loading
Tags: XlsIO
victor elizondo
Asked On July 12, 2011 12:53 AM UTC

Hello

I need your help

As you can see in the attached image, I'm exporting a syncfusion grid to an excel file.

If I copy the text from a DataTable to this text editor:

"PRUEBA
PRUEBAENTER"

As you can see the text it's in two rows this because an Enter key that previously was typed.

The cuestion is: How can I do for export to the excel file but i want to export the information in two rows that information too, because currently is making it just in one two as you can see in the attached image.

The code I'm using for the exportation is this one:

---------------------------------------------------------------
this.GridGroupingControl1.DataSource = dt;

GridExcelExport excel = new GridExcelExport(this.GridGroupingControl1, StripTags(DisplayLabel(ReportP.Header)) + ".xls");

excel.ExportNestedTable = true;
excel.Export();
---------------------------------------------------------------

Its an aspx aplication in C# the code server in Visual Studio 2008.

Best Regards.



excel_c2a49eaf.zip

Ranjithkumar R G [Syncfusion]
Replied On July 14, 2011 01:45 PM UTC

Hi Victor,

Thanks for using Syncfusion products.

Your requirement of exporting text to excel in a single row with line break can be achieved by setting the WrapText property to true by overriding CopyStyles class. Please refer to the code-snippet below.

[CodeBehind]



public class mycustomExport : GridExcelExport
{
public mycustomExport(GridGroupingControl ggc, string fileName)
: base(ggc, fileName)
{

}

protected override void CopyStyles(GridTableCellStyleInfo style, int rowIdx, int colIdx)
{

IRange range = this.Sheet[rowIdx, colIdx];
//Condition to check whether the cell is Record and Column with the name 'Telephone'
if (style.TableCellIdentity.DisplayElement.Kind == DisplayElementKind.Record && style.TableCellIdentity.Column.Name == "Telephone")
{
range.WrapText = true;

}
}
}



Please let me know if you have any queries.

Regards,
Ranjithkumar.


victor elizondo
Replied On July 19, 2011 03:38 PM UTC

Hi Ranjithkumar

Thanks a lot, let me try with your code snippet and i will notice you I am in doubt.

Regards.
Víctor.


Sridhar N [Syncfusion]
Replied On July 20, 2011 04:07 AM UTC

Hi Victor,

Thanks for the update.

We will wait to hear from you.

Please let me know if you have any other questions or concerns.

Regards,
Sridhar.N


victor elizondo
Replied On August 3, 2011 05:28 PM UTC

Hello Ranjithkumar R G

Sorry for the late answer.

I'm having a little problem with your sample, I don't understanding it. It is possible that you could make a C# sample recreating the excel-break-line problem.

Best Regards.


Sridhar N [Syncfusion]
Replied On August 4, 2011 11:38 AM UTC

Hi Victor,

Thanks for the update.

We are unable to get your query. Could you please let us know what is your exact requirement in the sample?

Please let me know if you have any other questions or concerns.

Regards,
Sridhar.N


victor elizondo
Replied On August 4, 2011 10:22 PM UTC

Hello Sridhar N

Thanks for your fast answer.

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

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

excel.ExportNestedTable = true;
excel.Export();
---------------------------------------------------------------
I have syncfusion version 6.4.0.15.
I'M USING VISUAL STUDIO 2008 C#.

GridGroupingControl1 is a Syncfusion Control
(Syncfusion.Web.UI.WebControls.Grid.Grouping.GridGroupingControl)

In that syncfusion grid I have a row with information with a breakline ( the image about it is attached file) but when EXPORTING to Excel ( in the image says IMPORTING, sorry) doesn't respect the breakline 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 breakline ( 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.zip

victor elizondo
Replied On August 11, 2011 01:04 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
//sheet
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;
Letra++;
}

//This is for showing the datatable dtExcel in the excel
//sheet
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
Letra++;
}
//Increasing the numbers (1,2,3,4...)
Numero++;
}

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

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

----------------------------------------------------------------



Sridhar [Syncfusion]
Replied On August 11, 2011 12:55 PM UTC

Hi Victor,

The Forum 100473 is created for the above same query , and please follow up on the Forum 100473 for further updates.

Please let us know if you require any further clarifications.

Thanks,
Sridhar.S


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.

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

;