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

Export richtext with GridExcelConverterControl

Thread ID:

Created:

Updated:

Platform:

Replies:

44325 May 21,2006 01:52 PM UTC Aug 30,2008 12:50 AM UTC WinForms 16
loading
Tags: GridControl
Christian Lützenkirchen
Asked On May 21, 2006 01:52 PM UTC

Hi, I am exporting the contents of my virtual Syncfusion.Windows.Forms.Grid.GridControl (Library Version 4.2.0.26) with Syncfusion.GridExcelConverter.GridExcelConverterControl int an Excel-File. It works fine except that the contents of a richtext-cell is written with RTF-tags. Is this still a bug in the beta-version or is there a way to convert the contents of each cell into plain ascii-text? Regards, Christian

Administrator [Syncfusion]
Replied On May 22, 2006 06:59 AM UTC

Hi Christian, There is no built-in support for exporting the Richtext with GridExcelConverterContr. To export the ascii text of the Richtext, you need to assign the ascii text of the Richtext cell''s Rtf to a cell in a grid. Here is a code snippet. ///befor convert to excel format ,you need to change the cell text of the richtext cell. string text = this.gridControl1[1,1].Text; //(1,1) is rich text cell. RichTextBox rbox = new RichTextBox(); if(RichTextPaint.IsValidRtf(text )) { rbox.Rtf = text; this.gridControl1[1,1].Text = rbox.Text; } Syncfusion.GridExcelConverter.GridExcelConverterControl gecc = new Syncfusion.GridExcelConverter.GridExcelConverterControl(); SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "Files(*.xls)|*.xls"; saveFileDialog.DefaultExt = ".xls"; if(saveFileDialog.ShowDialog() == DialogResult.OK) { gecc.GridToExcel(this.gridControl1.Model, saveFileDialog.FileName); if(MessageBox.Show("Do you wish to open the xls file now?", "Export to Excel", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { Process proc = new Process(); proc.StartInfo.FileName = saveFileDialog.FileName; proc.Start(); } } ////After converting to excel format ,you need to change the text of richtext cell in a grid. this.gridControl1[1,1].Text = rbox.Rtf; rbox.Dispose(); Please let me know if this helps. Best Regards, Haneef

Christian Lützenkirchen
Replied On May 23, 2006 07:08 AM UTC

Hi Haneef, thank you for your reply. Your sample works fine for one or two cells but it will be difficult for large tables with more than one Rtf-column. Can you add an event for each cell where my application can optionally modify then contents that is exported to excel (convert the text with a RichTextBox or do additional formatting)? Best Regards, Christian

Administrator [Syncfusion]
Replied On May 23, 2006 09:12 AM UTC

Hi Christian, Could you try this code to export the ascii text of the Richtext cell in a Grid. Here is a code snippet. public void GridToExcel(Syncfusion.Windows.Forms.Grid.GridControl grid, string FileName) { Syncfusion.GridExcelConverter.GridExcelConverterControl gecc = new Syncfusion.GridExcelConverter.GridExcelConverterControl(); RtfToAscii(grid); gecc.GridToExcel(grid.Model, FileName); AsciiToRtf(grid); } private void RtfToAscii(Syncfusion.Windows.Forms.Grid.GridControl grid) { RichTextBox rbox = new RichTextBox(); for(int i=1;i< grid.RowCount;i++) { for(int j=1;j< grid.ColCount;j++) { if(grid.Model[i,j].CellType == "RichText") { string text = grid.Model[i,j].Text; if(RichTextPaint.IsValidRtf(text )) { rbox.Rtf = text; grid.Model[i,j].Text = rbox.Text; //Add Extra settings of the cells. grid.Model[i,j].Tag = rbox.Rtf; //For Rtf text. } } } } rbox.Dispose(); } private void AsciiIToRtf(Syncfusion.Windows.Forms.Grid.GridControl grid) { for(int i=1;i< grid.RowCount;i++) { for(int j=1;j< grid.ColCount;j++) { if(grid.Model[i,j].CellType == "RichText") { string text = grid.Model[i,j].Tag as string ; if(text != null) { grid.Model[i,j].Text = text; } } } } } Please let me know if this helps. Thanks for choosing Syncfusion Products. Best Regards, Haneef

Christian Lützenkirchen
Replied On July 13, 2006 06:13 AM UTC

Hi Haneef, thank you for your sample. It works fine, but it would be nice if I could include formatting in my export like in Essential Studio\4.2.0.37\windows\XlsIO.Windows\Samples\Rich Text\WriteRichText\cs sample. Do I have to make a feature request? Hint: You should include the RichTextPaint.IsValidRtf() in your documentation. It is not included... Regards Christian

Administrator [Syncfusion]
Replied On July 13, 2006 08:53 AM UTC

Hi Christian, I have logged a feature request #1074 on this. We will try our very best to implement this feature at the earliest. You could track the progress of this feature request at this link below : http://www.syncfusion.com/support/features/grid/Default.aspx?ToDo=view&questId=1074 Thanks for bringing this issue to our attention. Best Regards, Haneef

Christian Lützenkirchen
Replied On January 11, 2007 08:37 AM UTC

Hi Haneef,

your sample worked fine until I upgraded to version 4.4.0.54. Temporary changing the text causes a SaveCellInfo-event and saves the modified contents in my datastructures. Are there any plans to implement feature request #1074 or do you have another solution?

Best regards,
Christian

Christian Lützenkirchen
Replied On February 22, 2007 09:04 AM UTC

Hi Haneef,

do you have any solution?

Regards,
Christian

Administrator [Syncfusion]
Replied On February 22, 2007 03:46 PM UTC

Hi Christian,

I am investigating on this issue. I will update you soon.

Best regards,
Haneef

Administrator [Syncfusion]
Replied On February 22, 2007 05:26 PM UTC

Hi Christian,

You would have to derive the GridExcelConverterControl class and implement the GridToExcel method. Please refer to the attached sample for more details and let me know if this helps.

Sample : GDBGRichTextExport.zip

Best regards,
Haneef

Christian Lützenkirchen
Replied On February 23, 2007 12:38 PM UTC

Hi Haneef,

your sample works fine. Thank you very much.

Best Regards,
Christian

Christian Lützenkirchen
Replied On February 23, 2007 12:54 PM UTC

Hi Haneef,

I found another issue. My Thread runs with
Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("de-DE");

On of the columns has the "Currency"-Type. It shows "34,10 €". The Format the corresponding Cell in Excel has the Format "$ 34,10", the value is correct but the format is wrong. Is this a localization-bug in GridExcelConverterBase?

Regards,
Christian

Christian Lützenkirchen
Replied On February 28, 2007 05:17 PM UTC

Hi Haneef,

do you have any suggestions?

Regards,
Christian

Administrator [Syncfusion]
Replied On February 28, 2007 10:42 PM UTC

Hi Christian,

You can try exporting the FormattedText to excel in a GridCellToExcel() method. Here is a modified code in the GridCellToExcel() method else part. Please refer to the attached sample and let me know if you are looking something different.

else
{
//range.Value2 = objValue;
range.Text = gridCell.FormattedText;
}

Sample : GDBGRichText.zip

Best regards,
Haneef

Christian Lützenkirchen
Replied On March 1, 2007 07:37 AM UTC

Hi Haneef,

thank you for your sample but it does not really solve the problem. The contents of the cell in Excel (2007) is shown as "1000.00 €" but if you enter the cell and leave it it is automatically converted to "$ 1000.00". I beleave the only solution is to set the right format!
Your sample shows another issue. Please insert the following code

double a = 1000.00;
string b = a.ToString("C");
Debug.WriteLine(b);

The Output shows "1000,00 €"
(With a comma!)

Can you please open two bug reporte for these issues?

Regards,
Christian

Administrator [Syncfusion]
Replied On March 1, 2007 08:33 PM UTC

Hi Christian,

Sorry for the incovenience caused.

Essential Grid support only US formats for exporting the grid cells to excel. But it will preserve all the culture settings during exporting. Please let me know if you have any other questions.

Thanks for your patience.

Best regards,
Haneef

Administrator [Syncfusion]
Replied On August 30, 2008 12:50 AM UTC

rlkilxja http://lrkoevmz.com dzaizcfg narqokib


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

;