function getSheetData() {
var sheet = SpreadsheetApp.getActiveSheet();
var startRow = 2; // First row of data to process
var numRows = 100; // Number of rows to process
var startCol = 1; //First column of data to process
var numCols = 15; // Number of columns to process
var dataRange = sheet.getRange(startRow, startCol, numRows, numCols);
// Fetch values for each row in the Range.
var data = dataRange.getValues();
return data;
}
You can also modify the above function as follows to get data range dynamic from the content present in sheet:
function getDataSheet() {
sheet = SpreadsheetApp.getActiveSheet();
//Get data range based on content
var dataRange = sheet.getDataRange();
// Fetch values for each row in the Range.
var data = dataRange.getValues();
return data;
}