List of usage examples for org.apache.poi.xwpf.usermodel XWPFDocument XWPFDocument
public XWPFDocument()
From source file:org.cgiar.ccafs.marlo.action.summaries.POWBPOISummaryAction.java
License:Open Source License
public POWBPOISummaryAction(APConfig config, GlobalUnitManager crpManager, PhaseManager phaseManager, PowbExpectedCrpProgressManager powbExpectedCrpProgressManager, ProjectExpectedStudyManager projectExpectedStudyManager, PowbSynthesisManager powbSynthesisManager, PowbExpenditureAreasManager powbExpenditureAreasManager, LiaisonInstitutionManager liaisonInstitutionManager, PowbCrpStaffingCategoriesManager powbCrpStaffingCategoriesManager, ProjectManager projectManager) { super(config, crpManager, phaseManager, projectManager); document = new XWPFDocument(); poiSummary = new POISummary(); currencyFormat = NumberFormat.getCurrencyInstance(); percentageFormat = new DecimalFormat("##.##%"); this.powbExpectedCrpProgressManager = powbExpectedCrpProgressManager; this.projectExpectedStudyManager = projectExpectedStudyManager; this.powbSynthesisManager = powbSynthesisManager; this.powbExpenditureAreasManager = powbExpenditureAreasManager; this.liaisonInstitutionManager = liaisonInstitutionManager; this.powbCrpStaffingCategoriesManager = powbCrpStaffingCategoriesManager; }
From source file:org.goobi.production.flow.helper.SearchResultHelper.java
License:Open Source License
public XWPFDocument getResultAsWord(List<SearchColumn> columnList, String filter, String order, boolean showClosedProcesses, boolean showArchivedProjects) { @SuppressWarnings("rawtypes") List list = search(columnList, filter, order, showClosedProcesses, showArchivedProjects); XWPFDocument doc = new XWPFDocument(); // create header row int colNum = columnList.size(); int rowNum = list.size() + 1; XWPFTable table = doc.createTable(rowNum, colNum); CTTblWidth width = table.getCTTbl().addNewTblPr().addNewTblW(); width.setType(STTblWidth.DXA);//from w w w.ja v a 2 s . co m width.setW(BigInteger.valueOf(10000)); int currentRow = 0; int currentCol = 0; XWPFTableRow headerRow = table.getRow(currentRow++); for (SearchColumn sc : columnList) { XWPFTableCell cell = headerRow.getCell(currentCol++); cell.setText(Helper.getTranslation(sc.getValue())); } for (Object obj : list) { currentCol = 0; Object[] objArr = (Object[]) obj; XWPFTableRow row = table.getRow(currentRow++); for (Object entry : objArr) { XWPFTableCell cell = row.getCell(currentCol++); cell.setText((String) entry); } } return doc; }
From source file:org.hackthelegacy.hack400tool.ibmiscannercore.IBMiConnector.java
License:Open Source License
public void exportToDOCX(String fileName, String inputText) { System.out.println("Save as file: " + fileName); try {/*w w w . ja v a2s . c o m*/ prepareFile(fileName); FileOutputStream fileOutStream = new FileOutputStream(fileName); XWPFDocument wordDocument = new XWPFDocument(); String[] textArray = inputText.split("\n"); for (String textLine : textArray) { if (textLine.length() == 0 || textLine == null) continue; XWPFParagraph tmpParagraph = wordDocument.createParagraph(); XWPFRun tmpRun = tmpParagraph.createRun(); tmpRun.setText(textLine); tmpRun.setFontSize(8); tmpRun.setFontFamily("Courier New"); } wordDocument.write(fileOutStream); fileOutStream.close(); } catch (Exception ex) { Logger.getLogger(IBMiConnector.class.getName()).log(Level.SEVERE, null, ex); return; } }
From source file:org.luwrain.app.writer.Base.java
License:Open Source License
void createNewDoc() { doc = new XWPFDocument(); doc.createParagraph(); }
From source file:org.obeonetwork.m2doc.genconf.edit.tests.provider.ModelDefinitionItemProviderTests.java
License:Open Source License
/** * Initializes test resources./*from w w w . ja v a 2 s .c o m*/ */ @Before public void before() { final ResourceSet rs = new ResourceSetImpl(); rs.getURIConverter().getURIHandlers().add(0, uriHandler); rs.getResourceFactoryRegistry().getContentTypeToFactoryMap().put("*", new XMIResourceFactoryImpl()); final Resource res = rs.createResource(URI.createURI("m2doctests://resources/test.genconf")); final Generation generation = GenconfPackage.eINSTANCE.getGenconfFactory().createGeneration(); generation.setTemplateFileName("test.docx"); res.getContents().add(generation); definition = GenconfPackage.eINSTANCE.getGenconfFactory().createModelDefinition(); definition.setKey("self"); generation.getDefinitions().add(definition); final EPackage ePkg1 = EcorePackage.eINSTANCE.getEcoreFactory().createEPackage(); ePkg1.setName("package1"); final EPackage ePkg2 = EcorePackage.eINSTANCE.getEcoreFactory().createEPackage(); ePkg2.setName("package2"); final EPackage ePkg3 = EcorePackage.eINSTANCE.getEcoreFactory().createEPackage(); ePkg3.setName("package3"); final EClass eCls1 = EcorePackage.eINSTANCE.getEcoreFactory().createEClass(); eCls1.setName("Class1"); final EClass eCls2 = EcorePackage.eINSTANCE.getEcoreFactory().createEClass(); eCls2.setName("Class2"); final EClass eCls3 = EcorePackage.eINSTANCE.getEcoreFactory().createEClass(); eCls3.setName("Class3"); res.getContents().add(ePkg1); res.getContents().add(ePkg2); res.getContents().add(ePkg3); res.getContents().add(eCls1); res.getContents().add(eCls2); res.getContents().add(eCls3); try { res.save(null); } catch (IOException e) { e.printStackTrace(); fail(e.getMessage()); } document = new XWPFDocument(); properties = new TemplateCustomProperties(document); properties.getPackagesURIs().add(GenconfPackage.eINSTANCE.getNsURI()); }
From source file:org.obeonetwork.m2doc.genconf.tests.GenconfUtilsTests.java
License:Open Source License
@Test public void getNewDefinitionsNotExistingModelDefinition() throws IOException { final Generation generation = GenconfPackage.eINSTANCE.getGenconfFactory().createGeneration(); try (final XWPFDocument document = new XWPFDocument()) { final TemplateCustomProperties properties = new TemplateCustomProperties(document); properties.getVariables().put("variable", "ecore::EClass"); final List<Definition> definitions = GenconfUtils.getNewDefinitions(generation, properties); assertEquals(1, definitions.size()); assertTrue(definitions.get(0) instanceof ModelDefinition); assertEquals("variable", definitions.get(0).getKey()); }//from w w w . jav a2s .co m }
From source file:org.obeonetwork.m2doc.genconf.tests.GenconfUtilsTests.java
License:Open Source License
@Test public void getNewDefinitionsNotExistingStringDefinition() throws IOException { final Generation generation = GenconfPackage.eINSTANCE.getGenconfFactory().createGeneration(); try (final XWPFDocument document = new XWPFDocument()) { final TemplateCustomProperties properties = new TemplateCustomProperties(document); properties.getVariables().put("variable", TemplateCustomProperties.STRING_TYPE); final List<Definition> definitions = GenconfUtils.getNewDefinitions(generation, properties); assertEquals(1, definitions.size()); assertTrue(definitions.get(0) instanceof StringDefinition); assertEquals("variable", definitions.get(0).getKey()); }/*ww w.j av a2 s . c o m*/ }
From source file:org.obeonetwork.m2doc.genconf.tests.GenconfUtilsTests.java
License:Open Source License
@Test public void getNewDefinitionsExisting() throws IOException { final Generation generation = GenconfPackage.eINSTANCE.getGenconfFactory().createGeneration(); final StringDefinition stringDefinition = GenconfPackage.eINSTANCE.getGenconfFactory() .createStringDefinition();/*from www. j a v a 2 s. c o m*/ stringDefinition.setKey("variable"); generation.getDefinitions().add(stringDefinition); try (final XWPFDocument document = new XWPFDocument()) { final TemplateCustomProperties properties = new TemplateCustomProperties(document); properties.getVariables().put("variable", TemplateCustomProperties.STRING_TYPE); final List<Definition> definitions = GenconfUtils.getNewDefinitions(generation, properties); assertEquals(0, definitions.size()); } }
From source file:org.obeonetwork.m2doc.genconf.tests.GenconfUtilsTests.java
License:Open Source License
@Test public void getNewDefinitionsExistingInvalidType() throws IOException { final Generation generation = GenconfPackage.eINSTANCE.getGenconfFactory().createGeneration(); final StringDefinition stringDefinition = GenconfPackage.eINSTANCE.getGenconfFactory() .createStringDefinition();//w w w . jav a 2s . co m stringDefinition.setKey("variable"); generation.getDefinitions().add(stringDefinition); try (final XWPFDocument document = new XWPFDocument()) { final TemplateCustomProperties properties = new TemplateCustomProperties(document); properties.getVariables().put("variable", "ecore::EClass"); final List<Definition> definitions = GenconfUtils.getNewDefinitions(generation, properties); assertEquals(1, definitions.size()); assertTrue(definitions.get(0) instanceof ModelDefinition); assertEquals("variable", definitions.get(0).getKey()); } }
From source file:org.obeonetwork.m2doc.generator.test.TableClientProcessorTest.java
License:Open Source License
@Before public void setUp() { doc = new XWPFDocument(); paragraph = doc.createParagraph();/*from w ww . j a va2 s . co m*/ run = paragraph.createRun(); provider = new AbstractTableProvider() { @Override public Map<String, OptionType> getOptionTypes() { return options; } @Override public List<MTable> getTables(Map<String, Object> parameters) throws ProviderException { return getTestTables(); } @Override public List<ProviderValidationMessage> validate(Map<String, Object> params) { return Collections.emptyList(); } }; }