function prepareSheet(opts, data, columns, idx) {
		/** Default options for sheet */
		var opt = {sheetid: 'Sheet ' + idx, headers: true};
		alasql.utils.extend(opt, opts);

		var dataLength = Object.keys(data).length;

		// Generate columns if they are not defined
		if (!columns || columns.length == 0) {
			if (dataLength > 0) {
				columns = Object.keys(data[0]).map(function (columnid) {
					return {columnid: columnid};
				});
			} else {
				columns = [];
			}
		}

		var cells = {};

		if (wb.SheetNames.indexOf(opt.sheetid) > -1) {
			cells = wb.Sheets[opt.sheetid];
		} else {
			wb.SheetNames.push(opt.sheetid);
			wb.Sheets[opt.sheetid] = {};
			cells = wb.Sheets[opt.sheetid];
		}

		var range = 'A1';
		if (opt.range) range = opt.range;

		var col0 = alasql.utils.xlscn(range.match(/[A-Z]+/)[0]);
		var row0 = +range.match(/[0-9]+/)[0] - 1;

		if (wb.Sheets[opt.sheetid]['!ref']) {
			var rangem = wb.Sheets[opt.sheetid]['!ref'];
			var colm = alasql.utils.xlscn(rangem.match(/[A-Z]+/)[0]);
			var rowm = +rangem.match(/[0-9]+/)[0] - 1;
		} else {
			var colm = 1,
				rowm = 1;
		}
		var zeroColumnFix = columns.length ? 0 : 1;
		var colmax = Math.max(col0 + columns.length - 1 + zeroColumnFix, colm);
		var rowmax = Math.max(row0 + dataLength + 2, rowm);

		//		console.log(col0,row0);
		var i = row0 + 1;

		wb.Sheets[opt.sheetid]['!ref'] = 'A1:' + alasql.utils.xlsnc(colmax) + rowmax;
		//		var i = 1;

		if (opt.headers) {
			columns.forEach(function (col, idx) {
				cells[alasql.utils.xlsnc(col0 + idx) + '' + i] = {
					v: col.columnid.trim(),
				};
			});
			i++;
		}

		for (var j = 0; j < dataLength; j++) {
			columns.forEach(function (col, idx) {
				var cell = {v: data[j][col.columnid]};
				if (typeof data[j][col.columnid] == 'number') {
					cell.t = 'n';
				} else if (typeof data[j][col.columnid] == 'string') {
					cell.t = 's';
				} else if (typeof data[j][col.columnid] == 'boolean') {
					cell.t = 'b';
				} else if (typeof data[j][col.columnid] == 'object') {
					if (data[j][col.columnid] instanceof Date) {
						cell.t = 'd';
					}
				}
				cells[alasql.utils.xlsnc(col0 + idx) + '' + i] = cell;
			});
			i++;
		}
	}
Prepare sheet
		@params {object} opts
		@params {array|object} data
		@params {array} columns Columns