Subversion Repositories SmartDukaan

Rev

Rev 23568 | Rev 24052 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 23568 Rev 23819
Line 5... Line 5...
5
import java.io.OutputStream;
5
import java.io.OutputStream;
6
import java.time.LocalDateTime;
6
import java.time.LocalDateTime;
7
import java.time.ZoneId;
7
import java.time.ZoneId;
8
import java.util.ArrayList;
8
import java.util.ArrayList;
9
import java.util.Date;
9
import java.util.Date;
-
 
10
import java.util.Iterator;
-
 
11
import java.util.LinkedHashMap;
10
import java.util.List;
12
import java.util.List;
-
 
13
import java.util.Map;
-
 
14
import java.util.Map.Entry;
-
 
15
import java.util.Set;
11
 
16
 
12
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
17
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
13
import org.apache.poi.ss.usermodel.Cell;
18
import org.apache.poi.ss.usermodel.Cell;
14
import org.apache.poi.ss.usermodel.CellStyle;
19
import org.apache.poi.ss.usermodel.CellStyle;
15
import org.apache.poi.ss.usermodel.CellType;
20
import org.apache.poi.ss.usermodel.CellType;
Line 534... Line 539...
534
		
539
		
535
		for(int index = 0; index < 14; index++){
540
		for(int index = 0; index < 14; index++){
536
			sheet.autoSizeColumn(index);
541
			sheet.autoSizeColumn(index);
537
		}
542
		}
538
		
543
		
-
 
544
	    try{
-
 
545
			workbook.write(outputStream);
-
 
546
	    	workbook.close();
-
 
547
	    }catch(IOException ioException){
-
 
548
	    	LOGGER.error("Unable to generate excel file", ioException);
-
 
549
	    }
-
 
550
	}
-
 
551
	public static void writePriceDrop(Map<String, String> priceDropIMEIfofoId,int itemId,OutputStream outputStream){
-
 
552
		SXSSFWorkbook workbook = new SXSSFWorkbook();
-
 
553
	    
-
 
554
		//CreationHelper createHelper = workbook.getCreationHelper();
-
 
555
	    
-
 
556
		SXSSFSheet sheet = workbook.createSheet("Schemes");
-
 
557
		sheet.trackAllColumnsForAutoSizing();
-
 
558
		
-
 
559
		
-
 
560
	    Row rowHeader = sheet.createRow(0);
-
 
561
	    Cell cellItemHeader = rowHeader.createCell(0);
-
 
562
	    cellItemHeader.setCellValue("ITEMID");
-
 
563
		Cell cellIMEIHeader = rowHeader.createCell(1);
-
 
564
		cellIMEIHeader.setCellValue("IMEI");
-
 
565
		Cell cellFOFOIDHeader = rowHeader.createCell(2);
-
 
566
		cellFOFOIDHeader.setCellValue("RETAILERNAME");
-
 
567
		//Row rowQuantityRateValue = sheet.createRow(1);
-
 
568
		
-
 
569
		/*for(int index = 6; index < 18; index = index + 3){
-
 
570
			Cell cellQuantityHeader = rowQuantityRateValue.createCell(index);
-
 
571
			cellQuantityHeader.setCellValue("Quantity");
-
 
572
			Cell cellRateHeader = rowQuantityRateValue.createCell(index + 1);
-
 
573
			cellRateHeader.setCellValue("Rate");
-
 
574
			Cell cellValueHeader = rowQuantityRateValue.createCell(index + 2);
-
 
575
			cellValueHeader.setCellValue("Value");
-
 
576
			sheet.addMergedRegion(new CellRangeAddress(0, 0, index, index + 2));
-
 
577
		}*/
-
 
578
		Font font = workbook.createFont();
-
 
579
		CellStyle cellStyle = workbook.createCellStyle();
-
 
580
		font.setBold(true);
-
 
581
		cellStyle.setAlignment(HorizontalAlignment.CENTER);
-
 
582
		//font.setFontHeight((short)16);
-
 
583
		cellStyle.setFont(font);
-
 
584
		for(int i = 0; i < 14; i++){
-
 
585
			if(rowHeader.getCell(i) != null){
-
 
586
				rowHeader.getCell(i).setCellStyle(cellStyle);
-
 
587
			}
-
 
588
		}
-
 
589
		LinkedHashMap<String,String> priceAmount=new LinkedHashMap<>(priceDropIMEIfofoId);
-
 
590
		Set<String> keyset=priceAmount.keySet();
-
 
591
		int rownum = 1;
-
 
592
		for (String key : keyset) {
-
 
593
            Row row = sheet.createRow(rownum++);
-
 
594
            String objArr = priceAmount.get(key);
-
 
595
            int cellnum = 0;
-
 
596
            Cell cell = row.createCell(cellnum++);
-
 
597
            cell.setCellValue(itemId);
-
 
598
            Cell cell1 = row.createCell(cellnum++);
-
 
599
            cell1.setCellValue(key);
-
 
600
            Cell cell2 = row.createCell(cellnum++);
-
 
601
            cell2.setCellValue(priceAmount.get(key));
-
 
602
            }
-
 
603
		
-
 
604
		for(int index = 0; index < 14; index++){
-
 
605
			sheet.autoSizeColumn(index);
-
 
606
		}
-
 
607
		
-
 
608
	    try{
-
 
609
			workbook.write(outputStream);
-
 
610
	    	workbook.close();
-
 
611
	    }catch(IOException ioException){
-
 
612
	    	LOGGER.error("Unable to generate excel file", ioException);
-
 
613
	    }
-
 
614
	}
-
 
615
	public static void writePriceDropForAllIMEI(Map<String,String>priceDropAmount,OutputStream outputStream){
-
 
616
		SXSSFWorkbook workbook = new SXSSFWorkbook();
-
 
617
	    
-
 
618
		//CreationHelper createHelper = workbook.getCreationHelper();
-
 
619
	    
-
 
620
		SXSSFSheet sheet = workbook.createSheet("Schemes");
-
 
621
		sheet.trackAllColumnsForAutoSizing();
-
 
622
		
-
 
623
		
-
 
624
	    Row rowHeader = sheet.createRow(0);
-
 
625
	    Cell cellItemHeader = rowHeader.createCell(0);
-
 
626
	    cellItemHeader.setCellValue("Itemdescription");
-
 
627
		Cell cellIMEIHeader = rowHeader.createCell(1);
-
 
628
		cellIMEIHeader.setCellValue("IMEI");
-
 
629
		//Row rowQuantityRateValue = sheet.createRow(1);
-
 
630
		
-
 
631
		/*for(int index = 6; index < 18; index = index + 3){
-
 
632
			Cell cellQuantityHeader = rowQuantityRateValue.createCell(index);
-
 
633
			cellQuantityHeader.setCellValue("Quantity");
-
 
634
			Cell cellRateHeader = rowQuantityRateValue.createCell(index + 1);
-
 
635
			cellRateHeader.setCellValue("Rate");
-
 
636
			Cell cellValueHeader = rowQuantityRateValue.createCell(index + 2);
-
 
637
			cellValueHeader.setCellValue("Value");
-
 
638
			sheet.addMergedRegion(new CellRangeAddress(0, 0, index, index + 2));
-
 
639
		}*/
-
 
640
		Font font = workbook.createFont();
-
 
641
		CellStyle cellStyle = workbook.createCellStyle();
-
 
642
		font.setBold(true);
-
 
643
		cellStyle.setAlignment(HorizontalAlignment.CENTER);
-
 
644
		//font.setFontHeight((short)16);
-
 
645
		cellStyle.setFont(font);
-
 
646
		for(int i = 0; i < 14; i++){
-
 
647
			if(rowHeader.getCell(i) != null){
-
 
648
				rowHeader.getCell(i).setCellStyle(cellStyle);
-
 
649
			}
-
 
650
		}
-
 
651
		Set<String> keyset=priceDropAmount.keySet();
-
 
652
		int rownum = 1;
-
 
653
		for (String key : keyset) {
-
 
654
            Row row = sheet.createRow(rownum++);
-
 
655
            String objArr = priceDropAmount.get(key);
-
 
656
            int cellnum = 0;
-
 
657
            Cell cell = row.createCell(cellnum++);
-
 
658
            cell.setCellValue(priceDropAmount.get(key));
-
 
659
            Cell cell1 = row.createCell(cellnum++);
-
 
660
            cell1.setCellValue(key);
-
 
661
            }
-
 
662
		
-
 
663
		for(int index = 0; index < 14; index++){
-
 
664
			sheet.autoSizeColumn(index);
-
 
665
		}
-
 
666
		
539
	    try{
667
	    try{
540
			workbook.write(outputStream);
668
			workbook.write(outputStream);
541
	    	workbook.close();
669
	    	workbook.close();
542
	    }catch(IOException ioException){
670
	    }catch(IOException ioException){
543
	    	LOGGER.error("Unable to generate excel file", ioException);
671
	    	LOGGER.error("Unable to generate excel file", ioException);