code: protected void writeCsvHeader(final JTable table, final Writer out, final char csvSeparator)
  			throws IOException {
  		// récupération des informations utiles
  		final int columnCount = table.getColumnModel().getColumnCount();
  
  		final String eol = System.getProperty("line.separator");
  		if (table.getName() != null) {
  			String title = formatCsv(table.getName(), csvSeparator);
  			if (title.startsWith("ID")) {
  				final String tmp = '"' + title + '"';
  				title = tmp;
  			}
  			out.write(title);
  			out.write(eol);
  		}
  		// titres des colonnes
  		String text;
  		for (int i = 0; i < columnCount; i++) {
  			text = String.valueOf(table.getColumnModel().getColumn(i).getHeaderValue());
  			text = formatCsv(text, csvSeparator);
  			if (i == 0 && text.startsWith("ID")) {
  				out.write('"' + text + '"'); // si commence par ID, Excel pense que c'est un sylk !
  			} else {
  				out.write(text);
  			}
  			if (i < columnCount - 1) {
  				out.write(csvSeparator);
  			}
  		}
  		out.write(eol);
  	}
docs: Exporte les headers csv d'une JTable..
  
  @param table
  JTable
  @param out
  Writer
  @param csvSeparator
  char
  @throws IOException
  Erreur disque