(PrintWriter writer)
| 1277 | |
| 1278 | |
| 1279 | protected void writeCSV(PrintWriter writer) { |
| 1280 | if (columnTitles != null) { |
| 1281 | for (int col = 0; col < getColumnCount(); col++) { |
| 1282 | if (col != 0) { |
| 1283 | writer.print(','); |
| 1284 | } |
| 1285 | try { |
| 1286 | if (columnTitles[col] != null) { // col < columnTitles.length && |
| 1287 | writeEntryCSV(writer, columnTitles[col]); |
| 1288 | } |
| 1289 | } catch (ArrayIndexOutOfBoundsException e) { |
| 1290 | PApplet.printArray(columnTitles); |
| 1291 | PApplet.printArray(columns); |
| 1292 | throw e; |
| 1293 | } |
| 1294 | } |
| 1295 | writer.println(); |
| 1296 | } |
| 1297 | for (int row = 0; row < rowCount; row++) { |
| 1298 | for (int col = 0; col < getColumnCount(); col++) { |
| 1299 | if (col != 0) { |
| 1300 | writer.print(','); |
| 1301 | } |
| 1302 | String entry = getString(row, col); |
| 1303 | // just write null entries as blanks, rather than spewing 'null' |
| 1304 | // all over the spreadsheet file. |
| 1305 | if (entry != null) { |
| 1306 | writeEntryCSV(writer, entry); |
| 1307 | } |
| 1308 | } |
| 1309 | // Prints the newline for the row, even if it's missing |
| 1310 | writer.println(); |
| 1311 | } |
| 1312 | writer.flush(); |
| 1313 | } |
| 1314 | |
| 1315 | |
| 1316 | protected void writeEntryCSV(PrintWriter writer, String entry) { |
no test coverage detected