AD
Administrator
Syncfusion Team
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
CL
Christian Lützenkirchen
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
AD
Administrator
Syncfusion Team
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
CL
Christian Lützenkirchen
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
AD
Administrator
Syncfusion Team
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
CL
Christian Lützenkirchen
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
CL
Christian Lützenkirchen
February 22, 2007 09:04 AM UTC
Hi Haneef,
do you have any solution?
Regards,
Christian
AD
Administrator
Syncfusion Team
February 22, 2007 03:46 PM UTC
Hi Christian,
I am investigating on this issue. I will update you soon.
Best regards,
Haneef
AD
Administrator
Syncfusion Team
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.zipBest regards,
Haneef
CL
Christian Lützenkirchen
February 23, 2007 12:38 PM UTC
Hi Haneef,
your sample works fine. Thank you very much.
Best Regards,
Christian
CL
Christian Lützenkirchen
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
CL
Christian Lützenkirchen
February 28, 2007 05:17 PM UTC
Hi Haneef,
do you have any suggestions?
Regards,
Christian
AD
Administrator
Syncfusion Team
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.zipBest regards,
Haneef
CL
Christian Lützenkirchen
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
AD
Administrator
Syncfusion Team
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
AD
Administrator
Syncfusion Team
August 30, 2008 12:50 AM UTC
rlkilxja
http://lrkoevmz.com dzaizcfg narqokib