I am creating a sheet with apache poi, it have a lot of column and row name so I create a lot of code, I have a lot of code duplicate, How can I can create a function and reuse it for another?
Workbook wb = new HSSFWorkbook();
Sheet sheet = wb.createSheet("Sheet1");
try (OutputStream os = new FileOutputStream("report.xls")) {
Row row;
Cell cell;
row = sheet.createRow(0);
cell = row.createCell(0);
cell.setCellValue("Shop:");
cell = row.createCell(1);
cell.setCellValue(4);
cell = row.createCell(6);
cell.setCellValue("Export Date:");
cell = row.createCell(7);
cell.setCellValue("14.06.2019");
// -----
row = sheet.createRow(2);
cell = row.createCell(0);
cell.setCellValue("Code Supervisor:");
cell = row.createCell(1);
cell.setCellValue(4);
cell = row.createCell(6);
cell.setCellValue("Audit Date:");
cell = row.createCell(7);
cell.setCellValue("dd.MM.yyyy");
//----
row = sheet.createRow(4);
cell = row.createCell(6);
cell.setCellValue("Shop Note:");
cell = row.createCell(7);
cell.setCellValue("Note something");
wb.write(os);
}catch(Exception e) {
System.out.println(e.getMessage());
}
Related
while hiding column in pivot table. text above pivot table also getting removedI want to hide one column in pivot table. If I remove that column then the functionality should not get effected. How can I achieve that functionality by removing or hiding that column in pivot table
public class Createxlsx {
public static void main(String[] args) throws FileNotFoundException, IOException, InvalidFormatException {
createPivotTable();
}
private static void createPivotTable() throws IOException, FileNotFoundException {
try (XSSFWorkbook wb = new XSSFWorkbook()) {
XSSFSheet sheet1 = wb.createSheet("1e");
XSSFSheet sheet = wb.createSheet("1econtent");
XSSFFont font = wb.createFont();
font.setFontHeightInPoints((short) 15);
font.setColor(IndexedColors.WHITE.getIndex());
// sheet.setTabColor(10);
/* CTColor color = CTColor.Factory.newInstance();
color.setIndexed(IndexedColors.RED.getIndex());
sheet.getCTWorksheet().getSheetPr().setTabColor(color);*/
// sheet1.setTabColor( new XSSFColor( Color.RED ) );
// sheet.setTabColor(1)
/* CTColor color = CTColor.Factory.newInstance();
color.setIndexed(IndexedColors.GREEN.getIndex());
sheet1.getCTWorksheet().getSheetPr().setTabColor(color); */
// sheet1.setTabColor(0);
//Set the tab color
// sheet.setTabColor(Color.getRed());
//Save the Excel file
//workbook.save(dataDir + "AsposeColoredTab_Out.xls");
CellStyle fontStyle = wb.createCellStyle();
fontStyle.setFont(font);
fontStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
fontStyle.setFillForegroundColor(IndexedColors.ORANGE.getIndex());
fontStyle.setWrapText(true);
CellStyle fontStyle1 = wb.createCellStyle();
fontStyle1.setFont(font);
fontStyle1.setFillPattern(FillPatternType.SOLID_FOREGROUND);
fontStyle1.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
fontStyle1.setWrapText(true);
CellStyle fontStyle2 = wb.createCellStyle();
fontStyle2.setFont(font);
fontStyle2.setFillPattern(FillPatternType.SOLID_FOREGROUND);
XSSFColor color = new XSSFColor();
color.setARGBHex("fcd5b4");
fontStyle2.setFillForegroundColor(color.getIndexed());
fontStyle2.setWrapText(true);
CellStyle fontStyle3 = wb.createCellStyle();
fontStyle3.setFont(font);
fontStyle3.setFillPattern(FillPatternType.SOLID_FOREGROUND);
XSSFColor color1 = new XSSFColor();
color1.setARGBHex("fcd5b4");
fontStyle3.setFillForegroundColor(color1.getIndexed());
fontStyle3.setWrapText(true);
sheet1.setDisplayGridlines(false);
sheet1.addMergedRegion(new CellRangeAddress(4,7,0,5));
sheet1.addMergedRegion(new CellRangeAddress(0,0,0,5));
sheet1.addMergedRegion(new CellRangeAddress(1,1,1,5));
sheet1.addMergedRegion(new CellRangeAddress(2,2,1,5));
sheet1.addMergedRegion(new CellRangeAddress(3,3,0,5));
sheet1.setColumnWidth(1, 25*256);
sheet1.setColumnWidth(2, 45*256);
Row row1 = sheet1.createRow(0);
Cell cell11 = row1.createCell(0);
cell11.setCellStyle(fontStyle);
cell11.setCellValue("XXX");
Row row2 = sheet1.createRow(1);
// row2.setRowStyle(fontStyle);
//row2.setRowStyle(fontStyle2);
Cell cell21 = row2.createCell(0);
//CellStyle alignCellStyle = cell21.getCellStyle();
CellStyle headerStyle = wb.createCellStyle();
headerStyle.setAlignment(HorizontalAlignment.RIGHT);
//alignCellStyle.setAlignment(HorizontalAlignment.RIGHT);
cell21.setCellValue("Preparued for:");
cell21.setCellStyle(fontStyle2);
Cell cell22 = row2.createCell(1);
cell22.setCellValue("Rerrrrts Tests");
cell22.setCellStyle(fontStyle2);
Row row3 = sheet1.createRow(2);
// row3.setRowStyle(fontStyle2);
Cell cell31 = row3.createCell(0);
CellStyle alignCellStyle1 = cell31.getCellStyle();
alignCellStyle1.setAlignment(HorizontalAlignment.RIGHT);
cell31.setCellValue("Time Period:");
cell31.setCellStyle(fontStyle2);
Cell cell32 = row3.createCell(1);
DataFormat poiFormat = wb.createDataFormat();
CellStyle cellStyle = wb.createCellStyle();
String excelFormatPattern = DateFormatConverter.convert(Locale.US, "mm/dd/yyyy");
cellStyle.setDataFormat(poiFormat.getFormat(excelFormatPattern));
cell32.setCellValue(new Date());
cell32.setCellStyle(fontStyle2);
Row row4 = sheet1.createRow(3);
Cell cell41 = row4.createCell(0);
cell41.setCellValue("Table 1e: Confs Created ");
//row4.setRowStyle(fontStyle1);
cell41.setCellStyle(fontStyle1);
Row row5 = sheet1.createRow(4);
//row5.setRowStyle(fontStyle2);
Cell cell51 = row5.createCell(0);
cell51.setCellValue("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
cell51.setCellStyle(fontStyle3);
setCellData(sheet,wb);
wb.getSheet("1econtent").setSelected(false);
wb.setSheetVisibility(wb.getSheetIndex("1econtent"),SheetVisibility.VISIBLE);
AreaReference source = new AreaReference("A1:D5", SpreadsheetVersion.EXCEL2007);
CellReference position = new CellReference(10,0);
XSSFPivotTable pivotTable = sheet1.createPivotTable(source, position,wb.getSheet("1econtent"));
pivotTable.addReportFilter(2);
pivotTable.addRowLabel(0);
pivotTable.addColumnLabel(DataConsolidateFunction.SUM, 1);
pivotTable.addColumnLabel(DataConsolidateFunction.SUM, 1,"% of value");
pivotTable.getCTPivotTableDefinition().getDataFields().getDataFieldArray(1).setShowDataAs(org.openxmlformats.schemas.spreadsheetml.x2006.main.STShowDataAs.PERCENT_OF_COL);
DataFormat dataformat = wb.createDataFormat();
short numFmtId = dataformat.getFormat("0.00%");
pivotTable.getCTPivotTableDefinition().getDataFields().getDataFieldArray(1).setNumFmtId(numFmtId);
pivotTable.getCTPivotTableDefinition().getPivotFields().getPivotFieldArray(0).setAutoShow(false);
pivotTable.getCTPivotTableDefinition().getPivotFields().getPivotFieldArray(0).getItems().getItemArray(0).unsetT();
pivotTable.getCTPivotTableDefinition().getPivotFields().getPivotFieldArray(0).getItems().getItemArray(0).setX((long)0);
pivotTable.getPivotCacheDefinition().getCTPivotCacheDefinition().getCacheFields().getCacheFieldArray(0).getSharedItems().addNewS().setV("Jane");
pivotTable.getCTPivotTableDefinition().getPageFields().getPageFieldArray(0).setItem(0);
sheet1.getRow(10);
pivotTable.getCTPivotTableDefinition().getPivotTableStyleInfo().setName("PivotStyleMedium10");
try (FileOutputStream fileOut = new FileOutputStream("ooxml-pivottablesa.xlsx")) {
wb.write(fileOut);
}
}
}
public static void setCellData(XSSFSheet sheet,XSSFWorkbook wb){
Row row1 = sheet.createRow(0);
// Create a cell and put a value in it.
Cell cell11 = row1.createCell(0);
cell11.setCellValue("Names");
Cell cell12 = row1.createCell(1);
cell12.setCellValue("Confts");
Cell cell13 = row1.createCell(2);
cell13.setCellValue("ConftsAS");
Cell cell14 = row1.createCell(3);
cell14.setCellValue("Human");
Row row2 = sheet.createRow(1);
Cell cell21 = row2.createCell(0);
cell21.setCellValue("Jane");
Cell cell22 = row2.createCell(1);
cell22.setCellValue(10);
Cell cell23 = row2.createCell(2);
cell23.setCellValue(100);
Cell cell24 = row2.createCell(3);
cell24.setCellValue("Yes");
Row row3 = sheet.createRow(2);
Cell cell31 = row3.createCell(0);
cell31.setCellValue("Tarzan");
Cell cell32 = row3.createCell(1);
cell32.setCellValue(5);
Cell cell33 = row3.createCell(2);
cell33.setCellValue(100);
Cell cell34 = row3.createCell(3);
cell34.setCellValue("Yes");
Row row4 = sheet.createRow(3);
Cell cell41 = row4.createCell(0);
cell41.setCellValue("Terk");
Cell cell42 = row4.createCell(1);
cell42.setCellValue(10);
Cell cell43 = row4.createCell(2);
cell43.setCellValue(90);
Cell cell44 = row4.createCell(3);
cell44.setCellValue("No");
cell44.getCellStyle().setHidden(false);
Row row5 = sheet.createRow(4);
Cell cell211 = row5.createCell(0);
cell211.setCellValue("Jane");
Cell cell221 = row5.createCell(1);
cell221.setCellValue(10);
Cell cell231 = row5.createCell(2);
cell231.setCellValue(60);
Cell cell241 = row5.createCell(3);
cell241.setCellValue("No");
cell241.getCellStyle().setHidden(false);
}
}
I want to hide one column in pivot table So as shown in this Image I want to hide first column how can I hide.
I want to insert two list in the same HSSFSheet I start by the first one and when I go to insert values of the second list the firstone is crushed
this is my method of generating excel file
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet spreadsheet = workbook.createSheet("employe db");
HSSFRow row = spreadsheet.createRow(0);
HSSFCell cell;
cell = row.createCell(0);
cell.setCellValue("Ref");
cell = row.createCell(1);
cell.setCellValue("Fournisseur");
cell = row.createCell(2);
cell.setCellValue("Produit");
cell = row.createCell(3);
cell.setCellValue("Quantité");
cell = row.createCell(4);
cell.setCellValue("Prix");
cell = row.createCell(5);
cell.setCellValue("Somme");
cell = row.createCell(6);
cell.setCellValue("Solde Avant");
cell = row.createCell(7);
cell.setCellValue("Après");
cell = row.createCell(8);
cell.setCellValue("Date");
cell = row.createCell(9);
cell.setCellValue("Description");
//paiement//
cell = row.createCell(14);
cell.setCellValue("Libellé");
cell = row.createCell(15);
cell.setCellValue("Type");
cell = row.createCell(16);
cell.setCellValue("Montant");
cell = row.createCell(17);
cell.setCellValue("Date ");
cell = row.createCell(18);
cell.setCellValue("Echance");
Iterator<AchatProduit> itr = list.iterator();
int i = 1;
while (itr.hasNext()) {
AchatProduit emp = (AchatProduit) itr.next();
row = spreadsheet.createRow(i);
cell = row.createCell(0);
cell.setCellValue(emp.getPk_seq());
cell = row.createCell(1);
cell.setCellValue(emp.getFournisseur().getNom() + " // " + emp.getFournisseur().getSociete());
cell = row.createCell(2);
cell.setCellValue(emp.getProduit().getLibelle());
cell = row.createCell(3);
cell.setCellValue(emp.getQuantite());
cell = row.createCell(4);
cell.setCellValue(emp.getPrix());
cell = row.createCell(5);
cell.setCellValue(emp.getSomme());
cell = row.createCell(6);
cell.setCellValue(emp.getSoldeAvant());
cell = row.createCell(7);
cell.setCellValue(emp.getSoldeApres());
cell = row.createCell(8);
cell.setCellValue(emp.getStringDateAchat());
cell = row.createCell(9);
cell.setCellValue(emp.getDescription());
i++;
}
Iterator<CompteFournisseur> itr2 = listPaiement.iterator();
int j = 1;
while (itr2.hasNext()) {
CompteFournisseur emp = (CompteFournisseur) itr2.next();
row = spreadsheet.createRow(j);/// line that cauz problem
cell = row.createCell(14);
cell.setCellValue(emp.getLibellePaiment());
cell = row.createCell(15);
cell.setCellValue(emp.getTypePaiement());
cell = row.createCell(16);
cell.setCellValue(emp.getMontant());
cell = row.createCell(17);
cell.setCellValue(emp.getStringDatePaiement());
cell = row.createCell(18);
cell.setCellValue(emp.getStringDateEcheance());
j++;
}
FileOutputStream out = null;
try {
String exepath = path;
if (exepath.endsWith(".xls") || exepath.endsWith(".xlsx")) {
out = new FileOutputStream(new File(exepath));
workbook.write(out);
out.close();
System.out.println("Executed successfully");
} else {
String bufpath = exepath.concat(".xls");
out = new FileOutputStream(new File(bufpath));
workbook.write(out);
out.close();
}
} catch (Exception aa) {
}
}
normaly the yellow area should have values also but when I call this row = spreadsheet.createRow(j); beacause j=1; so it crush the values of first iterator (it)
so there any way to insert values because I have two lists
thanks is advance
UPDATE
Iterator<CompteFournisseur> itr2 = listPaiement.iterator();
int j = 1;
while (itr2.hasNext()) {
CompteFournisseur emp = (CompteFournisseur) itr2.next();
row = spreadsheet.getRow(j);
if (row == null) {
row = spreadsheet.createRow(j);
cell = row.createCell(14);
cell.setCellValue(emp.getLibellePaiment());
cell = row.createCell(15);
cell.setCellValue(emp.getTypePaiement());
cell = row.createCell(16);
cell.setCellValue(emp.getMontant());
cell = row.createCell(17);
cell.setCellValue(emp.getStringDatePaiement());
cell = row.createCell(18);
cell.setCellValue(emp.getStringDateEcheance());
} else {
cell = row.createCell(14);
cell.setCellValue(emp.getLibellePaiment());
cell = row.createCell(15);
cell.setCellValue(emp.getTypePaiement());
cell = row.createCell(16);
cell.setCellValue(emp.getMontant());
cell = row.createCell(17);
cell.setCellValue(emp.getStringDatePaiement());
cell = row.createCell(18);
cell.setCellValue(emp.getStringDateEcheance());
}
j++;
}
I'm writing data into excel file using Apache Poi In Java Eclipse,Problem is when i add column aligned with each row,it override the previous column...here is the code before i add anything.
public static void main(String[] args) throws IOException {
XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet spreadsheet = workbook.createSheet("cellstyle");
XSSFRow row=spreadsheet.createRow(1);
XSSFCell cell;
row = spreadsheet.createRow((short) 4);
row.setHeight((short) 800);
cell = (XSSFCell) row.createCell((short) 5);
cell.setCellValue("Total Alerts raised");
spreadsheet.addMergedRegion(new CellRangeAddress(4,4,5,6));
row = spreadsheet.createRow(5);
cell = (XSSFCell) row.createCell(5);
cell.setCellValue("Critical");
row = spreadsheet.createRow(6);
cell = (XSSFCell) row.createCell(5);
cell.setCellValue("Warning");
row = spreadsheet.createRow(7);
cell = (XSSFCell) row.createCell(5);
cell.setCellValue("Total");
FileOutputStream out = new FileOutputStream(
new File("C:\\Users\\tshivhaser\\Desktop\\cellstyle.xlsx"));
workbook.write(out);
out.close();
System.out.println("cellstyle.xlsx written successfully");
}
I then add this piece of code...Critical,Warning and Total column becomes empty
row = spreadsheet.createRow(5);
cell = row.createCell(6);
cell.setCellValue(0);
row = spreadsheet.createRow(6);
cell = row.createCell(6);
cell.setCellValue(0);
row = spreadsheet.createRow(7);
cell = row.createCell(6);
cell.setCellValue(10);
Please help on how i can have all cells filled...
I have an app that reads an excel and gets the information. This is my code that reads the information from column 0 and column 1. I want to know a way to start only on row number 34 and skip row 1 from 33.
File file = new File(inFileName);
Workbook workBook = WorkbookFactory.create(file);
Sheet sheet = workBook.getSheetAt(0);
Iterator<Row> rowIter = sheet.rowIterator();
while(rowIter.hasNext()){
Row myRow =rowIter.next();
Cell cell1 = myRow.getCell(0);
Cell cell2 = myRow.getCell(1);
...
Iterator<Cell> cellIter = myRow.cellIterator();
while(cellIter.hasNext()){
Cell myCell = cellIter.next();
}
//bd.addAnimalls(cell1.toString(),cell2.toString());
Toast.makeText(getApplicationContext(), "on inserting", Toast.LENGTH_SHORT).show();
}
You can get specific rows using sheet.getRow(rowNum).
So your code can be changed to this:
File file = new File(inFileName);
Workbook workBook = WorkbookFactory.create(file);
Sheet sheet = workBook.getSheetAt(0);
int rowCtr = 33;
Row myRow = sheet.getRow(rowCtr++);
while (myRow != null) {
Cell cell1 = myRow.getCell(0);
// rest of your loop code
myRow = sheet.getRow(rowCtr++);
}
I have a Java Spring web application with Spring Security where the user enters a date, the
database is queried based on that date and the result is sent back to the user's browser as an excel file via HSSFWorkbook writing to ServletOutputStream.
If the date selected is in the weeks of 12/28/2013-1/4/2014, 1/12/2014-1/18-2014, 1/19/2014-1/25/2014, or 1/26/2014-2/1/2014 the file that is sent to the user for download is converted to the contentType "text/html" even though it is explicitly set to "application/x-ms-excel".
The resulting Excel file is corrupted and contains only strange symbols. This only happens when Spring-Security is included and so far, only for the dates listed.
If anyone has had this problem could you please let me know how you fixed it?
This generates the workbook:
public static HSSFWorkbook getExcelRemittance(HashMap<String,List> items)
{
List<ItemView> remit = items.get("remit");
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet;
sheet = workbook.createSheet("Final Remittance");
Row header = sheet.createRow(0);
Cell cell1 = header.createCell(0);
cell1.setCellValue("DISNEY INVOICE NUM");
Cell cell2 = header.createCell(1);
cell2.setCellValue("EBI AMOUNT");
Cell cell3 = header.createCell(2);
cell3.setCellValue("PAYING AMOUNT");
Cell cell4 = header.createCell(3);
cell4.setCellValue("RESIDUAL AMOUNT");
Cell cell5 = header.createCell(4);
cell5.setCellValue("BOOKING #");
Cell cell6 = header.createCell(5);
cell6.setCellValue("GUEST NAME");
Cell cell7 = header.createCell(6);
cell7.setCellValue("NOTES/Dispute Reason");
int count = 1;
double total = 0.0;
for(ItemView v : remit)
{
Row row = sheet.createRow(count++);
Cell c1 = row.createCell(0);
c1.setCellValue(v.getDisneyInvoiceNum());
Cell c2 = row.createCell(1);
c2.setCellValue(v.getEbiAmount());
Cell c3 = row.createCell(2);
c3.setCellValue(v.getEbiAmount());
Cell c4 = row.createCell(3);
c4.setCellValue("-");
Cell c5 = row.createCell(4);
c5.setCellValue("");
Cell c6 = row.createCell(5);
c6.setCellValue("");
Cell c7 = row.createCell(6);
c7.setCellValue("");
total+=v.getEbiAmount();
}
Row subTotalRemit = sheet.createRow(sheet.getLastRowNum()+1);
int subTotalRow1 = sheet.getLastRowNum()+1;
Cell t = subTotalRemit.createCell(0);
t.setCellValue("subtotal");
Cell tAmt = subTotalRemit.createCell(1);
tAmt.setCellFormula("SUM(B2:B"+sheet.getLastRowNum()+")");
List<ItemView> past = items.get("prev");
Row prevHead = sheet.createRow(count+6);
Cell remitTitle = prevHead.createCell(0);
remitTitle.setCellValue("Invoices from previous batches");
CellStyle cs = workbook.createCellStyle();
Font f = workbook.createFont();
f.setBoldweight(Font.BOLDWEIGHT_BOLD);
cs.setFont(f);
remitTitle.setCellStyle(cs);
Row prevCols = sheet.createRow(sheet.getLastRowNum()+1);
Cell ph1= prevCols.createCell(0);
ph1.setCellValue("Invoice Number");
Cell ph2= prevCols.createCell(1);
ph2.setCellValue("Invoice Amount");
Cell ph3= prevCols.createCell(2);
ph3.setCellValue("Paying Amount");
Cell ph4= prevCols.createCell(3);
ph4.setCellValue("Residual Amount");
Cell ph5= prevCols.createCell(4);
ph5.setCellValue("Booking #");
Cell ph6= prevCols.createCell(5);
ph6.setCellValue("Guest Name");
Cell ph7= prevCols.createCell(6);
ph7.setCellValue("Notes/Dispute Reason");
int sum1 = sheet.getLastRowNum()+1;
for(ItemView v : past)
{
Row row = sheet.createRow(sheet.getLastRowNum()+1);
Cell c1 = row.createCell(0);
c1.setCellValue(v.getDisneyInvoiceNum());
Cell c2 = row.createCell(1);
c2.setCellValue(v.getEbiAmount());
Cell c3 = row.createCell(2);
c3.setCellValue(v.getAmountPaid());
Cell c4 = row.createCell(3);
c4.setCellValue(v.getDiffEbiApAmt());
Cell c5 = row.createCell(4);
c5.setCellValue("");
Cell c6 = row.createCell(5);
c6.setCellValue("");
Cell c7 = row.createCell(6);
c7.setCellValue(v.getNotes());
}
Row subTotalPrev = sheet.createRow(sheet.getLastRowNum()+1);
Cell tP = subTotalPrev.createCell(1);
tP.setCellValue("subtotal");
Cell tAmtP = subTotalPrev.createCell(2);
tAmtP.setCellFormula("SUM(C"+sum1+":C"+sheet.getLastRowNum()+")");
Row gTotal = sheet.createRow(sheet.getLastRowNum()+1);
Cell gtP = gTotal.createCell(1);
gtP.setCellValue("Total");
Cell gtAmtP = gTotal.createCell(2);
gtAmtP.setCellFormula("B"+subTotalRow1+"+C"+(sheet.getLastRowNum()));
return workbook;
}
This is the code that sends the file to the user:
#RequestMapping(value="generateRemit")
public #ResponseBody String getRemitExcel(
#RequestParam("date") String date,
HttpServletResponse response)
{
ServletOutputStream out;
HSSFWorkbook book = Utils.getExcelRemittance(jdbcBillingDao.getWeeklyRemit(date));
try {
response.setContentType("application/x-ms-excel");
response.setHeader("Content-Disposition","attachment;filename="+date+"Remittance Final.xls");
out = response.getOutputStream();
log.info("writing to output stream");
book.write(out);
out.flush();
log.info("finished writing to output stream");
// return book.toString();
} catch (IOException e) {
e.printStackTrace();
log.info("Error writing to file output stream");
return e.toString();
}
return "success";
}
Fixed it by returning an AbstractExcelView instead of a redirect:
#RequestMapping(value="generateRemit")
protected View remitExcel( #RequestParam("date") String date)
{
final String finalDate = date;
return new AbstractExcelView() {
#Override
protected void buildExcelDocument(Map<String, Object> model, HSSFWorkbook workbook,
HttpServletRequest request, HttpServletResponse response) throws Exception {
response.addHeader("Content-Disposition", "attachment; filename=\""+finalDate+"Disney Remittance Final\"");
HashMap<String,List> items = jdbcBillingDao.getWeeklyRemit(finalDate);
HSSFSheet sheet = workbook.createSheet("Final Remittance");
#SuppressWarnings("unchecked")
List<ItemView> remit = items.get("remit");
Row header = sheet.createRow(0);
Cell cell1 = header.createCell(0);
cell1.setCellValue("DISNEY INVOICE NUM");
Cell cell2 = header.createCell(1);
cell2.setCellValue("EBI AMOUNT");
Cell cell3 = header.createCell(2);
cell3.setCellValue("PAYING AMOUNT");
Cell cell4 = header.createCell(3);
cell4.setCellValue("RESIDUAL AMOUNT");
Cell cell5 = header.createCell(4);
cell5.setCellValue("BOOKING #");
Cell cell6 = header.createCell(5);
cell6.setCellValue("GUEST NAME");
Cell cell7 = header.createCell(6);
cell7.setCellValue("NOTES/Dispute Reason");
//more spreadsheet generation
}
};
}