Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- XSSFWorkbook workbook = new XSSFWorkbook();
- XSSFSheet sheet = workbook.createSheet("export eBlox");
- int rowCount = 0;
- while (rs.next()) {
- ResultSetMetaData rsMetaData = rs.getMetaData();
- //log.debug("New row columns:"+rsMetaData.getColumnCount());
- int numberOfColumns = rsMetaData.getColumnCount();
- org.apache.poi.ss.usermodel.Row bufferRow = sheet.createRow(++rowCount);
- if (rs.isFirst()) {
- String header = "";
- for (int i = columnOffset; i < numberOfColumns + 1; i++) {
- String fieldName = rsMetaData.getColumnLabel(i);
- if (fieldName.equalsIgnoreCase("str")) {
- strColIndex = i;
- }
- if (brParams) {
- log.debug("WE HERE BRO WTF?!");
- Cell cell = bufferRow.createCell(i);
- cell.setCellValue(fieldName);
- log.debug("FIELD NAME BRUH " + fieldName);
- } else {
- header += fieldName + ";";
- }
- }
- Integer operationCenterId =
- (Integer)ADFContext.getCurrent().getSessionScope().get("operationCenterId");
- if ((sql.contains("V_MOBILITY_KPD_V2") && ((Integer)101229).equals(operationCenterId)) ||
- sql.contains("V_EXPORT_NAVISION_YVAN_PAQUE") || sql.contains("V_MOBILITY_KPD_V3_SODEMAT") ||
- sql.contains("V_WORK_ORDER_EXPORT_VILLAGEN1")) {
- } else {
- if (abCustomExportReps || fourMEuropeParams || fourBenelmantAttentiaParams ||
- sotrelcoExportParams || valensParams || cleExportParams ||
- cleChantierExportParams) {
- } else {
- sb.append(header).append(System.getProperty("line.separator"));
- }
- }
- }
- String csvLine = "";
- for (int i = columnOffset; i < numberOfColumns + 1; i++) {
- String fieldValue = rs.getString(i);
- if (null == fieldValue || fieldValue.equals("null"))
- fieldValue = "";
- csvLine += fieldValue.replaceAll(";", " ") + ";"; //.replaceAll(",", " ")
- if (abCustomExportReps) {
- csvLine = "";
- csvLine += rs.getString(strColIndex).replaceAll(";", " ");
- }
- if (fourMEuropeParams || fourBenelmantAttentiaParams || valensParams) {
- csvLine = "";
- csvLine += rs.getString(strColIndex);
- }
- if (brParams) {
- Cell cell = bufferRow.createCell(i);
- cell.setCellValue(fieldValue);
- log.debug("FIELD VALUE BRUH " + fieldValue);
- }
- }
- if (sql.contains("V_EXPORT_NAVISION_YVAN_PAQUE") || sql.contains("V_WORK_ORDER_EXPORT_VILLAGEN1")) {
- //csvLine = "=\"" + csvLine.substring(0, csvLine.length() - 1) + "\""; //option 1 with inline XLS formatting
- //csvLine = csvLine.substring(0, csvLine.length() - 1) + "\t"; //option 2 with tab
- csvLine = csvLine.substring(0, csvLine.length() - 1); //option 3 for Notepad
- }
- if (counter == 0 && valensParams) {
- sb.append("VERSION 2").append(System.getProperty("line.separator"));
- counter++;
- }
- sb.append(csvLine).append(System.getProperty("line.separator"));
- }
- rs.close();
- if (brParams) {
- workbook.write(outputStream);
- } else {
- BufferedWriter out = new BufferedWriter(fstream);
- if (sb.length() > 0) {
- String a = sb.substring(0, sb.length() - 1);
- out.write(a);
- }
- out.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement