ExcelExport and PdfExport are very very slow, useless !

Hi , 
I have a grid and use ExcelExport & PdfExport to export data, 
whit a few rows Export works fine but whit about 10000 rows and 11 columns, 
the export is very slow in my local server and more slow on hosting server,
in local about 7/8 mins , is impossible to wait  so long !

On debugging I found that the DB query is very fast , the long wait is the Export method.

Can you help me to improve the performances?

See the code below 


public ActionResult Export(string GridModel, ExportType typeExport)
       { 
           Object exp;
           //Convert to Grid Object
           var obj = ConvertGridObject(GridModel);
            //Get Grid Datasource
           var dataSource = db.Database.SqlQuery<ViewModels.lista_clienti>(BuildingQuery(whereFilter)).ToList();
 
           var fileName = fileNameExport("ListaClienti");
 
           //set add sessionId to fileName
           string nameFile = HttpContext.Session.SessionID + "_" + fileName;
  
           if (typeExport == ExportType.xlsx)
           {
               exp = new ExcelExport();
 
               //Set Properties
               var properties = new GridExcelExport
               {
                   FileName = nameFile,
                   Excelversion = ExcelVersion.Excel2010,
                   Theme = "flat-saffron",
                   LocalSave = true,
                   FilePath = Server.MapPath("~/temp")                    
 
               };
 
               //Export Grid             
 ((ExcelExport)exp).Export(obj, dataSource, properties);   ///SLOW !!!!!!

           }
           
else
           {
               exp = new PdfExport();
 
               PdfDocument document = new PdfDocument();
               document.PageSettings.Orientation = PdfPageOrientation.Landscape; //Sets landscape page orientation.
 
               //Set Properties
               var properties = new GridPdfExport
               {
                   FileName = nameFile,
                   PdfDocument = document,
                   Theme = "flat-saffron",
                   LocalSave = true,
                   FilePath = Server.MapPath("~/temp"),
                   Unicode = true
 
               };
 
               //Export Grid
               ((PdfExport)exp).Export(obj, dataSource, properties); ///VERY SLOW!!!!!
 
               
           }
 
           //return the file name
           return Json(new { fileName = nameFile + "."+ typeExport.ToString() , nameOut = fileName + "."+ typeExport.ToString(), errorMessage = "" });
 
       }

//javascript 


function ejGridExport(gridObj, itemId, controller, extParm) {

    //funzione standard per esportazione dati selezionati dai pulsanti sulla toolbar della grid standard

    // gridObj -> oggetto ejGrid
    // itemId -> Id del pulsante premuto  
    // controller -> controller da invocare x la action Export
    // extParm -> eventuali extra parametri  

    var url;
    var typeExport;
    if (itemId.indexOf("_excelExport") != -1) typeExport = "xlsx";
    if (itemId.indexOf("_pdfExport") != -1) typeExport = "pdf";

    if (typeExport) {
        $.extend(extParm, { typeExport: typeExport });
        url = Router.action(controller, 'Export', extParm );
        ejGridDoExport(gridObj, url);
    }
}

function ejGridDoExport(gridObj, url)
{
    //funzione per l'esportazione dati di una ejGrid 
 
    // gridObj -> oggetto ejGrid
    // url -> url corrispondente alla action da eseguire per l'esportazione
  
    waitingDialog.show('Preparazione dati in corso');
 
    //passa il filtro al metodo di esportazione attraverso il modelGrid
    gridObj.model["where"] = $('form').serialize();
 
    //necessario altrimenti se si fanno 2 esportazioni consecutive da errore (perchè ??)
    var model = $.extend(true, {}, gridObj.model);
 
    //necessario per localizzare correttamente l'esportazione (per visualizzare € al posto di $ )
    var tempObj = {}
    $.extend(tempObj, ej.Grid.Locale["en-US"], ej.Grid.Locale[model.locale]);
    var temp = tempObj.GroupCaptionFormat;
    var split1 = temp.indexOf("{{if");
    var split2 = temp.indexOf(" {{else}}");
    var grpText = temp.slice(split1, split2).replace("{{if count == 1 }}", "");
    var localeProp = { EmptyRecord: tempObj.EmptyRecord, GroupCaptionFormat: temp.slice(0, split1), GroupText: grpText, True: tempObj.True, False: tempObj.False };
    model.locale = model.locale.concat(JSON.stringify(localeProp));
    //----- esportazione proprty locale ------
 
    //rimuove le property da ignorare in esportazione
    if (gridObj.ignoreOnExport) {
        for (var i = 0; i < gridObj.ignoreOnExport.length; i++)
            delete model[gridObj.ignoreOnExport[i]];
    } 
 
    $.ajax({
        type: "POST",
        url: url,
        data: { GridModel: JSON.stringify(model) },//pass the grid model
        dataType: "json",
        success: function (data) {
            waitingDialog.hide();
            //get the file name for download
            if (data.fileName != "") {
                //use window.location.rel='nofollow' href for redirect to download action for download the file
                window.location.rel='nofollow' href = Router.action('Base','Download')+"?file="+data.fileName+"&nameOut="+data.nameOut;
            }
        }
      ,
        error: function (Result) {
            alert("Error");
            waitingDialog.hide();
        }
    });
}



       


3 Replies

FS Farveen Sulthana Thameeztheen Basha Syncfusion Team July 23, 2018 12:29 PM UTC

Hi Nicola, 

Thanks for contacting Syncfusion Support. 

We can reproduce your reported problem “Exporting Grid very slow” at our end. We have already log the issue “Performance issue in Exporting Grid”  and the fix for the issue will be included in our 2018 Volume 2 Service Pack 1 release which is expected to be release at the end of July. 

Please get back to us if you need any further assistance. 

Regards, 
Farveen sulthana T 



NI Nicola September 14, 2018 02:20 PM UTC

Hi,
I updated to version 16.2.0.50 but GridExport is always very slow, 17000 lines in 6 minutes!
At this point I think it is better to export a csv file directly with a query on db and give up the GridExport.

Any suggestions?



PK Prasanna Kumar Viswanathan Syncfusion Team September 17, 2018 07:11 AM UTC

Hi Nicola, 
 
Based on your update you have mentioned that the “GridExport” is very slow after upgraded to the latest version “16.2.0.50”. We have improved the performance in upgraded version, but you have mentioned that you have 17000 rows in Grid.  So, we suggest you set the IsAutoFitRows and IsAutoFit properties as false along with Theme as none.     
 
For more information please refer the below knowledgeBase documentation, 
 
 
Regards, 
Prasanna Kumar N.S.V 


Loader.
Up arrow icon