5 Answers, 1 is accepted
0
Accepted

Emanuel Varga
Top achievements
Rank 1
answered on 06 May 2011, 08:18 AM
Hello Mark,
There is no clean way to do this, but you can do the following, set the exporter HiddenRowOption to DoNotExport, hide all other rows, export the grid, restore the hidden rows and reselect the initial selected rows.
Please take a look at the following example:
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Telerik WinForms MVP
There is no clean way to do this, but you can do the following, set the exporter HiddenRowOption to DoNotExport, hide all other rows, export the grid, restore the hidden rows and reselect the initial selected rows.
Please take a look at the following example:
void
btn_Click(
object
sender, EventArgs e)
{
var selectedRows = radGridView1.SelectedRows.ToArray();
foreach
(var row
in
radGridView1.Rows.ToArray())
{
if
(!row.IsSelected)
{
row.IsVisible =
false
;
}
}
ExportToExcelML exporter =
new
ExportToExcelML(
this
.radGridView1);
exporter.HiddenRowOption = HiddenOption.DoNotExport;
exporter.ExportVisualSettings =
true
;
string
fileName =
"C:\\ExportedData123.xls"
;
exporter.RunExport(fileName);
foreach
(var row
in
radGridView1.Rows.ToArray())
{
row.IsVisible =
true
;
if
(selectedRows.Contains(row))
{
row.IsSelected =
true
;
}
}
}
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Telerik WinForms MVP
0

Mark
Top achievements
Rank 1
answered on 06 May 2011, 07:27 PM
So it is not really possible to do this by selected cells, only by rows then?
0
Accepted

Emanuel Varga
Top achievements
Rank 1
answered on 06 May 2011, 08:29 PM
Hello again,
You can do the same thing with the columns by hiding columns and set to not export hidden columns, to hide some columns but i don't believe that you can do it like this with cells.
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Telerik WinForms MVP
You can do the same thing with the columns by hiding columns and set to not export hidden columns, to hide some columns but i don't believe that you can do it like this with cells.
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Telerik WinForms MVP
0

Mark
Top achievements
Rank 1
answered on 06 May 2011, 08:34 PM
Thanks for all the help. Do you think it would be possible to do the same thing based on hiding columns and rows, based on which ones should be visible, assuming selected cells are all adjacent?
0
Hello Mark,
Like Emanuel has already pointed, the only way to export just the selected cells is to hide the other rows and columns and use the DoNotExport option. Feel free to implement your scenario hiding and bringing back to visual whichever combination of rows and columns you find appropriate for your needs.
Martin Vasilev
the Telerik team
Like Emanuel has already pointed, the only way to export just the selected cells is to hide the other rows and columns and use the DoNotExport option. Feel free to implement your scenario hiding and bringing back to visual whichever combination of rows and columns you find appropriate for your needs.
Do not hesitate to write back if you have any other questions.
Regards,Martin Vasilev
the Telerik team