Chris Gårdenberg
Top achievements
Rank 2
Chris Gårdenberg
asked on 13 Oct 2010, 01:30 PM
I have a list that contains images, links, repeaters, and regular labels.
When I export to excel in HTML-mode (with OnlyData=true), everything except the labels gets stripped.
Is there someway I can tell the export to export everything, without getting broken images, links and such, everything converted to text, plain text?
When I export to excel in HTML-mode (with OnlyData=true), everything except the labels gets stripped.
Is there someway I can tell the export to export everything, without getting broken images, links and such, everything converted to text, plain text?
7 Answers, 1 is accepted
0
Hello Chris,
You could leave the ExportOnlyData property to its default value (false) and remove the unwanted elements manually on ItemCreated/ItemDataBound. Please examine the Using ItemCreated/ItemDataBound section in our HTML export help topic.
Word/Excel export (HTML-based)
Let me know if you need more specific instructions.
Best regards,
Daniel
the Telerik team
You could leave the ExportOnlyData property to its default value (false) and remove the unwanted elements manually on ItemCreated/ItemDataBound. Please examine the Using ItemCreated/ItemDataBound section in our HTML export help topic.
Word/Excel export (HTML-based)
Let me know if you need more specific instructions.
Best regards,
Daniel
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0
Anne
Top achievements
Rank 1
answered on 15 Dec 2010, 01:40 PM
Hello Daniel,
I have the same problem.
How can I deleted objects HTLM:Submitbutton which are created during the export on Excel File, please ?
Regards,
Anne
I have the same problem.
How can I deleted objects HTLM:Submitbutton which are created during the export on Excel File, please ?
Regards,
Anne
0
Chris Gårdenberg
Top achievements
Rank 2
answered on 15 Dec 2010, 01:52 PM
Hello Anne,
I solved this problem by going the hard way around, by making the export of all the data myself.
I use a component that can read/write excel-files ( http://www.gemboxsoftware.com/GBSpreadsheetFree.htm , we are using this component to read imports and make exports to/from excel).
With some easy tweaks you can use your datasource and export it to excel in an instant, just define all the columns and write a loop that loops over all the data.
Or do as Daniel says and use the ItemCreated/ItemDataBound to remove all items you want to remove before the export.
You'll have more control if you write the export yourself, but it is easier with teleriks already made export-functions.
But in your event that handles the export, you could always loop over the controls and hide the unwanted ones.
Here's some code to obtain controls in an controlcollection
And you can use it like
I solved this problem by going the hard way around, by making the export of all the data myself.
I use a component that can read/write excel-files ( http://www.gemboxsoftware.com/GBSpreadsheetFree.htm , we are using this component to read imports and make exports to/from excel).
With some easy tweaks you can use your datasource and export it to excel in an instant, just define all the columns and write a loop that loops over all the data.
Or do as Daniel says and use the ItemCreated/ItemDataBound to remove all items you want to remove before the export.
You'll have more control if you write the export yourself, but it is easier with teleriks already made export-functions.
But in your event that handles the export, you could always loop over the controls and hide the unwanted ones.
Here's some code to obtain controls in an controlcollection
public
static
IEnumerable<Control> getControls(ControlCollection coll)
{
return
coll.Cast<Control>().Union(coll.Cast<Control>().SelectMany(c => getControls(c.Controls)));
}
And you can use it like
// Not real code, just putting pseudo-code here.
static void
Page_Load() {
var controls = getControls(Page.Controls);
DisableControls(controls);
}
// This is a function I use to loop over the controls I have to disable them, you could adapt this to remove the controls you want to hide.
public
static
void
DisableControls(IEnumerable<Control> controls,
params
string
[] excludedIDs)
{
foreach
(Control ctrl
in
controls.Where(ctrl2 => !excludedIDs.Any(s => s == ctrl2.ID)))
{
if
(ctrl
is
GridView)
{
DisableControls(getControls(ctrl.Controls), excludedIDs);
foreach
(GridViewRow row
in
((GridView)ctrl).Rows)
{
DisableControls(getControls(row.Controls), excludedIDs);
foreach
(DataControlFieldCell cell
in
row.Cells)
{
DisableControls(getControls(cell.Controls), excludedIDs);
}
}
}
else
if
(ctrl
is
GridViewRow)
{
DisableControls(getControls(ctrl.Controls), excludedIDs);
}
else
if
(ctrl
is
DataControlFieldCell)
{
DisableControls(getControls(ctrl.Controls), excludedIDs);
}
else
if
(ctrl
is
Repeater)
{
DisableControls(getControls(ctrl.Controls), excludedIDs);
}
else
if
(ctrl
is
RepeaterItem)
{
DisableControls(getControls(ctrl.Controls), excludedIDs);
}
else
if
(ctrl
is
WebControl)
{
PropertyInfo pi = ctrl.GetType().GetProperty(
"ReadOnly"
);
if
(pi !=
null
)
pi.SetValue(ctrl,
true
,
null
);
else
((WebControl)ctrl).Enabled =
false
;
}
}
}
0
Anne
Top achievements
Rank 1
answered on 20 Dec 2010, 12:22 PM
Thank you very much Chris for you quick answer. I'll try it soon.
Best regards
Anne
Best regards
Anne
0
Anne
Top achievements
Rank 1
answered on 23 Dec 2010, 10:23 AM
Hello,
I don't resolved my problem.
Sometimes on the same web page, the export is well and sometimes it is bad according to filter.
Sometimes with a same filter, the export is well and sometimes it is bad.
I don't understand why ?
I 'll create a ticket.
Regards
Anne
I don't resolved my problem.
Sometimes on the same web page, the export is well and sometimes it is bad according to filter.
Sometimes with a same filter, the export is well and sometimes it is bad.
I don't understand why ?
I 'll create a ticket.
Regards
Anne
0
Hello Anne,
Thank you for submitting ticket about this issue. As soon as we find out what is wrong I will post the solution/explanation in this topic.
Regards,
Daniel
the Telerik team
Thank you for submitting ticket about this issue. As soon as we find out what is wrong I will post the solution/explanation in this topic.
Regards,
Daniel
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Anne
Top achievements
Rank 1
answered on 07 Jan 2011, 09:25 AM
I have resolved my problem. A command applied twice.
My new code :
Than you Chris and Daniel
My new code :
Private bFiltre As Boolean = False
Private Sub MyRadGrid_ItemCommand(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles MyRadGrid.ItemCommand
If e.CommandName = "ExportToExcel" Then
RadFilter1.FireApplyCommand()
bFiltre = True
End If
End Sub
Private Sub MyRadGrid_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyRadGrid.PreRender
Try
If bFiltre = False Then
RadFilter1.FireApplyCommand()
Else
bFiltre = False
End If
Catch ex As Exception
End Try
End Sub
Than you Chris and Daniel