Subversion Repositories SmartDukaan

Rev

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

Rev 22470 Rev 22486
Line 1... Line 1...
1
package com.spice.profitmandi.common.util;
1
package com.spice.profitmandi.common.util;
2
 
2
 
3
import java.io.FileOutputStream;
-
 
4
import java.io.IOException;
3
import java.io.IOException;
5
import java.io.InputStream;
4
import java.io.InputStream;
6
import java.io.OutputStream;
5
import java.io.OutputStream;
7
import java.time.LocalDateTime;
6
import java.time.LocalDateTime;
8
import java.time.ZoneId;
7
import java.time.ZoneId;
Line 12... Line 11...
12
 
11
 
13
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
12
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
14
import org.apache.poi.ss.usermodel.Cell;
13
import org.apache.poi.ss.usermodel.Cell;
15
import org.apache.poi.ss.usermodel.CellStyle;
14
import org.apache.poi.ss.usermodel.CellStyle;
16
import org.apache.poi.ss.usermodel.CellType;
15
import org.apache.poi.ss.usermodel.CellType;
17
import org.apache.poi.ss.usermodel.CreationHelper;
-
 
18
import org.apache.poi.ss.usermodel.Font;
16
import org.apache.poi.ss.usermodel.Font;
19
import org.apache.poi.ss.usermodel.Row;
17
import org.apache.poi.ss.usermodel.Row;
20
import org.apache.poi.ss.usermodel.Row.MissingCellPolicy;
18
import org.apache.poi.ss.usermodel.Row.MissingCellPolicy;
21
import org.apache.poi.ss.util.CellRangeAddress;
19
import org.apache.poi.ss.util.CellRangeAddress;
22
import org.apache.poi.xssf.streaming.SXSSFSheet;
20
import org.apache.poi.xssf.streaming.SXSSFSheet;
23
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
21
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
24
import org.apache.poi.xssf.usermodel.XSSFRichTextString;
-
 
25
import org.apache.poi.xssf.usermodel.XSSFRow;
22
import org.apache.poi.xssf.usermodel.XSSFRow;
26
import org.apache.poi.xssf.usermodel.XSSFSheet;
23
import org.apache.poi.xssf.usermodel.XSSFSheet;
27
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
24
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
28
import org.slf4j.Logger;
25
import org.slf4j.Logger;
29
import org.slf4j.LoggerFactory;
26
import org.slf4j.LoggerFactory;
Line 134... Line 131...
134
			}
131
			}
135
		}
132
		}
136
		return tagListings;
133
		return tagListings;
137
	}
134
	}
138
	
135
	
139
	public static OutputStream writeInventoryItemAgingModels(List<InventoryItemAgingModel> inventoryItemAgingModels, List<Integer> intervals){
136
	public static OutputStream writeInventoryItemAgingModels(List<InventoryItemAgingModel> inventoryItemAgingModels, List<Integer> intervals, OutputStream outputStream){
140
		SXSSFWorkbook workbook = new SXSSFWorkbook();
137
		SXSSFWorkbook workbook = new SXSSFWorkbook();
141
	    
138
	    
142
		//CreationHelper createHelper = workbook.getCreationHelper();
139
		//CreationHelper createHelper = workbook.getCreationHelper();
143
	    
140
	    
144
		SXSSFSheet sheet = workbook.createSheet("InventoryItemAging");
141
		SXSSFSheet sheet = workbook.createSheet("InventoryItemAging");
Line 184... Line 181...
184
		Font font = workbook.createFont();
181
		Font font = workbook.createFont();
185
		CellStyle cellStyle = workbook.createCellStyle();
182
		CellStyle cellStyle = workbook.createCellStyle();
186
		font.setBold(true);
183
		font.setBold(true);
187
		//font.setFontHeight((short)16);
184
		//font.setFontHeight((short)16);
188
		cellStyle.setFont(font);
185
		cellStyle.setFont(font);
189
		for(int i = 0; i < 18; i++){
186
		for(int i = 0; i < 8 + (intervals.size() * 2); i++){
190
			rowHeader.getCell(i).setCellStyle(cellStyle);
187
			rowHeader.getCell(i).setCellStyle(cellStyle);
191
			if(rowPriceQuantity.getCell(i) != null){
188
			if(rowPriceQuantity.getCell(i) != null){
192
				rowPriceQuantity.getCell(i).setCellStyle(cellStyle);
189
				rowPriceQuantity.getCell(i).setCellStyle(cellStyle);
193
			}
190
			}
194
		}
191
		}
Line 223... Line 220...
223
	    			cellQuantity.setCellValue("NA");
220
	    			cellQuantity.setCellValue("NA");
224
	    		}
221
	    		}
225
	    	}
222
	    	}
226
	    }
223
	    }
227
		
224
		
228
		for(int index = 0; index < 18; index++){
225
		for(int index = 0; index < 8 + (intervals.size() * 2); index++){
229
			sheet.autoSizeColumn(index);
226
			sheet.autoSizeColumn(index);
230
		}
227
		}
231
		
228
		
232
	    try{
229
	    try{
233
	    	FileOutputStream fileOutputStream = new FileOutputStream("/home/ashikali/Documents/testInventoryItemAging.xlsx");
-
 
234
			workbook.write(fileOutputStream);
230
			workbook.write(outputStream);
235
	    	workbook.close();
231
	    	workbook.close();
236
	    }catch(IOException ioException){
232
	    }catch(IOException ioException){
237
	    	LOGGER.info("Unable to generate excel file", ioException);
233
	    	LOGGER.error("Unable to generate excel file", ioException);
238
	    }
234
	    }
239
	    return null;
235
	    return null;
240
	}
236
	}
241
	
237
	
242
}
238
}