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

[Solved] How to set the Font Type on Grid Export

2 Answers 144 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alex
Top achievements
Rank 1
Alex asked on 24 Jun 2009, 09:29 AM
Hi,

I have a grid with export button. I am using Office 2007 skin and font type is "Tahoma". But when i export to word or pdf or excel, default is Times New Roman. Please let me know to keep my grid's font type as it is.

Regards,
Alex

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 24 Jun 2009, 09:46 AM
Hello Alex,

You can try out the following code to set the desired font name while exporting:
c#:
    bool isPdfExport; 
    protected void Button1_Click(object sender, EventArgs e) 
    { 
        isPdfExport = true; 
        RadGrid1.ExportSettings.ExportOnlyData = true
        RadGrid1.ExportSettings.IgnorePaging = true
        RadGrid1.ExportSettings.OpenInNewWindow = true
        RadGrid1.MasterTableView.ExportToExcel();        
    } 
      
    protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
    { 
        if (isPdfExport
        { 
            if (e.Item is GridDataItem) 
            { 
                GridDataItem dataItem = (GridDataItem)e.Item; 
                dataItem.Style["font-family"] = "Tahoma";               
            } 
            if (e.Item is GridHeaderItem) 
            { 
                GridHeaderItem headerItem = (GridHeaderItem)e.Item; 
                headerItem.Style["font-family"] = "Tahoma"
 
            } 
        } 
     } 

Thanks
Princy.
0
Alex
Top achievements
Rank 1
answered on 24 Jun 2009, 09:51 AM
Okey. Thanks. Please let me know why it is happening like that. I saw one of your forum comment said that export style is default with the style that we used in grid.
Tags
Grid
Asked by
Alex
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Alex
Top achievements
Rank 1
Share this question
or