code: public static byte[] exportQueryCommentsAsCsv(Locale locale, ReplierExportStrategy replierExportStrategy, List<QueryReply> replies, Query query, PanelStamp stamp) throws IOException {
      QueryPageDAO queryPageDAO = new QueryPageDAO();
      
      List<QueryPage> queryPages = queryPageDAO.listByQuery(query);
      Collections.sort(queryPages, new QueryPageNumberComparator());
      
      String[] columnHeaders = new String[] { 
        getReplierExportStrategyLabel(locale, replierExportStrategy), 
        Messages.getInstance().getText(locale, "panelAdmin.query.export.csvCommentAnswerColumn"), 
        Messages.getInstance().getText(locale, "panelAdmin.query.export.csvCommentCommentColumn"), 
        Messages.getInstance().getText(locale, "panelAdmin.query.export.csvCommentReplyColumn"), 
      };
      
      List<String[]> rows = new ArrayList<>();
      
      for (QueryPage queryPage : queryPages) {
        List<String[]> pageRows = exportQueryPageCommentsAsCsv(replierExportStrategy, replies, stamp, queryPage);
        
        if (!pageRows.isEmpty()) {
          rows.add(new String[] { "", "", "", "" });
          rows.add(new String[] { queryPage.getTitle(), "", "", "" });
          rows.add(new String[] { "", "", "", "" });
          rows.addAll(pageRows);
        }
      }
  
      return writeCsv(columnHeaders, rows);
    }
docs: Export query comments into CSV byte array
  
  @param locale locale
  @param replierExportStrategy replies export strategy
  @param replies replies to be exported
  @param query query
  @param stamp stamp
  @return query comments in CSV byte array
  @throws IOException throws IOException when CSV writing fails