(PrintWriter writer)
| 1257 | |
| 1258 | |
| 1259 | protected void writeCSV(PrintWriter writer) { |
| 1260 | if (columnTitles != null) { |
| 1261 | for (int col = 0; col < getColumnCount(); col++) { |
| 1262 | if (col != 0) { |
| 1263 | writer.print(','); |
| 1264 | } |
| 1265 | try { |
| 1266 | if (columnTitles[col] != null) { // col < columnTitles.length && |
| 1267 | writeEntryCSV(writer, columnTitles[col]); |
| 1268 | } |
| 1269 | } catch (ArrayIndexOutOfBoundsException e) { |
| 1270 | PApplet.printArray(columnTitles); |
| 1271 | PApplet.printArray(columns); |
| 1272 | throw e; |
| 1273 | } |
| 1274 | } |
| 1275 | writer.println(); |
| 1276 | } |
| 1277 | for (int row = 0; row < rowCount; row++) { |
| 1278 | for (int col = 0; col < getColumnCount(); col++) { |
| 1279 | if (col != 0) { |
| 1280 | writer.print(','); |
| 1281 | } |
| 1282 | String entry = getString(row, col); |
| 1283 | // just write null entries as blanks, rather than spewing 'null' |
| 1284 | // all over the spreadsheet file. |
| 1285 | if (entry != null) { |
| 1286 | writeEntryCSV(writer, entry); |
| 1287 | } |
| 1288 | } |
| 1289 | // Prints the newline for the row, even if it's missing |
| 1290 | writer.println(); |
| 1291 | } |
| 1292 | writer.flush(); |
| 1293 | } |
| 1294 | |
| 1295 | |
| 1296 | protected void writeEntryCSV(PrintWriter writer, String entry) { |
no test coverage detected