List of usage examples for org.apache.poi.openxml4j.util Nullable Nullable
public Nullable(E value)
From source file:ddf.catalog.transformer.input.pptx.PptxInputTransformerTest.java
License:Open Source License
@Test public void testCreatedDate() throws IOException, CatalogTransformerException, InterruptedException { try (XMLSlideShow ss = new XMLSlideShow()) { ss.createSlide();//from www. java 2 s .com Date d = createOneSecondPrecisionDate(); ss.getProperties().getCoreProperties().setCreated(new Nullable<>(d)); try (ByteArrayOutputStream os = new ByteArrayOutputStream()) { ss.write(os); try (ByteArrayInputStream inStr = new ByteArrayInputStream(os.toByteArray())) { PptxInputTransformer t = new PptxInputTransformer(inputTransformer, true); Metacard m = t.transform(inStr); assertThat(m.getCreatedDate().getTime(), is(d.getTime())); } } } }
From source file:ddf.catalog.transformer.input.pptx.PptxInputTransformerTest.java
License:Open Source License
@Test public void testModifiedDate() throws IOException, CatalogTransformerException, InterruptedException { try (XMLSlideShow ss = new XMLSlideShow()) { ss.createSlide();/*from w w w . j a v a 2 s.c om*/ Date d = createOneSecondPrecisionDate(); ss.getProperties().getCoreProperties().setModified(new Nullable<>(d)); try (ByteArrayOutputStream os = new ByteArrayOutputStream()) { ss.write(os); try (ByteArrayInputStream inStr = new ByteArrayInputStream(os.toByteArray())) { PptxInputTransformer t = new PptxInputTransformer(inputTransformer, true); Metacard m = t.transform(inStr); assertThat(m.getModifiedDate().getTime(), is(d.getTime())); } } } }
From source file:de.bund.bfr.knime.openkrise.db.imports.custom.bfrnewformat.TraceGenerator.java
License:Open Source License
private boolean save(XSSFWorkbook workbook, String filename) { try {/*w w w .ja va 2 s.c o m*/ File f = new File(filename); if (f.exists()) { int returnVal = JOptionPane.showConfirmDialog(parent, "Replace file '" + filename + "'?", "Excel file '" + filename + "' exists already", JOptionPane.YES_NO_OPTION); if (returnVal == JOptionPane.NO_OPTION) return false; else if (returnVal == JOptionPane.YES_OPTION) ; else return false; } POIXMLProperties.CoreProperties coreProp = workbook.getProperties().getCoreProperties(); coreProp.setCreator("FoodChain-Lab"); coreProp.setCreated(new Nullable<Date>(new Date(System.currentTimeMillis()))); // Write the workbook in file system FileOutputStream out = new FileOutputStream(f); workbook.write(out); out.close(); System.out.println(filename + " written successfully on disk."); } catch (Exception e) { e.printStackTrace(); return false; } return true; }
From source file:de.knowwe.include.export.ExportManager.java
License:Open Source License
public ExportModel createExport(ProgressListener listener) throws IOException { ParallelProgress progress = new ParallelProgress(listener, 3f, 7f); progress.updateProgress(0, 0f, MSG_CREATE); // detect stream for word template Section<AttachmentType> attach = Sections.successor(section, AttachmentType.class); // create builder and export the section try (InputStream stream = (attach == null) ? createDefaultTemplateStream() : createAttachmentStream(attach)) { ExportModel model = new ExportModel(this, stream, progress.getSubTaskProgressListener(1)); DefaultBuilder builder = new DefaultBuilder(model); progress.updateProgress(0, 0.2f); if (section.get() instanceof IncludeMarkup) { updateDocumentInfo(Sections.cast(section, IncludeMarkup.class), model); }/* w ww . j a v a2 s . co m*/ progress.updateProgress(0, 0.9f); builder.export(section); // initialize some core properties CoreProperties coreProperties = builder.getDocument().getProperties().getCoreProperties(); coreProperties.setModified(new Nullable<>(getLastModified())); progress.updateProgress(1f, MSG_SAVE); return model; } }
From source file:org.alfresco.bm.report.XLSXReporter.java
License:Open Source License
private void writeMetadata(XSSFWorkbook workbook) throws IOException, NotFoundException { TestService testService = getTestService(); CoreProperties workbookCoreProperties = workbook.getProperties().getCoreProperties(); // Title//from ww w. j ava 2 s. c om workbookCoreProperties.setTitle(title); // Description StringBuilder description = new StringBuilder(128); DBObject testObj = testService.getTestMetadata(test); String testDescription = (String) testObj.get(FIELD_DESCRIPTION); if (testDescription != null) { description.append(testDescription).append("\n"); } DBObject testRunObj = testService.getTestRunMetadata(test, run); String testRunDescription = (String) testRunObj.get(FIELD_DESCRIPTION); if (testRunDescription != null) { description.append(testRunDescription); } workbookCoreProperties.setDescription(description.toString().trim()); // Created Long time = (Long) testRunObj.get(FIELD_STARTED); if (time > 0) { workbookCoreProperties.setCreated(new Nullable<Date>(new Date(time))); } }
From source file:org.keyboardplaying.xtt.xlsx.XlsxNormalizer.java
License:Apache License
/** * Normalizes the time tracker workbook's properties to avoid unrequired changes in the SCM repository. * <p/>/*from w w w.ja va2s .c o m*/ * This sets the author, company and title with the properties of the instance, and resets the last modification * date with the creation date. * * @param workbook * the workbook to normalize */ public void normalizeProperties(XSSFWorkbook workbook) { POIXMLProperties properties = workbook.getProperties(); CoreProperties coreProperties = properties.getCoreProperties(); // Set author coreProperties.setCreator(author); coreProperties.getUnderlyingProperties().setLastModifiedByProperty(author); properties.getExtendedProperties().getUnderlyingProperties().setCompany(company); // Set title coreProperties.setTitle(title); // Don't save last modification date coreProperties.setModified(new Nullable<>(coreProperties.getCreated())); }