packages/ag-grid-docs/src/example-excel-import/excel-import/example.js
// pull out the values we're after, converting it into an array of rowData
pull out the values we're after, converting it into an array of rowData
pull out the values we ' re after converting it into an array of rowData
function populateGrid(workbook) {
    var firstSheetName = workbook.SheetNames[0];
    var worksheet = workbook.Sheets[firstSheetName];
    var columns = {
        'A': 'athlete',
        'B': 'age',
        'C': 'country',
        'D': 'year',
        'E': 'date',
        'F': 'sport',
        'G': 'gold',
        'H': 'silver',
        'I': 'bronze',
        'J': 'total'
    };
    var rowData = [];
    var rowIndex = 2;
    while (worksheet['A' + rowIndex]) {
        var row = {};
        Object.keys(columns).forEach(function(column) {
            row[columns[column]] = worksheet[column + rowIndex].w;
        });
        rowData.push(row);
        rowIndex++;
    }
    gridOptions.api.setRowData(rowData);
}
function populateGrid ( workbook ) { var firstSheetName = workbook . SheetNames [ 0 ] ; var worksheet = workbook . Sheets [ firstSheetName ] ; var columns = { 'A' : 'athlete' , 'B' : 'age' , 'C' : 'country' , 'D' : 'year' , 'E' : 'date' , 'F' : 'sport' , 'G' : 'gold' , 'H' : 'silver' , 'I' : 'bronze' , 'J' : 'total' } ; var rowData = [ ] ; var rowIndex = 2 ; while ( worksheet [ 'A' + rowIndex ] ) { var row = { } ; Object . keys ( columns ) . forEach ( function ( column ) { row [ columns [ column ] ] = worksheet [ column + rowIndex ] . w ; } ) ; rowData . push ( row ) ; rowIndex ++ ; } gridOptions . api . setRowData ( rowData ) ; }
pull out the values we're after, converting it into an array of rowData
pull out the values we ' re after converting it into an array of rowData
// our data is in the first sheet // we expect the following columns to be present // start at the 2nd row - the first row are the headers // iterate over the worksheet pulling out the columns we're expecting // finally, set the imported rowData into the grid