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

radgrid export to excel biff format

3 Answers 308 Views
Grid
This is a migrated thread and some comments may be shown as answers.
ZR
Top achievements
Rank 1
ZR asked on 29 Oct 2012, 05:48 PM
Hi,

I've the below format in my aspx:

 

 

<ExportSettings ExportOnlyData="true" OpenInNewWindow="true" HideStructureColumns="true">

 

 

 

<Excel Format="Biff" />

 

 

 

</ExportSettings>

 


I need to do the foll:
1) When exporting to excel, how do I left justify the header and excell cell contents .(i've biff formatting. I cannot change it to html due to excel warning message.)

I tried this in itemCommand:

GridItem

 

 

Item = (GridItem)radDASignature.MasterTableView.GetItems(GridItemType.Item)[0];

 


 

 

foreach (TableCell tcell in Item.Cells)

 

{

tcell.Text = tcell.Text.Replace(

 

"<nobr>", "");

 

tcell.Style[

 

"text-align"] = "left";

 

tcell.HorizontalAlign =

 

HorizontalAlign.Left;

 

}
This above doesn't work. Please help with code.

2) When exporting the cell content in excel,I  have <nobr> and </nobr> tags to the data. How do I get rid of them while exporting.
I set them in column created event to avoid wrapping of cell contents. However, I do not want the <nobr> added to the excel data while exporting.

3 Answers, 1 is accepted

Sort by
0
Multi
Top achievements
Rank 1
answered on 30 Oct 2012, 12:34 PM
Hi,

I had this problem and I removed the code:

boundColumn.DataFormatString = "<nobr>{0}</nobr>";


Regards,
PatrĂ­cia

0
Kostadin
Telerik team
answered on 01 Nov 2012, 12:06 PM
Hi Zaheka,

Note that styling via CSS classes is not possible when you are using BIFF Export format. You could take a look at the following article where you can see how to styling columns/rows/cells.

All the best,
Kostadin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Dilip
Top achievements
Rank 1
answered on 22 Dec 2015, 11:59 AM

Now its working this way

protected void grdPreview_ExcelExportCellFormatting(object sender, ExcelExportCellFormattingEventArgs e)
    {
        GridDataItem item = e.Cell.Parent as GridDataItem;
        if (e.FormattedColumn.UniqueName == "Policy_Number")
        {
            e.Cell.HorizontalAlign = HorizontalAlign.Right;
        }
    }

Tags
Grid
Asked by
ZR
Top achievements
Rank 1
Answers by
Multi
Top achievements
Rank 1
Kostadin
Telerik team
Dilip
Top achievements
Rank 1
Share this question
or