Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void exportData() throws IOException {
- FacesContext facesContext = FacesContext.getCurrentInstance();
- ExternalContext externalContext = facesContext.getExternalContext();
- externalContext.setResponseContentType("text/csv");
- externalContext.setResponseHeader("Content-Disposition", "attachment; filename="all_files.csv"");
- OutputStream out = externalContext.getResponseOutputStream();
- Writer writer = new OutputStreamWriter(out);
- String sql = "SELECT"
- + " job_class_cd "JOB CLASS","
- + " pay_grade "PAY GRADE","
- + " job_class_title,"
- + " mou,"
- + " mou_description,"
- + " nvl(REGEXP_REPLACE(minimum_annual, '\.[0-9]*', ''), ' ') "MINIMUM ANNUAL","
- + " nvl(REGEXP_REPLACE(maximum_annual, '\.[0-9]*', ''), ' ') "MAXIMUM ANNUAL","
- + " nvl(salary_range || CASE WHEN min_step IS NULL THEN '' ELSE ' (' || to_char(MIN_STEP) || ')' END, ' ') "SALARY RANGE (MIN STEP)","
- + " nvl(rate_type, ' ') "RATE TYPE","
- + " nvl(flat_rate, ' ') "FLAT RATE","
- + " nvl(per_event_rate, ' ') "PER EVENT RATE","
- + " step_1,"
- + " step_2,"
- + " step_3,"
- + " step_4,"
- + " step_5,"
- + " step_6,"
- + " step_7,"
- + " step_8,"
- + " step_9,"
- + " step_10,"
- + " step_11,"
- + " step_12,"
- + " step_13,"
- + " step_14,"
- + " step_15"
- + " FROM myApp.st_s_spay"
- + " ORDER BY job_class_title, job_class_cd, pay_grade, rate_type desc";
- // MARK: CSV content header
- try {
- writer.write("JOB CLASS,PAY GRADE,JOB_CLASS_TITLE");
- writer.write("PAY GRADE, JOB_CLASS_TITLE");
- writer.write(", MOU,MOU_DESCRIPTION");
- writer.write(", MINIMUM ANNUAL,MAXIMUM ANNUAL");
- writer.write(", SALARY RANGE, RATE TYPE");
- writer.write(", FLAT RATE, PER EVENT RATE");
- writer.write(",STEP_1, STEP_2");
- writer.write(",STEP_3, STEP_4");
- writer.write(",STEP_5, STEP_6");
- writer.write(",STEP_7, STEP_8");
- writer.write(",STEP_9, STEP_10");
- writer.write(",STEP_11, STEP_12");
- writer.write(",STEP_13, STEP_14");
- writer.write(",STEP_15");
- } finally {
- if (writer != null) {
- // MARK: Close and flush the OutputStream
- writer.close();
- }
- }
- facesContext.responseComplete();
- }
Add Comment
Please, Sign In to add comment