
VP Geology
Top achievements
Rank 1
VP Geology
asked on 09 Nov 2010, 06:04 PM
I have the following problem in windows application.
I am creating columns by code and then adding rows. As in the following example:
textcolum dim as gridviewtexboxcolumn
textcolum = new gridviewtexboxcolumn
textcolum.fieldname = "name"
textcolum.textalignment = contentaligment.middlecenter
....
....
rowinfo = me.GRID.rows.addnew ()
rowinfo.cells (0). value = "Peter bad"
export to excel, the column name is not justified to center, as I indicated in the code, but is justified on the left.
help please!
I am creating columns by code and then adding rows. As in the following example:
textcolum dim as gridviewtexboxcolumn
textcolum = new gridviewtexboxcolumn
textcolum.fieldname = "name"
textcolum.textalignment = contentaligment.middlecenter
....
....
rowinfo = me.GRID.rows.addnew ()
rowinfo.cells (0). value = "Peter bad"
export to excel, the column name is not justified to center, as I indicated in the code, but is justified on the left.
help please!
5 Answers, 1 is accepted
0

Emanuel Varga
Top achievements
Rank 1
answered on 09 Nov 2010, 08:30 PM
Hello,
Please be sure to set ExportVisualSettings to true, like this for pdf:
but sadly for excel you have to format the cells, like so:
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Please be sure to set ExportVisualSettings to true, like this for pdf:
ExportToPDF exporter =
new
ExportToPDF(
this
.radGridView2);
exporter.ExportVisualSettings =
true
;
exporter.RunExport(@
"C:\test.pdf"
);
but sadly for excel you have to format the cells, like so:
ExportToExcelML exporter =
new
ExportToExcelML(
this
.radGridView1);
exporter.ExcelCellFormatting +=
new
Telerik.WinControls.UI.Export.ExcelML.ExcelCellFormattingEventHandler(exporter_ExcelCellFormatting);
exporter.ExportVisualSettings =
true
;
exporter.RunExport(@
"C:\test.xls"
);
}
void
exporter_ExcelCellFormatting(
object
sender, Telerik.WinControls.UI.Export.ExcelML.ExcelCellFormattingEventArgs e)
{
if
(e.GridColumnIndex == 1)
e.ExcelStyleElement.AlignmentElement.HorizontalAlignment = Telerik.WinControls.UI.Export.ExcelML.HorizontalAlignmentType.Center;
}
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
0
Hello VP,
Emanuel has already provided you with a hint on how to use ExcelCellFormatting event to specify the text alignment. I would only like to add here that we will examine and improve the exporting alignment functionality further in order to allow for getting the alignment setting from the grid columns.
Best wishes,
Martin Vasilev
the Telerik team
Emanuel has already provided you with a hint on how to use ExcelCellFormatting event to specify the text alignment. I would only like to add here that we will examine and improve the exporting alignment functionality further in order to allow for getting the alignment setting from the grid columns.
Best wishes,
Martin Vasilev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0

VP Geology
Top achievements
Rank 1
answered on 15 Nov 2010, 02:31 PM
Emanuel Varga
thank you for the help and collaboration.
thank you very much
thank you for the help and collaboration.
thank you very much
0

VP Geology
Top achievements
Rank 1
answered on 15 Nov 2010, 02:32 PM
Martin (admin)
thank you for the help and collaboration.
thank you very much
thank you for the help and collaboration.
thank you very much
0

Emanuel Varga
Top achievements
Rank 1
answered on 15 Nov 2010, 02:48 PM
Glad to be able to help,
If you have any more questions please just let me know, and if the question has been solved, please mark the all of the helpfull posts as answers, so that others can find the answers to their questions faster.
Best Regards,
Emanuel Varga
Telerik WinForms MVP
If you have any more questions please just let me know, and if the question has been solved, please mark the all of the helpfull posts as answers, so that others can find the answers to their questions faster.
Best Regards,
Emanuel Varga
Telerik WinForms MVP