Commit 3ddb8003 authored by Ketan Patil's avatar Ketan Patil

Replace SFACSVToExcelConverter.java

parent a7a9fb5b
/* */ package ibase.webitm.ejb.sc; package ibase.webitm.ejb.sc;
/* */
/* */ import ibase.utility.CommonConstants; import java.io.BufferedReader;
/* */ import ibase.webitm.ejb.dis.DistCommon; import java.io.DataInputStream;
/* */ import java.io.BufferedReader; import java.io.File;
/* */ import java.io.DataInputStream; import java.io.FileInputStream;
/* */ import java.io.File; import java.io.FileNotFoundException;
/* */ import java.io.FileInputStream; import java.io.FileOutputStream;
/* */ import java.io.FileNotFoundException; import java.io.FileReader;
/* */ import java.io.FileOutputStream; import java.io.FileWriter;
/* */ import java.io.FileReader; import java.io.IOException;
/* */ import java.io.IOException; import java.sql.Connection;
/* */ import java.io.PrintStream; import java.sql.Timestamp;
/* */ import java.sql.Connection; import java.text.SimpleDateFormat;
/* */ import java.text.SimpleDateFormat; import java.util.ArrayList;
/* */ import java.util.ArrayList; import java.util.Calendar;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.streaming.SXSSFSheet; import org.apache.poi.xssf.streaming.SXSSFSheet;
import org.apache.poi.xssf.streaming.SXSSFWorkbook; import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFCell; import org.apache.poi.xssf.usermodel.XSSFCell;
...@@ -28,327 +22,404 @@ import org.apache.poi.xssf.usermodel.XSSFCellStyle; ...@@ -28,327 +22,404 @@ import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFRow; import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
/* */ import org.apache.poi.hssf.usermodel.HSSFCell;
/* */ public class SFACSVToExcelConverter import org.apache.poi.hssf.usermodel.HSSFCellStyle;
/* */ { import org.apache.poi.hssf.usermodel.HSSFRow;
/* */ public static final char FILE_DELIMITER = ','; import org.apache.poi.hssf.usermodel.HSSFSheet;
/* */ public static final String FILE_EXTN = ".xlsx"; import org.apache.poi.hssf.usermodel.HSSFWorkbook;
/* */ public static final String FILE_NAME = "EXCEL_DATA"; import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
/* */ import org.apache.poi.ss.usermodel.*;
/* */ public void convert(String fileName, String seperator) import org.apache.poi.xssf.usermodel.XSSFWorkbook;
/* */ throws IOException import ibase.utility.CommonConstants;
/* */ { import ibase.utility.E12GenericUtility;
/* 50 */ String jbossHome = CommonConstants.JBOSSHOME; import ibase.webitm.ejb.dis.DistCommon;
/* */ import ibase.webitm.utility.ITMException;
/* 52 */ String fName = jbossHome + File.separator +
/* 53 */ "SFACDailyReport" + File.separator + fileName; import java.lang.Object;
/* */ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
/* 55 */ ArrayList arList = null;
/* 56 */ ArrayList al = null; public class SFACSVToExcelConverter
/* */ {
/* 58 */ int count = 0; public static final char FILE_DELIMITER = ',';
/* 59 */ FileReader reader = new FileReader(fName + ".csv"); public static final String FILE_EXTN = ".xlsx";
/* */ public static final String FILE_NAME = "EXCEL_DATA";
/* 62 */ BufferedReader bufferedReader = new BufferedReader(reader); @SuppressWarnings("deprecation")
/* 63 */ int i = 0; public void convert(String fileName, String seperator)
/* 64 */ arList = new ArrayList(); throws IOException
/* */ String thisLine; {
/* 66 */ while ((thisLine = bufferedReader.readLine()) != null) String jbossHome = CommonConstants.JBOSSHOME;
/* */ {
/* 69 */ al = new ArrayList(); String fName = jbossHome + File.separator +
/* 70 */ String[] strar = thisLine.split(seperator); "SFACDailyReport" + File.separator + fileName;
/* 71 */ for (int j = 0; j < strar.length; j++) {
/* 72 */ al.add(strar[j]); ArrayList arList = null;
/* */ } ArrayList al = null;
/* 74 */ arList.add(al);
/* 75 */ System.out.println(); int count = 0;
/* 76 */ i++; FileReader reader = new FileReader(fName + ".csv");
/* */ } // FileInputStream fis = new FileInputStream(fName + ".csv");
/* */ try // DataInputStream myInput = new DataInputStream(fis);
/* */ { BufferedReader bufferedReader = new BufferedReader(reader);
/* 80 */ HSSFWorkbook hwb = new HSSFWorkbook(); int i = 0;
/* 81 */ HSSFSheet sheet = hwb.createSheet("new sheet"); arList = new ArrayList();
/* */ String thisLine;
/* 83 */ HSSFCellStyle style = hwb.createCellStyle(); while ((thisLine = bufferedReader.readLine()) != null)
/* 84 */ style.setAlignment((short) 3); /* */ {
/* 85 */ for (int k = 0; k < arList.size(); k++) { ///* */ String thisLine;
/* 86 */ ArrayList ardata = (ArrayList)arList.get(k); /* 40 */ al = new ArrayList();
/* 87 */ HSSFRow row = sheet.createRow(0 + k); /* 41 */ String[] strar = thisLine.split(seperator);
/* 88 */ for (int p = 0; p < ardata.size(); p++) { /* 42 */ for (int j = 0; j < strar.length; j++) {
/* 89 */ HSSFCell cell = row.createCell((short)p); /* 43 */ al.add(strar[j]);
/* 90 */ String data = ardata.get(p).toString(); /* */ }
/* 91 */ System.out.println("data: " + data); /* 45 */ arList.add(al);
/* 92 */ if (data.startsWith("=")) { /* 46 */ System.out.println();
/* 93 */ cell.setCellType(1); /* 47 */ i++;
/* 94 */ data = data.replaceAll("\"", ""); /* */ }
/* 95 */ data = data.replaceAll("=", ""); /* */ try
/* 96 */ cell.setCellValue(data); /* */ {
/* 97 */ } else if (data.startsWith("\"")) { /* 51 */ HSSFWorkbook hwb = new HSSFWorkbook();
/* 98 */ data = data.replaceAll("\"", ""); /* 52 */ HSSFSheet sheet = hwb.createSheet("new sheet");
/* 99 */ cell.setCellType(1); /* */
/* 100 */ cell.setCellValue(data); /* 54 */ HSSFCellStyle style = hwb.createCellStyle();
/* 101 */ } else if ((isNumeric(data)) && (!data.startsWith("0"))) /* 55 */ style.setAlignment(CellStyle.ALIGN_RIGHT);
/* */ { /* 56 */ for (int k = 0; k < arList.size(); k++) {
/* 103 */ System.out.println("In Numeric"); /* 57 */ ArrayList ardata = (ArrayList)arList.get(k);
/* */ /* 58 */ HSSFRow row = sheet.createRow(0 + k);
/* 105 */ cell.setCellStyle(style); /* 59 */ for (int p = 0; p < ardata.size(); p++) {
/* 106 */ cell.setCellType(0); /* 60 */ HSSFCell cell = row.createCell((short)p);
/* 107 */ cell.setCellValue(Double.parseDouble(data)); /* 61 */ String data = ardata.get(p).toString();
/* */ } /* 62 */ System.out.println("data: " + data);
/* */ else /* 63 */ if (data.startsWith("=")) {
/* */ { /* 64 */ cell.setCellType(1);
/* 111 */ data = data.replaceAll("\"", ""); /* 65 */ data = data.replaceAll("\"", "");
/* 112 */ cell.setCellType(1); /* 66 */ data = data.replaceAll("=", "");
/* 113 */ cell.setCellValue(data); /* 67 */ cell.setCellValue(data);
/* */ } /* 68 */ } else if (data.startsWith("\"")) {
/* */ /* 69 */ data = data.replaceAll("\"", "");
/* */ } /* 70 */ cell.setCellType(1);
/* */ /* 71 */ cell.setCellValue(data);
/* 118 */ System.out.println(); /* 72 */ } else if ((isNumeric(data)) && (!data.startsWith("0")))
/* */ } /* */ {
/* 120 */ FileOutputStream fileOut = new FileOutputStream(fName + ".xls"); /* 74 */ System.out.println("In Numeric");
/* 121 */ hwb.write(fileOut); /* */
/* 122 */ fileOut.close(); /* 76 */ cell.setCellStyle(style);
/* 123 */ reader.close(); /* 77 */ cell.setCellType(0);
/* 124 */ bufferedReader.close(); /* 78 */ cell.setCellValue(Double.parseDouble(data));
/* 125 */ File f = new File(fName + ".csv"); /* */ }
/* 126 */ Boolean value = Boolean.valueOf(f.delete()); /* */ else
/* 127 */ f.deleteOnExit(); /* */ {
/* 128 */ System.out.println("Value: " + value); /* 83 */ data = data.replaceAll("\"", "");
/* 129 */ System.out.println("Your excel file has been generated"); /* 84 */ cell.setCellType(1);
/* */ } catch (Exception ex) { /* 85 */ cell.setCellValue(data);
/* 131 */ ex.printStackTrace(); /* */ }
/* */ } /* */
/* */ } /* */ }
/* */ /* */
/* */ public static String convertCsvToXls(String fileName, String xlsFileLocation) /* 91 */ System.out.println();
/* */ throws IOException /* */ }
/* */ { /* 93 */ FileOutputStream fileOut = new FileOutputStream(fName + ".xls");
/* 139 */ String jbossHome = CommonConstants.JBOSSHOME; /* 94 */ hwb.write(fileOut);
/* */ /* 95 */ fileOut.close();
/* 141 */ String fName = jbossHome + File.separator + /* 96 */ reader.close();
/* 142 */ "SFACDailyReport" + File.separator + fileName; /* 97 */ bufferedReader.close();
/* */ /* 98 */ File f = new File(fName + ".csv");
/* 144 */ ArrayList arList = null; /* 99 */ Boolean value = Boolean.valueOf(f.delete());
/* 145 */ ArrayList al = null; /* 100 */ f.deleteOnExit();
/* */ /* 101 */ System.out.println("Value: " + value);
/* 147 */ int count = 0; /* 102 */ System.out.println("Your excel file has been generated");
/* 148 */ FileInputStream fis = null; /* */ } catch (Exception ex) {
/* */ try { /* 104 */ ex.printStackTrace();
/* 150 */ fis = new FileInputStream(fName + ".csv"); /* */ }
/* */ } /* */ }
/* */ catch (FileNotFoundException e) {
/* 153 */ e.printStackTrace(); //public static String convertCsvToXls(String xlsFileLocation, String csvFilePath)
/* */ } @SuppressWarnings("resource")
/* */ public static String convertCsvToXls(String fileName, String xlsFileLocation) throws IOException
/* 156 */ DataInputStream myInput = new DataInputStream(fis); {
/* 157 */ int i = 0; String jbossHome = CommonConstants.JBOSSHOME;
/* 158 */ arList = new ArrayList();
/* */ String thisLine; String fName = jbossHome + File.separator +
/* 160 */ while ((thisLine = myInput.readLine()) != null) "SFACDailyReport" + File.separator + fileName;
/* */ {
/* 163 */ al = new ArrayList(); ArrayList arList = null;
/* 164 */ String[] strar = thisLine.split(xlsFileLocation); ArrayList al = null;
/* 165 */ for (int j = 0; j < strar.length; j++) {
/* 166 */ al.add(strar[j]); int count = 0;
/* */ } FileInputStream fis=null;
/* 168 */ arList.add(al); try {
/* 169 */ System.out.println(); fis = new FileInputStream(fName + ".csv");
/* 170 */ i++; } catch (FileNotFoundException e) {
/* */ } // TODO Auto-generated catch block
/* */ e.printStackTrace();
/* 173 */ System.out.println("xlsFileLocation>> " + xlsFileLocation); }
/* */
/* 175 */ System.out.println("csvFilePath>> " + fileName); DataInputStream myInput = new DataInputStream(fis);
/* 176 */ SXSSFSheet sheet = null; int i = 0;
/* */ arList = new ArrayList();
/* 178 */ Workbook workBook = null; String thisLine;
/* 179 */ String generatedXlsFilePath = ""; while ((thisLine = myInput.readLine()) != null)
/* 180 */ FileOutputStream fileOutputStream = null; {
/* */ try
/* */ { al = new ArrayList();
/* 188 */ workBook = new SXSSFWorkbook(); String[] strar = thisLine.split(xlsFileLocation);
/* 189 */ sheet = (SXSSFSheet)workBook.createSheet("Sheet"); for (int j = 0; j < strar.length; j++) {
/* */ al.add(strar[j]);
/* 191 */ int rowNum = 0; }
/* */ arList.add(al);
/* 206 */ generatedXlsFilePath = xlsFileLocation + "EXCEL_DATA" + ".xlsx"; System.out.println();
/* */ i++;
/* 209 */ fileOutputStream = new FileOutputStream(generatedXlsFilePath.trim()); }
/* 210 */ workBook.write(fileOutputStream);
/* */ } catch (Exception exObj) { System.out.println("xlsFileLocation>> " +xlsFileLocation);
/* 212 */ exObj.printStackTrace();
/* */ } System.out.println("csvFilePath>> " +fileName);
/* */ SXSSFSheet sheet = null;
/* 230 */ return generatedXlsFilePath; // au.com.bytecode.opencsv.CSVReader reader = null;
/* */ } Workbook workBook = null;
/* */ String generatedXlsFilePath = "";
/* */ public void convertMonthlyReport(String fileName, String seperator, String logFileName, Connection conn) FileOutputStream fileOutputStream = null;
/* */ throws IOException
/* */ { try {
/* 239 */ String currTime = null;
/* 240 */ SimpleDateFormat sdf1 = null; /**** Get the CSVReader Instance & Specify The Delimiter To Be Used ****/
/* */ String[] nextLine;
/* 251 */ SFAMonthlyReport sf = new SFAMonthlyReport(); //reader = new CSVReader(new FileReader(csvFilePath), FILE_DELIMITER);
/* 252 */ System.out.println("fileName>> " + fileName);
/* 253 */ System.out.println("seperator>> " + seperator); workBook = new SXSSFWorkbook();
/* 254 */ DistCommon disCom = new DistCommon(); sheet = (SXSSFSheet) workBook.createSheet("Sheet");
/* 255 */ String jbossHome = disCom.getDisparams("999999", "MONTHLY_REPORT_", conn);
/* 256 */ System.out.println("jbossHome File Path >> " + jbossHome); int rowNum = 0;
/* */ // logger.info("Creating New .Xls File From The Already Generated .Csv File");
/* 262 */ String fName = jbossHome + File.separator + fileName; /* while((nextLine = reader.readNext()) != null) {
/* */ Row currentRow = sheet.createRow(rowNum++);
/* 264 */ System.out.println("inside the convertMonthlyReport fName >>" + fName); for(int ii=0; ii < nextLine.length; ii++) {
/* 265 */ ArrayList arList = null; if(NumberUtils.isDigits(nextLine[ii])) {
/* 266 */ ArrayList al = null; currentRow.createCell(ii).setCellValue(Integer.parseInt(nextLine[ii]));
/* */ } else if (NumberUtils.isNumber(nextLine[ii])) {
/* 268 */ int count = 0; currentRow.createCell(ii).setCellValue(Double.parseDouble(nextLine[ii]));
/* */ } else {
/* 270 */ FileReader reader = new FileReader(fName + ".csv"); currentRow.createCell(ii).setCellValue(nextLine[ii]);
/* */ }
/* 274 */ BufferedReader bufferedReader = new BufferedReader(reader); }
/* */ }*/
/* 277 */ int i = 0;
/* 278 */ arList = new ArrayList(); generatedXlsFilePath = xlsFileLocation + FILE_NAME + FILE_EXTN;
/* */ String thisLine; // logger.info("The File Is Generated At The Following Location?= " + generatedXlsFilePath);
/* 281 */ while ((thisLine = bufferedReader.readLine()) != null)
/* */ { fileOutputStream = new FileOutputStream(generatedXlsFilePath.trim());
/* 283 */ System.out.println("Inside the csv file "); workBook.write(fileOutputStream);
/* */ } catch(Exception exObj) {
/* 285 */ al = new ArrayList(); exObj.printStackTrace();
/* 286 */ String[] strar = thisLine.split(seperator); // logger.error("Exception In convertCsvToXls() Method?= " + exObj);
/* 287 */ for (int j = 0; j < strar.length; j++) { } /*finally {
/* 288 */ al.add(strar[j]); try {
/* */ }
/* 290 */ arList.add(al); *//**** Closing The Excel Workbook Object ****//*
/* 291 */ System.out.println(); workBook.close();
/* 292 */ i++;
/* */ } *//**** Closing The File-Writer Object ****//*
/* */ try fileOutputStream.close();
/* */ {
/* 296 */ System.out.println("@V2 arList :- [" + arList.size() + "]"); *//**** Closing The CSV File-ReaderObject ****//*
/* 297 */ System.out.println("@V2 arList :- [" + arList + "]"); reader.close();
/* 298 */ if (arList.size() <= 67000) } catch (IOException ioExObj) {
/* */ { logger.error("Exception While Closing I/O Objects In convertCsvToXls() Method?= " + ioExObj);
/* 300 */ System.out.println("Before XSSFWorkbook Call"); }
/* 301 */ XSSFWorkbook hwb = new XSSFWorkbook(); }*/
/* */
/* 303 */ System.out.println("After XSSFWorkbook Call"); return generatedXlsFilePath;
/* 304 */ XSSFSheet sheet = hwb.createSheet("new sheet");
/* */ }
/* 306 */ String data = "";
/* */ public void convertMonthlyReport(String fileName, String seperator,String logFileName, Connection conn)
/* 308 */ XSSFCellStyle style = hwb.createCellStyle(); throws IOException
/* 309 */ System.out.println("style??" + style);
/* */ {
/* 311 */ style.setAlignment((short) 3);
/* 312 */ for (int k = 0; k < arList.size(); k++) String currTime = null;
/* */ { SimpleDateFormat sdf1=null;
/* 314 */ System.out.println("Inside the arList loop " + arList.get(k));
/* */ /*try {
/* 316 */ ArrayList ardata = (ArrayList)arList.get(k); sdf1 = new SimpleDateFormat(this.genericUtility.getDBDateFormat());
/* 317 */ XSSFRow row = sheet.createRow(0 + k); } catch (ITMException e) {
/* 318 */ System.out.println("row:>> " + row); // TODO Auto-generated catch block
/* 319 */ System.out.println("ardata>> " + ardata); e.printStackTrace();
/* 320 */ System.out.println("Ardata Size>> " + ardata.size()); } catch (Exception e) {
/* */ // TODO Auto-generated catch block
/* 322 */ for (int p = 0; p < ardata.size(); p++) e.printStackTrace();
/* */ { }*/
/* 324 */ System.out.println("Inside the ardata loop "); SFAMonthlyReport sf =new SFAMonthlyReport();
/* */ System.out.println("fileName>> " +fileName);
/* 328 */ XSSFCell cell = row.createCell((short)p); System.out.println("seperator>> " +seperator);
/* 329 */ System.out.println("cell:>>" + cell); DistCommon disCom = new DistCommon();
/* */ String jbossHome= disCom.getDisparams("999999", "MONTHLY_REPORT_", conn);
/* 332 */ data = ardata.get(p).toString(); System.out.println("jbossHome File Path >> "+ jbossHome);
/* 333 */ System.out.println("data 1>> " + data);
/* 334 */ if (data.startsWith("=")) { //String jbossHome = CommonConstants.JBOSSHOME;
/* 335 */ System.out.println("Inside if data ");
/* 336 */ cell.setCellType(1); /*String fName = jbossHome + File.separator +
/* 337 */ data = data.replaceAll("\"", ""); "SFAMonthlyReport" + File.separator + fileName;*/
/* 338 */ data = data.replaceAll("=", ""); String fName = jbossHome+File.separator+ fileName;
/* */
/* 340 */ System.out.println("data 2>>" + data); System.out.println("inside the convertMonthlyReport fName >>" +fName);
/* 341 */ cell.setCellValue(data); ArrayList arList = null;
/* */ } ArrayList<String> al = null;
/* 343 */ else if ((data.startsWith(" ")) || (data.startsWith("\t"))) {
/* 344 */ System.out.println("Inside else if data "); int count = 0;
/* 345 */ cell.setCellType(1); //Added By Amit [Yesatrdya]
/* 346 */ data = data.replaceAll("\t", ""); FileReader reader = new FileReader(fName + ".csv");
/* 347 */ data = data.replaceAll(" ", "");
/* 348 */ System.out.println("data3>> " + data); //FileInputStream fis = new FileInputStream(fName + ".csv");
/* 349 */ cell.setCellValue(data); // myInput = new DataInputStream(fis);
/* */ } BufferedReader bufferedReader = new BufferedReader(reader);
/* 352 */ else if (data.startsWith("\"")) { //Added By Amit [Yesatrdya]
/* 353 */ System.out.println("Insdie \\");
/* 354 */ data = data.replaceAll("\"", ""); int i = 0;
/* 355 */ System.out.println("data 4>> " + data); arList = new ArrayList();
/* 356 */ cell.setCellType(1); String thisLine;
/* 357 */ cell.setCellValue(data);
/* */ } while ((thisLine = bufferedReader.readLine()) != null)
/* 359 */ else if ((isNumeric(data)) && (!data.startsWith("0"))) {
/* */ { System.out.println("Inside the csv file ");
/* 361 */ System.out.println("In Numeric");
/* */ al = new ArrayList();
/* 363 */ cell.setCellStyle(style); String[] strar = thisLine.split(seperator);
/* 364 */ cell.setCellType(0); for (int j = 0; j < strar.length; j++) {
/* 365 */ cell.setCellValue(Double.parseDouble(data)); al.add(strar[j]);
/* */ } }
/* */ else arList.add(al);
/* */ { System.out.println();
/* 369 */ System.out.println("Insdie replaceAll\\"); i++;
/* 370 */ data = data.replaceAll("\"", ""); }
/* 371 */ cell.setCellType(1); try
/* 372 */ cell.setCellValue(data); {
/* */ } System.out.println("@V2 arList :- ["+arList.size()+"]");
/* 374 */ data = null; System.out.println("@V2 arList :- ["+arList+"]");
/* */ } if(arList.size()<=67000)
/* */ {
/* 377 */ System.out.println(); System.out.println("Before XSSFWorkbook Call");
/* */ } XSSFWorkbook hwb = new XSSFWorkbook();
/* 379 */ FileOutputStream fileOut = new FileOutputStream(fName + ".xlsx"); //XSSFWorkbook hwb = new XSSFWorkbook();
/* 380 */ hwb.write(fileOut); System.out.println("After XSSFWorkbook Call");
/* 381 */ fileOut.close(); XSSFSheet sheet = hwb.createSheet("new sheet");
/* 382 */ reader.close(); //Sheet sheet = hwb.createSheet("new sheet");
/* */ String data="";
/* 384 */ bufferedReader.close();
/* */ XSSFCellStyle style = hwb.createCellStyle();
/* 386 */ File f = new File(fName + ".csv"); System.out.println("style??"+style);
/* 387 */ Boolean value = Boolean.valueOf(f.delete()); //CellStyle style = hwb.createCellStyle();
/* 388 */ f.deleteOnExit(); style.setAlignment(CellStyle.ALIGN_RIGHT);
/* 389 */ System.out.println("Value: " + value); for (int k = 0; k < arList.size(); k++)
/* 390 */ System.out.println("Your Excel File Has Been Generated With File Name= " + fName); {
/* */ System.out.println("Inside the arList loop "+arList.get(k));
/* 392 */ sf.printLogFile("STDOUT", "File Generated Name:= :: <" + fileName + ">", logFileName, conn); //ArrayList<Short>ardata=(ArrayList)arList.get(k);
/* */ } ArrayList ardata = (ArrayList)arList.get(k);
/* */ else XSSFRow row = sheet.createRow(0 + k);
/* */ { System.out.println("row:>> "+row);
/* 396 */ System.out.println("No excel created........[" + arList.size()); System.out.println("ardata>> "+ardata);
/* */ } System.out.println("Ardata Size>> "+ardata.size());
/* */ } catch (Exception ex) { /*Row row = sheet.createRow(0 + k);*/
/* 399 */ ex.printStackTrace(); for (int p = 0; p < ardata.size(); p++)
/* */ } {
/* */ } System.out.println("Inside the ardata loop ");
/* */ //HSSFCell cell = row.createCell((short)p);
/* */ public static boolean isNumeric(String str) //XSSFCell cell = (row.createCell(p));
/* */ { //Amit
/* */ try { XSSFCell cell = row.createCell((short)p);
/* 406 */ if ((str.toUpperCase().contains("A")) || System.out.println("cell:>>"+cell);
/* 407 */ (str.toUpperCase().contains("B")) || //Cell cell = (row.createCell(p));
/* 408 */ (str.toUpperCase().contains("C")) || //String data = ardata.get(p).toString();
/* 409 */ (str.toUpperCase().contains("D")) || data = ardata.get(p).toString();
/* 410 */ (str.toUpperCase().contains("E"))) { System.out.println("data 1>> "+data);
/* 411 */ return false; if (data.startsWith("=")) {
/* */ } System.out.println("Inside if data ");
/* 413 */ double d = Double.parseDouble(str); cell.setCellType(1);
/* */ } data = data.replaceAll("\"", "");
/* */ catch (NumberFormatException nfe) { data = data.replaceAll("=", "");
/* 416 */ return false;
/* */ } System.out.println("data 2>>"+data);
/* 418 */ return true; cell.setCellValue(data);
/* */ } }
/* */ } else if (data.startsWith(" ") || data.startsWith("\t")) {
System.out.println("Inside else if data ");
/* Location: C:\Users\pravin.nevage\Desktop\ibase3-webitm-sc2-0-1-5.jar cell.setCellType(1);
* Qualified Name: ibase.webitm.ejb.sc.SFACSVToExcelConverter data = data.replaceAll("\t", "");
* JD-Core Version: 0.6.0 data = data.replaceAll(" ", "");
*/ System.out.println("data3>> "+data);
\ No newline at end of file cell.setCellValue(data);
}
else if (data.startsWith("\"")) {
System.out.println("Insdie \\");
data = data.replaceAll("\"", "");
System.out.println("data 4>> "+data);
cell.setCellType(1);
cell.setCellValue(data);
}
else if ((isNumeric(data)) && (!data.startsWith("0")))
{
System.out.println("In Numeric");
cell.setCellStyle(style);
cell.setCellType(0);
cell.setCellValue(Double.parseDouble(data));
}
else
{
System.out.println("Insdie replaceAll\\");
data = data.replaceAll("\"", "");
cell.setCellType(1);
cell.setCellValue(data);
}
data=null;
}
System.out.println();
}
FileOutputStream fileOut = new FileOutputStream(fName + ".xlsx");
hwb.write(fileOut);
fileOut.close();
reader.close();
//fis.close();
bufferedReader.close();
//myInput.close();
File f = new File(fName + ".csv");
Boolean value = Boolean.valueOf(f.delete());
f.deleteOnExit();
System.out.println("Value: " + value);
System.out.println("Your Excel File Has Been Generated With File Name= "+fName);
//sf.printLogFile("STDOUT", "Your Excel File Has Been Generated With division:: <" +division+">"+"File Name=",fName, conn);
sf.printLogFile("STDOUT", "File Generated Name:= :: <" +fileName+">",logFileName, conn);
}
else
{
System.out.println("No excel created........["+arList.size()+"");
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
public static boolean isNumeric(String str)
/* */ {
/* */ try {
/* 111 */ if ((str.toUpperCase().contains("A")) ||
/* 112 */ (str.toUpperCase().contains("B")) ||
/* 113 */ (str.toUpperCase().contains("C")) ||
/* 114 */ (str.toUpperCase().contains("D")) ||
/* 115 */ (str.toUpperCase().contains("E"))) {
/* 116 */ return false;
/* */ }
/* 118 */ double d = Double.parseDouble(str);
/* */ }
/* */ catch (NumberFormatException nfe) {
/* 121 */ return false;
/* */ }
/* 123 */ return true;
/* */ }
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment