When exporting a RadDataGridView with the Export-Visuals enabled this handled what I needed (export conditional formatting), however it slowed the export down greatly. My solution was to swap to Async export. This did make the GUI better, but broke the export of conditional formatting. I jury-rigged a solution that works well enough, although not great. Figured I'd pass this along just in case it helps others
[Main Export Method ...]
BtnExportExcel.Enabled = false;
try
{
GridViewSpreadExport spreadExporter = new GridViewSpreadExport(this.radGridView1);
spreadExporter.ExportChildRowsGrouped = true;
spreadExporter.HiddenColumnOption = Telerik.WinControls.UI.Export.HiddenOption.DoNotExport;
spreadExporter.HiddenRowOption = Telerik.WinControls.UI.Export.HiddenOption.DoNotExport;
spreadExporter.FileExportMode = FileExportMode.CreateOrOverrideFile;
SpreadExportRenderer exportRenderer = new SpreadExportRenderer();
spreadExporter.ExportVisualSettings = true;
lastFileName = fileName;
using (var bgw = new BackgroundWorker())
{
pgb_Saving.Value = 0;
pnlSaving.Visible = true;
var bgwFileName = fileName;
bgw.DoWork += (o,e)=> spreadExporter.RunExport(bgwFileName, exportRenderer);
bgw.RunWorkerCompleted += SpreadExporter_AsyncExportCompleted;
bgw.RunWorkerAsync();
}
}
catch (Exception ex)
{
BtnExportExcel.Enabled = true;
}
[...]
private void SpreadExporter_AsyncExportCompleted(object sender, AsyncCompletedEventArgs e)
{
pgb_Saving.Value = 0;
pnlSaving.Visible = false;
tsbDataGridViewExportExcel.Enabled = true;
if (e.Error is null && System.IO.File.Exists(lastFileName))
{
string szTemp = "'" + lastFileName + "' created.\r\n\r\nWould you like to open the spreadsheet?";
var iRet = MsgBox.ConfirmMsg(szTemp, MessageBoxButtons.YesNo, "Spreadsheet Created");
if (iRet == DialogResult.Yes) System.Diagnostics.Process.Start(lastFileName);
}
SwapForExport(false);
}
private void pnlSaving_VisibleChanged(object sender, EventArgs e)
{
if (pnlSaving.Visible)
{
if (pnlSaving.Tag as Timer is null) {
var tmr = new Timer() { Interval = 250 };
tmr.Tick += Timer_Tick;
pnlSaving.Tag = tmr;
}
((Timer)pnlSaving.Tag).Start();
}
else
{
if(pnlSaving.Tag is Timer tmr)
{
tmr.Stop();
}
}
}
private void Timer_Tick(object sender, EventArgs e)
{
//pgb_Saving is a Progress Bar
pgb_Saving.Value = (pgb_Saving.Value + 1) % pgb_Saving.Maximum;
}