How to customize font style, size in print settings while printing RadSpreadsheet (Export Telerik RadGridView to Workbook) in wpf?

1 Answer 51 Views
GridView
Barani
Top achievements
Rank 1
Iron
Iron
Barani asked on 15 Feb 2023, 10:26 AM
Hello,

With reference to the below link,
https://www.telerik.com/forums/add-header-to-each-pages-when-export-telerik-radgridview-to-a-workbook-exporttoworkbook-in-wpf

I need to set font size for the workbook (overwrite default settings) and also apply word wrap for the columns. I have implemented with the above reference. Can you please guide me to achieve this? or if any idea or lead much appreciated. Please let me know if you need more information.

Thanks in advance.
Barani
Top achievements
Rank 1
Iron
Iron
commented on 17 Feb 2023, 08:45 AM

Hi,

Is there any update on the above issue?

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 20 Feb 2023, 09:05 AM

Hi Barani,

To achieve this you can export the grid to a Workbook and then set the properties. Here is an example of this: 

private void RadButton_Click(object sender, RoutedEventArgs e)
{
    var workbook = radGridView1.ExportToWorkbook();
    var worksheet = workbook.Worksheets[0];

    var selection = worksheet.Cells[0,0,worksheet.UsedCellRange.RowCount,worksheet.UsedCellRange.ColumnCount];
    selection.SetFontSize(22);
    selection.SetIsWrapped(true);

    XlsxFormatProvider provider = new XlsxFormatProvider();
    File.WriteAllBytes(@"..\..\..\result.xlsx", provider.Export(workbook));
}

More information is available here: SpreadProcessing - Get, Set, and Clear Cell Properties - Telerik Document Processing

I hope this helps. Should you have any other questions do not hesitate to ask.

Regards,
Dimitar
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Barani
Top achievements
Rank 1
Iron
Iron
commented on 22 Feb 2023, 07:08 AM

Hi Dimitar, thank you for your response. It helped to achieve my requirement. Also I have another issue, can we customize the worksheet to color specific cells with some logic e.g. I need to color the cells which have same words. How to do this and where to write the logic after ExportToWorkbook() functionality.
Dimitar
Telerik team
commented on 22 Feb 2023, 10:40 AM

Hi Barani, 

You can use conditional formatting for this. Detailed information is available here: SpreadProcessing - Conditional Formatting.

Let me know if I can assist you further.
Tags
GridView
Asked by
Barani
Top achievements
Rank 1
Iron
Iron
Answers by
Dimitar
Telerik team
Share this question
or