Export FlexGrid to CSV

To export a FlexGrid to CSV, call the FlexGrid.getClipString method to get a string representing the whole grid or any given range, then the string to a file.

You can export the entire grid to CSV like so:

import * as wjGrid from '@grapecity/wijmo.grid';

//function for converting CSV string into a downloadable file
function exportFile(csv, fileName) {
    var fileType = 'txt/csv;charset=utf-8';
    if (navigator.msSaveBlob) { // IE 
        navigator.msSaveBlob(new Blob([csv], {
        type: fileType
        }), fileName);
    else {
        var e = document.createElement('a');
        e.setAttribute('href', 'data:' + fileType + ',' + encodeURIComponent(csv));
        e.setAttribute('download', fileName);
        e.style.display = 'none';

//export grid to CSV
var rng = new wjGrid.CellRange(0, 0, theGrid.rows.length - 1, theGrid.columns.length - 1),
    csv = theGrid.getClipString(rng, true, true);
exportFile(csv, 'FlexGrid.csv');

Or you can export a portion of the grid like using the selected cells as a range to export:

//export selected cell range to CSV
var rng = theGrid.selection,
    csv = theGrid.getClipString(rng, true, true);
exportFile(csv, 'Selection.csv');