Class ExportUtil

java.lang.Object
nl.datasteel.crudcraft.runtime.util.ExportUtil

public final class ExportUtil extends Object
Utility methods for exporting DTO lists to various formats.
  • Method Details

    • toCsv

      public static <R> byte[] toCsv(List<R> dtos)
      Exports a list of DTOs to a CSV file.
      Parameters:
      dtos - the list of DTOs to export
      Returns:
      a byte array containing the CSV data
    • toJson

      public static <R> byte[] toJson(List<R> dtos)
      Exports a list of DTOs to a JSON array.
      Parameters:
      dtos - the list of DTOs to export
      Returns:
      a byte array containing the JSON data
    • toXlsx

      public static <R> byte[] toXlsx(List<R> dtos)
      Exports a list of DTOs to an XLSX file.
      Parameters:
      dtos - the list of DTOs to export
      Returns:
      a byte array containing the XLSX file data
    • streamCsv

      public static <R> void streamCsv(Iterator<R> dtos, OutputStream out)
      Streams a list of DTOs to a CSV file.
      Parameters:
      dtos - the iterator of DTOs to export
      out - the output stream to write the CSV to
    • streamJson

      public static <R> void streamJson(Iterator<R> dtos, OutputStream out)
      Streams a list of DTOs to a JSON array.
      Parameters:
      dtos - the iterator of DTOs to export
      out - the output stream to write the JSON to
    • streamXlsx

      public static <R> void streamXlsx(Iterator<R> dtos, OutputStream out)
      Streams a list of DTOs to an XLSX file.
      Parameters:
      dtos - the iterator of DTOs to export
      out - the output stream to write the XLSX file to