CompletIT Community Server

Welcome to CompletIT Community Server Sign in | Join | Help

Code Sample: Exporting DataGridView control contents to Html using the DGV Extension exporter

  •  08-31-2007, 2:03 AM

    Code Sample: Exporting DataGridView control contents to Html using the DGV Extension exporter

    It is possible to use separately the export functionality to Html provided by DataGridView Extension. There are some simple steps outlined below you have to follow.

    1. Add reference to the main assembly ‘DataGridViewExtension.dll’ and export dll ‘DGVEHtmlExporting.dll’. The assemblies can be found in folder 'v1.1.1\Bin' in the installation\archive.


    2. First ensure you have the following imports:
    C#
    using CompletIT.Windows.Forms.Export.Html;

    VB.NET
    Imports CompletIT.Windows.Forms.Export.Html


    3. Then add the following code in the event handler that has to perform the export:
    C#
    DGVEHtmlExportSettings exportSettings = new DGVEHtmlExportSettings();
    exportSettings.ExportFileName = ...//Export file name
    exportSettings.OpenFileAfterGeneration =
    true; //Open generated file after export
    //Set other settings here...

    DGVEHtmlExporter exporter = new DGVEHtmlExporter();
    exporter.Export( dataGridView, exportSettings );

    VB.NET
    Dim ExportSettings As DGVEHtmlExportSettings = New DGVEHtmlExportSettings()
    ExportSettings.ExportFileName = ...'Export file name
    ExportSettings.OpenFileAfterGeneration = True 'Open generated file after export
    'Set other settings here...

    Dim Exporter As DGVEHtmlExporter = New DGVEHtmlExporter()
    Exporter.Export(Me.DataGridViewControl, ExportSettings)


    4. Run your application!

    Filed under: , ,
View Complete Thread
Powered by Community Server (Personal Edition), by Telligent Systems