Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Get values in range
- *
- * @param {String} rangeA1 The range in A1 notation
- *
- * @return {Array} array with non-filtered values
- */
- function getValues (rangeA1) {
- // Get range
- var range = SpreadsheetApp.getActiveSheet().getRange(rangeA1);
- // Get values
- var values = range.getValues();
- // Prepare an array for the non-filtered values.
- var v = [];
- // Get the font color of each cell in our range.
- var oldColors = range.getFontColors();
- // Create a new array with different font colors.
- var colors = [];
- for (var r = 0; r < oldColors.length; r++) {
- colors[r] = oldColors[r].slice(0);
- // Modify the color slightly from black
- // (I figure that's the most common color)
- for (var c = 0; c < colors[r].length; c++) {
- colors[r][c] = (oldColors[r][c] == '#000001') ? '#000002' : '#000001';
- }
- }
- // Set the font colors to the generated colors.
- range.setFontColors(colors);
- // Get the font colors at this point.
- // They should have changed. If they haven't that means
- // the cell was filtered!
- var newColors = range.getFontColors();
- // Check filter status cell for cell
- for (var r = 0; r < colors.length; r++) {
- for (var c = 0; c < colors[r].length; c++) {
- // Store the value if it wasn't filtered
- if ((oldColors[r][c] != newColors[r][c])) {
- v.push(values[r][c]);
- }
- }
- }
- // Change the background colors back to what they were initially
- range.setFontColors(oldColors);
- return v;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement