This is a migrated thread and some comments may be shown as answers.

radGrid ExportToExcel style problem

1 Answer 86 Views
GridView
This is a migrated thread and some comments may be shown as answers.
dima
Top achievements
Rank 1
dima asked on 15 Jan 2009, 10:33 AM
Hello,
I need export radGrad to Excel file.

This is a code:

gv.ExportSettings.FileName = getFileName();
gv.ExportSettings.ExportOnlyData = true;
gv.ExportSettings.IgnorePaging = true;
gv.ExportSettings.OpenInNewWindow = true;
gv.MasterTableView.Style["text-align"] = "left";
gv.MasterTableView.ExportToExcel();

 

The problem: text-align of data in cells in excel file is different! One column aligned left, other - right. But in radGrid all aligned left.
I tried set style gv.MasterTableView.Style["text-align"] = "left"; but this doesn't solve my problem.
How can I set style for table cells???

P.S.
I found on the forum screenshot of excel table with a similar problem (last column aligned left and other right):
http://www.telerik.com/community/forums/aspnet-ajax/general-discussions/export-to-excel-number-problems.aspx

Thanks a lot.

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 16 Jan 2009, 01:40 PM
Hello Dima,

Please examine the following link:
Export to Microsoft Excel/Word/PDF/CSV

Sample code:
protected void RadGrid1_ExcelExportCellFormatting(object source, ExcelExportCellFormattingEventArgs e) 
    e.Cell.HorizontalAlign = HorizontalAlign.Left; 

Let us know if you need further assistance.

Regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
GridView
Asked by
dima
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or