"
DataGridXL 3 Out Now! See what's new→

Load data from CSV files

To load CSV data we recommend Papa Parse , a popular open source CSV parser that plays very nicely with DataGridXL.

Papa Parse parses CSV data and converts it to a JavaScript format: either an array of objects or a 2D array. Both formats are supported by DataGridXL.

Load remote CSV file (using AJAX)

javascript
Papa.parse("https://example.com/file.csv", {
  download: true,
  complete: function(results) {
    createGrid(results);
  }
});

function createGrid(data){
  const grid = new DataGridXL("grid", {
    data: data
  });
};

The Papa.parse method loads the given URL using AJAX. Wait for its complete callback to fire, then create your data grid with the freshly parsed data.

Load CSV file from user's computer

You can also pass in a local File from an <input type="file"> element.

javascript
Papa.parse(fileInput.files[0], {
  complete: function(results) {
    createGrid(results);
  }
});

function createGrid(data){ ... };
Generated: 25.01.28 (V3.25.01.22)