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

Set font for exported excel file

3 Answers 469 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Clive Hoggar
Top achievements
Rank 1
Clive Hoggar asked on 25 Aug 2009, 02:08 PM
Hi

I have an export to excel (plain, not ExcelML)  that looks fine, and the cell contens is aligned correctly
(eg numbers are aligned right), but i have not been able to find a way to set the default font for
the entire excel worksheet. It comes out Times New Roman, although the visible version of the
grid is default skin.

I have looked at various code snippets in the docs but no joy so far.

I guess this is really simple and I'll kick myself when I see it...

Thanks for your help

Clive

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 26 Aug 2009, 06:12 AM
Hello Clive,

You can try out the following code to set the font of the grid while exporting, according to your requirement:
c#:
 protected void btnExport_Click(object sender, EventArgs e) 
    { 
        RadGrid1.ExportSettings.ExportOnlyData = true
        RadGrid1.ExportSettings.OpenInNewWindow = true
        RadGrid1.MasterTableView.Font.Name = "Arial"
        RadGrid1.MasterTableView.ExportToExcel();        
    } 

Thanks
Princy.
0
Clive Hoggar
Top achievements
Rank 1
answered on 26 Aug 2009, 09:54 AM
HI

Thanks.

I can confirm this does set the font in the style of the table that is exported,
when I open the file with notepad to look at the html.

However, Open Offfice calc ignores it - so I guess it is not a problem for this
forum any more.

Guess I'll need to by real excel to see if that is OK.

Regards

Clive
0
Daniel
Telerik team
answered on 27 Aug 2009, 08:49 PM
Hello Clive,

OpenOffice Calc
will use its default font - Times New Roman, regardless of your font settings. It uses different format, that is not supported by RadGrid. Microsoft's mso-number-format won't work also.

Best regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
Clive Hoggar
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Clive Hoggar
Top achievements
Rank 1
Daniel
Telerik team
Share this question
or