wb.setPrintArea(0, 0, colCount, 0, rowCount);
HSSFFooter footer = sheet.getFooter();
footer.setCenter("Page " + HSSFFooter.page() + " of " + HSSFFooter.numPages());
// Fit Sheet to 1 page wide but very long
sheet.setAutobreaks(true);
HSSFPrintSetup ps = sheet.getPrintSetup();
ps.setFitWidth((short)1);
ps.setFitHeight((short)9999);
sheet.setGridsPrinted(true);
sheet.setHorizontallyCenter(true);
ps.setPaperSize(HSSFPrintSetup.LETTER_PAPERSIZE);
if(colCount > 5){ps.setLandscape(true);}
if(colCount > 10){ps.setPaperSize(HSSFPrintSetup.LEGAL_PAPERSIZE);}
if(colCount > 14){ps.setPaperSize(HSSFPrintSetup.EXECUTIVE_PAPERSIZE);}
// Set Margins
ps.setHeaderMargin((double) .35);
ps.setFooterMargin((double) .35);
sheet.setMargin(HSSFSheet.TopMargin, (double) .50);
sheet.setMargin(HSSFSheet.BottomMargin, (double) .50);
sheet.setMargin(HSSFSheet.LeftMargin, (double) .50);
sheet.setMargin(HSSFSheet.RightMargin, (double) .50);