List of usage examples for org.apache.poi.ss.usermodel Font setFontHeightInPoints
void setFontHeightInPoints(short height);
From source file:org.sigmah.server.endpoint.export.sigmah.spreadsheet.ExcelUtils.java
License:Open Source License
public Font getBoldFont(Workbook wb, short size) { Font font = wb.createFont(); font.setFontHeightInPoints(size); font.setBoldweight(Font.BOLDWEIGHT_BOLD); return font;// w w w . jav a 2 s .c o m }
From source file:org.sigmah.server.endpoint.export.sigmah.spreadsheet.ExcelUtils.java
License:Open Source License
public Font getItalicFont(Workbook wb, short size) { Font font = wb.createFont(); font.setFontHeightInPoints(size); font.setItalic(true);/* w ww. jav a 2 s . co m*/ return font; }
From source file:org.sleuthkit.autopsy.report.ReportExcel.java
License:Open Source License
/** * Start the Excel report by creating the Workbook, initializing styles, * and writing the summary.// w ww .j av a 2 s . co m * @param path path to save the report */ @Override public void startReport(String path) { // Set the path and save it for when the report is written to disk. this.reportPath = path + getRelativeFilePath(); // Make a workbook. wb = new XSSFWorkbook(); // Create some cell styles. // TODO: The commented out cell style settings below do not work as desired when // the output file is loaded by MS Excel or OfficeLibre. The font height and weight // settings only work as expected when the output file is loaded by OfficeLibre. // The alignment and text wrap settings appear to have no effect. titleStyle = wb.createCellStyle(); // titleStyle.setBorderBottom((short) 1); Font titleFont = wb.createFont(); titleFont.setFontHeightInPoints((short) 12); titleStyle.setFont(titleFont); titleStyle.setAlignment(CellStyle.ALIGN_LEFT); titleStyle.setWrapText(true); setStyle = wb.createCellStyle(); Font setFont = wb.createFont(); setFont.setFontHeightInPoints((short) 14); setFont.setBoldweight((short) 10); setStyle.setFont(setFont); setStyle.setAlignment(CellStyle.ALIGN_LEFT); setStyle.setWrapText(true); elementStyle = wb.createCellStyle(); // elementStyle.setF illBackgroundColor(HSSFColor.LIGHT_YELLOW.index); Font elementFont = wb.createFont(); elementFont.setFontHeightInPoints((short) 14); elementStyle.setFont(elementFont); elementStyle.setAlignment(CellStyle.ALIGN_LEFT); elementStyle.setWrapText(true); writeSummaryWorksheet(); }
From source file:org.sleuthkit.autopsy.report.ReportXLS.java
License:Apache License
@Override public String generateReport(ReportConfiguration reportconfig) throws ReportModuleException { config = reportconfig;//w w w . ja v a 2s .co m ReportGen reportobj = new ReportGen(); reportobj.populateReport(reportconfig); HashMap<BlackboardArtifact, ArrayList<BlackboardAttribute>> report = reportobj.Results; Workbook wbtemp = new XSSFWorkbook(); int countGen = 0; int countBookmark = 0; int countCookie = 0; int countHistory = 0; int countDownload = 0; int countRecentObjects = 0; int countTrackPoint = 0; int countInstalled = 0; int countKeyword = 0; int countHash = 0; int countDevice = 0; int countEmail = 0; for (Entry<BlackboardArtifact, ArrayList<BlackboardAttribute>> entry : report.entrySet()) { if (entry.getKey().getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_GEN_INFO.getTypeID()) { countGen++; } if (entry.getKey().getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_BOOKMARK .getTypeID()) { countBookmark++; } if (entry.getKey().getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_COOKIE.getTypeID()) { countCookie++; } if (entry.getKey().getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_HISTORY .getTypeID()) { countHistory++; } if (entry.getKey().getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_DOWNLOAD .getTypeID()) { countDownload++; } if (entry.getKey().getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_RECENT_OBJECT .getTypeID()) { countRecentObjects++; } if (entry.getKey().getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_TRACKPOINT.getTypeID()) { countTrackPoint++; } if (entry.getKey().getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_INSTALLED_PROG .getTypeID()) { countInstalled++; } if (entry.getKey().getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_KEYWORD_HIT .getTypeID()) { countKeyword++; } if (entry.getKey().getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_HASHSET_HIT .getTypeID()) { countHash++; } if (entry.getKey().getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_DEVICE_ATTACHED .getTypeID()) { countDevice++; } if (entry.getKey().getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_EMAIL_MSG.getTypeID()) { countEmail++; } } try { Case currentCase = Case.getCurrentCase(); // get the most updated case SleuthkitCase skCase = currentCase.getSleuthkitCase(); String caseName = currentCase.getName(); Integer imagecount = currentCase.getImageIDs().length; Integer filesystemcount = currentCase.getRootObjectsCount(); Integer totalfiles = skCase.countFsContentType(TskData.TSK_FS_META_TYPE_ENUM.TSK_FS_META_TYPE_REG); Integer totaldirs = skCase.countFsContentType(TskData.TSK_FS_META_TYPE_ENUM.TSK_FS_META_TYPE_DIR); DateFormat datetimeFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); DateFormat dateFormat = new SimpleDateFormat("MM-dd-yyyy-HH-mm-ss"); Date date = new Date(); String datetime = datetimeFormat.format(date); String datenotime = dateFormat.format(date); //The first summary report page Sheet sheetSummary = wbtemp.createSheet("Summary"); //Generate a sheet per artifact type // Sheet sheetGen = wbtemp.createSheet(BlackboardArtifact.ARTIFACT_TYPE.TSK_GEN_INFO.getDisplayName()); Sheet sheetHash = wbtemp.createSheet(BlackboardArtifact.ARTIFACT_TYPE.TSK_HASHSET_HIT.getDisplayName()); Sheet sheetDevice = wbtemp .createSheet(BlackboardArtifact.ARTIFACT_TYPE.TSK_DEVICE_ATTACHED.getDisplayName()); Sheet sheetInstalled = wbtemp .createSheet(BlackboardArtifact.ARTIFACT_TYPE.TSK_INSTALLED_PROG.getDisplayName()); Sheet sheetKeyword = wbtemp .createSheet(BlackboardArtifact.ARTIFACT_TYPE.TSK_KEYWORD_HIT.getDisplayName()); // Sheet sheetTrackpoint = wbtemp.createSheet(BlackboardArtifact.ARTIFACT_TYPE.TSK_TRACKPOINT.getDisplayName()); Sheet sheetRecent = wbtemp .createSheet(BlackboardArtifact.ARTIFACT_TYPE.TSK_RECENT_OBJECT.getDisplayName()); Sheet sheetCookie = wbtemp .createSheet(BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_COOKIE.getDisplayName()); Sheet sheetBookmark = wbtemp .createSheet(BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_BOOKMARK.getDisplayName()); Sheet sheetDownload = wbtemp .createSheet(BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_DOWNLOAD.getDisplayName()); Sheet sheetHistory = wbtemp .createSheet(BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_HISTORY.getDisplayName()); Sheet sheetEmail = wbtemp.createSheet(BlackboardArtifact.ARTIFACT_TYPE.TSK_EMAIL_MSG.getDisplayName()); //Bold/underline cell style for the top header rows CellStyle style = wbtemp.createCellStyle(); style.setBorderBottom((short) 2); Font font = wbtemp.createFont(); font.setFontHeightInPoints((short) 14); font.setFontName("Arial"); font.setBoldweight((short) 2); style.setFont(font); //create 'default' style CellStyle defaultstyle = wbtemp.createCellStyle(); defaultstyle.setBorderBottom((short) 2); Font defaultfont = wbtemp.createFont(); defaultfont.setFontHeightInPoints((short) 14); defaultfont.setFontName("Arial"); defaultfont.setBoldweight((short) 2); defaultstyle.setFont(defaultfont); //create the rows in the worksheet for our records //Create first row and header // sheetGen.createRow(0); // sheetGen.getRow(0).createCell(0).setCellValue("Name"); // sheetGen.getRow(0).createCell(1).setCellValue("Value"); // sheetGen.getRow(0).createCell(2).setCellValue("Date/Time"); sheetSummary.setDefaultColumnStyle(1, defaultstyle); sheetSummary.createRow(0).setRowStyle(style); sheetSummary.getRow(0).createCell(0).setCellValue("Summary Information"); sheetSummary.getRow(0).createCell(1).setCellValue(caseName); //add some basic information sheetSummary.createRow(1).setRowStyle(defaultstyle); sheetSummary.getRow(1).createCell(0).setCellValue("# of Images"); sheetSummary.getRow(1).createCell(1).setCellValue(imagecount); sheetSummary.createRow(2); sheetSummary.getRow(2).createCell(0).setCellValue("Filesystems found"); sheetSummary.getRow(2).createCell(1).setCellValue(imagecount); sheetSummary.createRow(3); sheetSummary.getRow(3).createCell(0).setCellValue("# of Files"); sheetSummary.getRow(3).createCell(1).setCellValue(totalfiles); sheetSummary.createRow(4); sheetSummary.getRow(4).createCell(0).setCellValue("# of Directories"); sheetSummary.getRow(4).createCell(1).setCellValue(totaldirs); sheetSummary.createRow(5); sheetSummary.getRow(5).createCell(0).setCellValue("Date/Time"); sheetSummary.getRow(5).createCell(1).setCellValue(datetime); sheetHash.setDefaultColumnStyle(1, defaultstyle); sheetHash.createRow(0).setRowStyle(style); sheetHash.getRow(0).createCell(0).setCellValue("Name"); sheetHash.getRow(0).createCell(1).setCellValue("Size"); sheetHash.getRow(0).createCell(2).setCellValue("Hashset Name"); sheetDevice.setDefaultColumnStyle(1, defaultstyle); sheetDevice.createRow(0).setRowStyle(style); sheetDevice.getRow(0).createCell(0).setCellValue("Name"); sheetDevice.getRow(0).createCell(1).setCellValue("Serial #"); sheetDevice.getRow(0).createCell(2).setCellValue("Time"); sheetInstalled.setDefaultColumnStyle(1, defaultstyle); sheetInstalled.createRow(0).setRowStyle(style); sheetInstalled.getRow(0).createCell(0).setCellValue("Program Name"); sheetInstalled.getRow(0).createCell(1).setCellValue("Install Date/Time"); sheetKeyword.setDefaultColumnStyle(1, defaultstyle); sheetKeyword.createRow(0).setRowStyle(style); sheetKeyword.getRow(0).createCell(0).setCellValue("Keyword"); sheetKeyword.getRow(0).createCell(1).setCellValue("File Name"); sheetKeyword.getRow(0).createCell(2).setCellValue("Preview"); sheetKeyword.getRow(0).createCell(3).setCellValue("Keyword List"); sheetRecent.setDefaultColumnStyle(1, defaultstyle); sheetRecent.createRow(0).setRowStyle(style); sheetRecent.getRow(0).createCell(0).setCellValue("Name"); sheetRecent.getRow(0).createCell(1).setCellValue("Path"); sheetRecent.getRow(0).createCell(2).setCellValue("Related Shortcut"); sheetCookie.setDefaultColumnStyle(1, defaultstyle); sheetCookie.createRow(0).setRowStyle(style); sheetCookie.getRow(0).createCell(0).setCellValue("URL"); sheetCookie.getRow(0).createCell(1).setCellValue("Date"); sheetCookie.getRow(0).createCell(2).setCellValue("Name"); sheetCookie.getRow(0).createCell(3).setCellValue("Value"); sheetCookie.getRow(0).createCell(4).setCellValue("Program"); sheetBookmark.setDefaultColumnStyle(1, defaultstyle); sheetBookmark.createRow(0).setRowStyle(style); sheetBookmark.getRow(0).createCell(0).setCellValue("URL"); sheetBookmark.getRow(0).createCell(1).setCellValue("Title"); sheetBookmark.getRow(0).createCell(2).setCellValue("Program"); sheetDownload.setDefaultColumnStyle(1, defaultstyle); sheetDownload.createRow(0).setRowStyle(style); sheetDownload.getRow(0).createCell(0).setCellValue("File"); sheetDownload.getRow(0).createCell(1).setCellValue("Source"); sheetDownload.getRow(0).createCell(2).setCellValue("Time"); sheetDownload.getRow(0).createCell(3).setCellValue("Program"); sheetHistory.setDefaultColumnStyle(1, defaultstyle); sheetHistory.createRow(0).setRowStyle(style); sheetHistory.getRow(0).createCell(0).setCellValue("URL"); sheetHistory.getRow(0).createCell(1).setCellValue("Date"); sheetHistory.getRow(0).createCell(2).setCellValue("Referrer"); sheetHistory.getRow(0).createCell(3).setCellValue("Title"); sheetHistory.getRow(0).createCell(4).setCellValue("Program"); sheetEmail.setDefaultColumnStyle(1, defaultstyle); sheetEmail.createRow(0).setRowStyle(style); sheetEmail.getRow(0).createCell(0).setCellValue("From"); sheetEmail.getRow(0).createCell(1).setCellValue("To"); sheetEmail.getRow(0).createCell(2).setCellValue("Subject"); sheetEmail.getRow(0).createCell(3).setCellValue("Date/Time"); sheetEmail.getRow(0).createCell(4).setCellValue("Content"); sheetEmail.getRow(0).createCell(5).setCellValue("CC"); sheetEmail.getRow(0).createCell(6).setCellValue("BCC"); sheetEmail.getRow(0).createCell(7).setCellValue("Path"); for (int i = 0; i < wbtemp.getNumberOfSheets(); i++) { Sheet tempsheet = wbtemp.getSheetAt(i); tempsheet.setAutobreaks(true); for (Row temprow : tempsheet) { for (Cell cell : temprow) { cell.setCellStyle(style); tempsheet.autoSizeColumn(cell.getColumnIndex()); } } } int countedGen = 0; int countedBookmark = 0; int countedCookie = 0; int countedHistory = 0; int countedDownload = 0; int countedRecentObjects = 0; int countedTrackPoint = 0; int countedInstalled = 0; int countedKeyword = 0; int countedHash = 0; int countedDevice = 0; int countedEmail = 0; //start populating the sheets in the workbook for (Entry<BlackboardArtifact, ArrayList<BlackboardAttribute>> entry : report.entrySet()) { if (ReportFilter.cancel == true) { break; } int cc = 0; Long objId = entry.getKey().getObjectID(); AbstractFile file = skCase.getAbstractFileById(objId); String filename = file.getName(); Long filesize = file.getSize(); TreeMap<Integer, String> attributes = new TreeMap<Integer, String>(); // Get all the attributes, line them up to be added. Place empty string placeholders for each attribute type int n; for (n = 1; n <= 36; n++) { attributes.put(n, ""); } for (BlackboardAttribute tempatt : entry.getValue()) { if (ReportFilter.cancel == true) { break; } String value = ""; int type = tempatt.getAttributeTypeID(); if (tempatt.getAttributeTypeID() == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_RCVD .getTypeID() || tempatt.getAttributeTypeID() == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME .getTypeID() || tempatt.getAttributeTypeID() == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_LAST_ACCESSED .getTypeID()) { value = new java.text.SimpleDateFormat("MM/dd/yyyy HH:mm:ss") .format(new java.util.Date((tempatt.getValueLong()) * 1000)).toString(); } else { value = tempatt.getValueString(); } attributes.put(type, StringEscapeUtils.escapeXml(value)); cc++; } if (entry.getKey().getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_GEN_INFO .getTypeID()) { countedGen++; // Row temp = sheetGen.getRow(countedGen); } if (entry.getKey().getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_BOOKMARK .getTypeID()) { countedBookmark++; Row temp = sheetBookmark.createRow(countedBookmark); temp.createCell(0) .setCellValue(attributes.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_URL.getTypeID())); temp.createCell(1) .setCellValue(attributes.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME.getTypeID())); temp.createCell(2).setCellValue( attributes.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PROG_NAME.getTypeID())); } if (entry.getKey().getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_COOKIE .getTypeID()) { countedCookie++; Row temp = sheetCookie.createRow(countedCookie); temp.createCell(0) .setCellValue(attributes.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_URL.getTypeID())); temp.createCell(1).setCellValue( attributes.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME.getTypeID())); temp.createCell(2) .setCellValue(attributes.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME.getTypeID())); temp.createCell(3) .setCellValue(attributes.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_VALUE.getTypeID())); temp.createCell(4).setCellValue( attributes.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PROG_NAME.getTypeID())); } if (entry.getKey().getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_HISTORY .getTypeID()) { countedHistory++; Row temp = sheetHistory.createRow(countedHistory); temp.createCell(0) .setCellValue(attributes.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_URL.getTypeID())); temp.createCell(1).setCellValue( attributes.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_LAST_ACCESSED.getTypeID())); temp.createCell(2).setCellValue( attributes.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_REFERRER.getTypeID())); temp.createCell(3) .setCellValue(attributes.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME.getTypeID())); temp.createCell(4).setCellValue( attributes.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PROG_NAME.getTypeID())); } if (entry.getKey().getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_DOWNLOAD .getTypeID()) { countedDownload++; Row temp = sheetDownload.createRow(countedDownload); temp.createCell(0) .setCellValue(attributes.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PATH.getTypeID())); temp.createCell(1) .setCellValue(attributes.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_URL.getTypeID())); temp.createCell(2).setCellValue( attributes.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_LAST_ACCESSED.getTypeID())); temp.createCell(3).setCellValue( attributes.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PROG_NAME.getTypeID())); } if (entry.getKey().getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_RECENT_OBJECT .getTypeID()) { countedRecentObjects++; Row temp = sheetRecent.createRow(countedRecentObjects); temp.createCell(0) .setCellValue(attributes.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME.getTypeID())); temp.createCell(1) .setCellValue(attributes.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PATH.getTypeID())); temp.createCell(2).setCellValue(file.getName()); temp.createCell(3).setCellValue( attributes.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PROG_NAME.getTypeID())); } if (entry.getKey().getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_TRACKPOINT .getTypeID()) { // sheetTrackpoint.addContent(artifact); } if (entry.getKey().getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_INSTALLED_PROG .getTypeID()) { countedInstalled++; Row temp = sheetInstalled.createRow(countedInstalled); temp.createCell(0).setCellValue( attributes.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PROG_NAME.getTypeID())); temp.createCell(1).setCellValue( attributes.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME.getTypeID())); } if (entry.getKey().getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_KEYWORD_HIT .getTypeID()) { countedKeyword++; Row temp = sheetKeyword.createRow(countedKeyword); temp.createCell(0).setCellValue( attributes.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_KEYWORD.getTypeID())); temp.createCell(1).setCellValue(filename); temp.createCell(2).setCellValue( attributes.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_KEYWORD_PREVIEW.getTypeID())); temp.createCell(3).setCellValue( attributes.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SET_NAME.getTypeID())); } if (entry.getKey().getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_HASHSET_HIT .getTypeID()) { countedHash++; Row temp = sheetHash.createRow(countedHash); temp.createCell(0).setCellValue(file.getName().toString()); temp.createCell(1).setCellValue(filesize.toString()); temp.createCell(2).setCellValue( attributes.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SET_NAME.getTypeID())); } if (entry.getKey().getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_DEVICE_ATTACHED .getTypeID()) { countedDevice++; Row temp = sheetDevice.createRow(countedDevice); temp.createCell(0).setCellValue( attributes.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DEVICE_MODEL.getTypeID())); temp.createCell(1).setCellValue( attributes.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DEVICE_ID.getTypeID())); temp.createCell(2).setCellValue( attributes.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME.getTypeID())); } if (entry.getKey().getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_EMAIL_MSG .getTypeID()) { countedEmail++; Row temp = sheetEmail.createRow(countedEmail); temp.createCell(0).setCellValue( attributes.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL_FROM.getTypeID())); temp.createCell(1).setCellValue( attributes.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL_TO.getTypeID())); temp.createCell(2).setCellValue( attributes.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SUBJECT.getTypeID())); temp.createCell(3).setCellValue( attributes.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_RCVD.getTypeID())); temp.createCell(4).setCellValue( attributes.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL_CONTENT_PLAIN.getTypeID())); temp.createCell(5).setCellValue( attributes.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL_CC.getTypeID())); temp.createCell(6).setCellValue( attributes.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL_BCC.getTypeID())); temp.createCell(7) .setCellValue(attributes.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PATH.getTypeID())); } } //write out the report to the reports folder, set the wbtemp to the primary wb object wb = wbtemp; xlsPath = currentCase.getCaseDirectory() + File.separator + "Reports" + File.separator + caseName + "-" + datenotime + ".xlsx"; this.save(xlsPath); } catch (Exception E) { String test = E.toString(); } return xlsPath; }
From source file:org.unitime.timetable.export.XLSPrinter.java
License:Apache License
protected Font getFont(boolean bold, boolean italic, boolean underline, Color c) { Short color = null;/*from w ww.j a v a 2 s .c o m*/ if (c == null) c = Color.BLACK; if (c != null) { String colorId = Integer.toHexString(c.getRGB()); color = iColors.get(colorId); if (color == null) { HSSFPalette palette = ((HSSFWorkbook) iWorkbook).getCustomPalette(); HSSFColor clr = palette.findSimilarColor(c.getRed(), c.getGreen(), c.getBlue()); color = (clr == null ? IndexedColors.BLACK.getIndex() : clr.getIndex()); iColors.put(colorId, color); } } String fontId = (bold ? "b" : "") + (italic ? "i" : "") + (underline ? "u" : "") + (color == null ? "" : color); Font font = iFonts.get(fontId); if (font == null) { font = iWorkbook.createFont(); font.setBold(bold); font.setItalic(italic); font.setUnderline(underline ? Font.U_SINGLE : Font.U_NONE); font.setColor(color); font.setFontHeightInPoints((short) 10); font.setFontName("Arial"); iFonts.put(fontId, font); } return font; }
From source file:org.zafritech.zidingorms.io.excel.ExcelFunctions.java
private static Map<String, CellStyle> createStyles(Workbook wb) { Map<String, CellStyle> styles = new HashMap<String, CellStyle>(); CreationHelper creationHelper = wb.getCreationHelper(); CellStyle style;/*from w w w.j a va 2 s. c o m*/ // Header Font Font headerFont = wb.createFont(); headerFont.setFontHeightInPoints((short) 12); headerFont.setBold(true); headerFont.setColor(IndexedColors.WHITE.getIndex()); // Header Left Aligned Style style = createBorderedStyle(wb); style.setAlignment(HorizontalAlignment.LEFT); style.setVerticalAlignment(VerticalAlignment.CENTER); style.setFont(headerFont); style.setFillForegroundColor(IndexedColors.PALE_BLUE.getIndex()); style.setFillPattern(FillPatternType.SOLID_FOREGROUND); styles.put("HeaderLeftAlign", style); // Header Center Aligned Style style = createBorderedStyle(wb); style.setAlignment(HorizontalAlignment.CENTER); style.setVerticalAlignment(VerticalAlignment.CENTER); style.setFont(headerFont); style.setFillForegroundColor(IndexedColors.PALE_BLUE.getIndex()); style.setFillPattern(FillPatternType.SOLID_FOREGROUND); styles.put("HeaderCenterAlign", style); // Body Left Aligned Style style = createBorderedStyle(wb); style.setAlignment(HorizontalAlignment.LEFT); style.setVerticalAlignment(VerticalAlignment.TOP); styles.put("BodyLeftAlign", style); // Body Center Aligned Style style = createBorderedStyle(wb); style.setAlignment(HorizontalAlignment.CENTER); style.setVerticalAlignment(VerticalAlignment.TOP); styles.put("BodyCenterAlign", style); // Body Left Aligned WrapText Style style = createBorderedStyle(wb); style.setAlignment(HorizontalAlignment.LEFT); style.setVerticalAlignment(VerticalAlignment.TOP); style.setWrapText(true); styles.put("BodyLeftAlignWrapText", style); // Body Left Aligned Date Format Style style = createBorderedStyle(wb); style.setAlignment(HorizontalAlignment.LEFT); style.setVerticalAlignment(VerticalAlignment.TOP); style.setDataFormat(creationHelper.createDataFormat().getFormat("yyyy-MM-dd HH:mm:ss")); styles.put("BodyLeftAlignDate", style); // Body Center Aligned Date Format Style style = createBorderedStyle(wb); style.setAlignment(HorizontalAlignment.CENTER); style.setVerticalAlignment(VerticalAlignment.TOP); style.setDataFormat(creationHelper.createDataFormat().getFormat("yyyy-MM-dd HH:mm:ss")); styles.put("BodyCenterAlignDate", style); return styles; }
From source file:output.ExcelM3Upgrad.java
/** * create a library of cell styles// www.j a v a 2 s. com */ private static Map<String, CellStyle> createStyles(Workbook wb) { Map<String, CellStyle> styles = new HashMap<>(); DataFormat df = wb.createDataFormat(); Font font1 = wb.createFont(); CellStyle style; Font headerFont = wb.createFont(); headerFont.setBoldweight(Font.BOLDWEIGHT_BOLD); style = createBorderedStyle(wb); style.setAlignment(CellStyle.ALIGN_CENTER); style.setFillForegroundColor(IndexedColors.LIGHT_CORNFLOWER_BLUE.getIndex()); style.setFillPattern(CellStyle.SOLID_FOREGROUND); style.setFont(headerFont); styles.put("header", style); style = wb.createCellStyle(); style.setAlignment(CellStyle.ALIGN_CENTER); style.setFont(font1); style.setLocked(false); styles.put("cell_centered", style); style = wb.createCellStyle(); style.setAlignment(CellStyle.ALIGN_CENTER); style.setFont(font1); style.setLocked(true); styles.put("cell_centered_locked", style); // style = createBorderedStyle(wb); // style.setAlignment(CellStyle.ALIGN_CENTER); // style.setFillForegroundColor(IndexedColors.LIGHT_CORNFLOWER_BLUE.getIndex()); // style.setFillPattern(CellStyle.SOLID_FOREGROUND); // style.setFont(headerFont); // style.setDataFormat(df.getFormat("d-mmm")); // styles.put("header_date", style); font1.setBoldweight(Font.BOLDWEIGHT_BOLD); style = createBorderedStyle(wb); style.setAlignment(CellStyle.ALIGN_LEFT); style.setFont(font1); styles.put("cell_b", style); style = createBorderedStyle(wb); style.setAlignment(CellStyle.ALIGN_CENTER); style.setFont(font1); style.setLocked(false); styles.put("cell_b_centered", style); style = createBorderedStyle(wb); style.setAlignment(CellStyle.ALIGN_CENTER); style.setFont(font1); style.setLocked(true); styles.put("cell_b_centered_locked", style); style = createBorderedStyle(wb); style.setAlignment(CellStyle.ALIGN_RIGHT); style.setFont(font1); style.setDataFormat(df.getFormat("d-mmm")); styles.put("cell_b_date", style); style = createBorderedStyle(wb); style.setAlignment(CellStyle.ALIGN_RIGHT); style.setFont(font1); style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex()); style.setFillPattern(CellStyle.SOLID_FOREGROUND); style.setDataFormat(df.getFormat("d-mmm")); styles.put("cell_g", style); Font font2 = wb.createFont(); font2.setColor(IndexedColors.BLUE.getIndex()); font2.setBoldweight(Font.BOLDWEIGHT_BOLD); style = createBorderedStyle(wb); style.setAlignment(CellStyle.ALIGN_LEFT); style.setFont(font2); styles.put("cell_bb", style); style = createBorderedStyle(wb); style.setAlignment(CellStyle.ALIGN_RIGHT); style.setFont(font1); style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex()); style.setFillPattern(CellStyle.SOLID_FOREGROUND); style.setDataFormat(df.getFormat("d-mmm")); styles.put("cell_bg", style); Font font3 = wb.createFont(); font3.setFontHeightInPoints((short) 14); font3.setColor(IndexedColors.DARK_BLUE.getIndex()); font3.setBoldweight(Font.BOLDWEIGHT_BOLD); style = createBorderedStyle(wb); style.setAlignment(CellStyle.ALIGN_LEFT); style.setFont(font3); style.setWrapText(true); styles.put("cell_h", style); style = createBorderedStyle(wb); style.setAlignment(CellStyle.ALIGN_LEFT); style.setWrapText(true); styles.put("cell_normal", style); style = createBorderedStyle(wb); style.setAlignment(CellStyle.ALIGN_CENTER); style.setWrapText(true); styles.put("cell_normal_centered", style); style = createBorderedStyle(wb); style.setAlignment(CellStyle.ALIGN_RIGHT); style.setWrapText(true); style.setDataFormat(df.getFormat("d-mmm")); styles.put("cell_normal_date", style); style = createBorderedStyle(wb); style.setAlignment(CellStyle.ALIGN_LEFT); style.setIndention((short) 1); style.setWrapText(true); styles.put("cell_indented", style); style = createBorderedStyle(wb); style.setFillForegroundColor(IndexedColors.BLUE.getIndex()); style.setFillPattern(CellStyle.SOLID_FOREGROUND); styles.put("cell_blue", style); return styles; }
From source file:packtest.CellComments.java
License:Apache License
public static void main(String[] args) throws IOException { Workbook wb = new XSSFWorkbook(); CreationHelper factory = wb.getCreationHelper(); Sheet sheet = wb.createSheet();/* w ww. j a v a 2 s .c o m*/ Cell cell1 = sheet.createRow(3).createCell(5); cell1.setCellValue("F4"); Drawing drawing = sheet.createDrawingPatriarch(); ClientAnchor anchor = factory.createClientAnchor(); Comment comment1 = drawing.createCellComment(anchor); RichTextString str1 = factory.createRichTextString("Hello, World!"); comment1.setString(str1); comment1.setAuthor("Apache POI"); cell1.setCellComment(comment1); Cell cell2 = sheet.createRow(2).createCell(2); cell2.setCellValue("C3"); Comment comment2 = drawing.createCellComment(anchor); RichTextString str2 = factory.createRichTextString("XSSF can set cell comments"); //apply custom font to the text in the comment Font font = wb.createFont(); font.setFontName("Arial"); font.setFontHeightInPoints((short) 14); font.setBoldweight(Font.BOLDWEIGHT_BOLD); font.setColor(IndexedColors.RED.getIndex()); str2.applyFont(font); comment2.setString(str2); comment2.setAuthor("Apache POI"); // comment2.setAddress(new CellAddress("C3")); String fname = "comments.xlsx"; FileOutputStream out = new FileOutputStream(fname); wb.write(out); out.close(); wb.close(); }
From source file:packtest.WorkingWithFonts.java
License:Apache License
public static void main(String[] args) throws Exception { Workbook wb = new XSSFWorkbook(); //or new HSSFWorkbook(); Sheet sheet = wb.createSheet("Fonts"); Font font0 = wb.createFont(); font0.setColor(IndexedColors.BROWN.getIndex()); CellStyle style0 = wb.createCellStyle(); style0.setFont(font0);/*from w w w. j a va2s. c o m*/ Font font1 = wb.createFont(); font1.setFontHeightInPoints((short) 14); font1.setFontName("Courier New"); font1.setColor(IndexedColors.RED.getIndex()); CellStyle style1 = wb.createCellStyle(); style1.setFont(font1); Font font2 = wb.createFont(); font2.setFontHeightInPoints((short) 16); font2.setFontName("Arial"); font2.setColor(IndexedColors.GREEN.getIndex()); CellStyle style2 = wb.createCellStyle(); style2.setFont(font2); Font font3 = wb.createFont(); font3.setFontHeightInPoints((short) 18); font3.setFontName("Times New Roman"); font3.setColor(IndexedColors.LAVENDER.getIndex()); CellStyle style3 = wb.createCellStyle(); style3.setFont(font3); Font font4 = wb.createFont(); font4.setFontHeightInPoints((short) 18); font4.setFontName("Wingdings"); font4.setColor(IndexedColors.GOLD.getIndex()); CellStyle style4 = wb.createCellStyle(); style4.setFont(font4); Font font5 = wb.createFont(); font5.setFontName("Symbol"); CellStyle style5 = wb.createCellStyle(); style5.setFont(font5); Cell cell0 = sheet.createRow(0).createCell(1); cell0.setCellValue("Default"); cell0.setCellStyle(style0); Cell cell1 = sheet.createRow(1).createCell(1); cell1.setCellValue("Courier"); cell1.setCellStyle(style1); Cell cell2 = sheet.createRow(2).createCell(1); cell2.setCellValue("Arial"); cell2.setCellStyle(style2); Cell cell3 = sheet.createRow(3).createCell(1); cell3.setCellValue("Times New Roman"); cell3.setCellStyle(style3); Cell cell4 = sheet.createRow(4).createCell(1); cell4.setCellValue("Wingdings"); cell4.setCellStyle(style4); Cell cell5 = sheet.createRow(5).createCell(1); cell5.setCellValue("Symbol"); cell5.setCellStyle(style5); // Write the output to a file FileOutputStream fileOut = new FileOutputStream(Utils.getPath("xssf-fonts.xlsx")); wb.write(fileOut); fileOut.close(); }
From source file:paysheets.PaySheetFormatter.java
public static void addTitleRow(HSSFWorkbook workbook) { workbook.createSheet("Sheet 1"); // Each pay sheet only uses the first sheet HSSFSheet sheet = workbook.getSheetAt(0); setDefaultColumnWidth(sheet);// ww w. j av a 2 s . c o m HSSFRow row; HSSFCell cell; // Create a font and set its attributes Font font = workbook.createFont(); font.setFontHeightInPoints((short) 11); // Set the color to black (constant COLOR_NORMAL) font.setColor(Font.COLOR_NORMAL); font.setBold(true); // Create a cell style and set its properties CellStyle cs = workbook.createCellStyle(); // Set the data format to the built in text format cs.setDataFormat(HSSFDataFormat.getBuiltinFormat("text")); // Set the cell style to use the font created previously cs.setFont(font); // Create the first title row row = sheet.createRow(0); // Use the default row height (-1) is sheet default row.setHeight((short) -1); // Add the first title row's 6 cells for (int cellNum = 0; cellNum < 6; cellNum++) { cell = row.createCell(cellNum); cell.setCellStyle(cs); } // Populate first row's values cell = row.getCell(PaySheet.DATE_INDEX); cell.setCellValue("DATE"); cell = row.getCell(PaySheet.CUST_INDEX); cell.setCellValue("CUSTOMER"); cell = row.getCell(PaySheet.PAY_INDEX); cell.setCellValue("PAY"); cell = row.getCell(PaySheet.NONSERIAL_INDEX); cell.setCellValue("EQUIPMENT"); cell = row.getCell(PaySheet.SERIAL_INDEX); cell.setCellValue("SERIALIZED"); cell = row.getCell(PaySheet.SHS_INDEX); cell.setCellValue("SHS"); // Create second title row row = sheet.createRow(1); row.setHeight((short) -1); // Add the cells to the row for (int cellNum = 0; cellNum < 3; cellNum++) { cell = row.createCell(cellNum); cell.setCellStyle(cs); } // Populate the second title row's values cell = row.getCell(PaySheet.WO_INDEX); cell.setCellValue("WORK ORDER"); cell = row.getCell(PaySheet.TYPE_INDEX); cell.setCellValue("TYPE"); cell = row.getCell(PaySheet.LEP_INDEX); cell.setCellValue("LEP"); // Add thick border around title row addJobBorder(workbook, 0); }