| 142 | } |
| 143 | |
| 144 | function reported(cellRange) { |
| 145 | const sheet = SpreadsheetApp.getActiveSheet(); |
| 146 | // Get the values from the cell range |
| 147 | const values = sheet.getRange(cellRange).getValues(); |
| 148 | |
| 149 | // Check if the range is empty or doesn't have headers |
| 150 | if (!values || !values.length || !values[0].length) { |
| 151 | return "ERROR: Empty range or missing headers"; |
| 152 | } |
| 153 | |
| 154 | // Build the markdown table header row |
| 155 | let markdownTable = "|"; |
| 156 | for (const header of values[0]) { |
| 157 | markdownTable += ` ${header} |`; |
| 158 | } |
| 159 | markdownTable += "\n"; |
| 160 | |
| 161 | // Add a separator line |
| 162 | markdownTable += "|"; |
| 163 | for (let i = 0; i < values[0].length; i++) { |
| 164 | markdownTable += " --- |"; |
| 165 | } |
| 166 | markdownTable += "\n"; |
| 167 | |
| 168 | // Build the remaining rows |
| 169 | for (let i = 1; i < values.length; i++) { |
| 170 | markdownTable += "|"; |
| 171 | for (const value of values[i]) { |
| 172 | markdownTable += ` ${value} |`; |
| 173 | } |
| 174 | markdownTable += "\n"; |
| 175 | } |
| 176 | |
| 177 | // Call the original translate function with the markdown table |
| 178 | return report(markdownTable); |
| 179 | } |