()
| 91 | } |
| 92 | |
| 93 | function applyCocaColaStyle() { |
| 94 | // Get the active spreadsheet and sheet |
| 95 | const spreadsheet = SpreadsheetApp.getActiveSpreadsheet(); |
| 96 | const sheet = spreadsheet.getActiveSheet(); |
| 97 | |
| 98 | // Get the last row and column |
| 99 | const lastRow = sheet.getLastRow(); |
| 100 | const lastColumn = sheet.getLastColumn(); |
| 101 | |
| 102 | // Define the header range |
| 103 | const headerRange = sheet.getRange(1, 1, 1, lastColumn); |
| 104 | |
| 105 | // Apply header formatting - Coca-Cola Red and White |
| 106 | headerRange.setBackground('#CC0000'); // Coca-Cola Red (approximate) |
| 107 | headerRange.setFontWeight('bold'); |
| 108 | headerRange.setFontFamily('Arial'); // A clean, readable font |
| 109 | headerRange.setFontColor('white'); |
| 110 | headerRange.setHorizontalAlignment('center'); |
| 111 | |
| 112 | // Apply alternating row backgrounds - White and Very Light Gray |
| 113 | for (let i = 2; i <= lastRow; i++) { |
| 114 | const rowRange = sheet.getRange(i, 1, 1, lastColumn); |
| 115 | if (i % 2 === 0) { // Even rows |
| 116 | rowRange.setBackground('white'); |
| 117 | } else { // Odd rows |
| 118 | rowRange.setBackground('#f0f0f0'); // Very light gray |
| 119 | } |
| 120 | rowRange.setFontFamily('Arial'); |
| 121 | rowRange.setFontColor('black'); |
| 122 | } |
| 123 | |
| 124 | // Example of formatting a specific column (e.g., Sales column) |
| 125 | const salesColumnIndex = 5; // Assuming "Sales" is the 3rd column |
| 126 | const salesColumnRange = sheet.getRange(2, salesColumnIndex, lastRow - 1, 1); |
| 127 | salesColumnRange.setNumberFormat('$#,##0.00'); // Currency format |
| 128 | |
| 129 | // Auto-resize columns |
| 130 | sheet.autoResizeColumns(1, lastColumn); |
| 131 | |
| 132 | Logger.log('Coca-Cola style formatting applied!'); |
| 133 | } |
| 134 | |
| 135 | function removeFormatting() { |
| 136 | // Get the active spreadsheet and sheet |
nothing calls this directly
no outgoing calls
no test coverage detected