Nyla Office

NYLA Office provides utilities for creating Excel, PDF and open office documents.

License

License

GroupId

GroupId

com.github.nyla-solutions
ArtifactId

ArtifactId

nyla.solutions.office
Last Version

Last Version

0.0.3
Release Date

Release Date

Type

Type

jar
Description

Description

Nyla Office
NYLA Office provides utilities for creating Excel, PDF and open office documents.
Project URL

Project URL

https://github.com/nyla-solutions/nyla-office
Source Code Management

Source Code Management

https://github.com/nyla-solutions/nyla-office.git

Download nyla.solutions.office

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.nyla-solutions/nyla.solutions.office/ -->
<dependency>
    <groupId>com.github.nyla-solutions</groupId>
    <artifactId>nyla.solutions.office</artifactId>
    <version>0.0.3</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.nyla-solutions/nyla.solutions.office/
implementation 'com.github.nyla-solutions:nyla.solutions.office:0.0.3'
// https://jarcasting.com/artifacts/com.github.nyla-solutions/nyla.solutions.office/
implementation ("com.github.nyla-solutions:nyla.solutions.office:0.0.3")
'com.github.nyla-solutions:nyla.solutions.office:jar:0.0.3'
<dependency org="com.github.nyla-solutions" name="nyla.solutions.office" rev="0.0.3">
  <artifact name="nyla.solutions.office" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.nyla-solutions', module='nyla.solutions.office', version='0.0.3')
)
libraryDependencies += "com.github.nyla-solutions" % "nyla.solutions.office" % "0.0.3"
[com.github.nyla-solutions/nyla.solutions.office "0.0.3"]

Dependencies

compile (12)

Group / Artifact Type Version
commons-collections : commons-collections jar 3.2
org.apache.xmlgraphics : fop jar 1.0
org.apache.avalon.framework : avalon-framework-api jar 4.3.1
org.jfree : jfreechart jar 1.0.19
jexcelapi : jxl jar 2.6
com.github.nyla-solutions : nyla.solutions.core jar 1.1.8
com.github.nyla-solutions : nyla.solutions.dao jar 0.0.2
com.github.nyla-solutions : nyla.solutions.commas.file jar 0.0.1
com.github.nyla-solutions : nyla.solutions.commas jar 0.1
com.github.nyla-solutions : nyla.solutions.spring jar 0.0.1
com.github.nyla-solutions : nyla.solutions.xml jar 0.1
junit : junit jar 4.12

test (1)

Group / Artifact Type Version
log4j : log4j jar 1.2.17

Project Modules

There are no modules declared in this project.

NYLA Office

NYLA Office provides utilities for creating Excel, PDF and open office documents.

Excel

Excel provides a set of functions to handle Excel files.

###Use Cases

String filePath = "src/resources/excel/input.xls";
Excel excel = Excel.getExcel(filePath);
ExcelSheet sheet = excel.retrieveSheet(sheetName);
Assert.assertTrue(sheet.getColumnCount() >  1);
Assert.assertTrue(sheet.getRowCount() >  1);

for (String[] row : sheet.getRows())
{
   Debugger.println("row:"+Arrays.asList(currentRow));
}

CSV

CSV is a object to create a CSV file.

###Use Case

File file = new File("src/test/resources/csv/output.csv");
CSV.writeHeader(file, "header1","header2","header3");
CSV.appendFile(file, 11,12,13);
		
Object[] row2 = {21,22,23};
CSV.appendFile(file, row2);

##JFreeChartFacade

JFreeChartFacade is a wrapper to the popular JFreeChart API(s).

###Simple Pie Char

Chart chart =  new JFreeChartFacade();
chart.setCategoryLabel(categoryLabel);
chart.setHeight(height);
chart.setName(name);
chart.plotValue(100.0, "Group A (66%)", "Usage");
chart.plotValue(50.0, "Group B  (34%)", "Usage");
chart.setTypeName(Chart.PNG_TYPE_NAME);

chart.setGraphType(Chart.PIE_GRAPH_TYPE);


IO.writeFile(new File(filePath), chart.getBytes());

###JVM memory area graph

//The Y axis is the memory size in GB
// X is days of week (Mon-Fri)
Chart chart =  new JFreeChartFacade();
chart.setLegend(legend);

chart.setCategoryLabel(categoryLabel);
chart.setHeight(height);
chart.setName(name);
chart.setWidth(width);
chart.setTitle(title);
String label = "JVM";

Calendar cal = Calendar.getInstance();
cal.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);

cal.add(Calendar.DATE, -5);

chart.plotValue(2,label, cal.getTime());
cal.add(Calendar.DATE, +1);


chart.plotValue(5, label, cal.getTime());
cal.add(Calendar.DATE, +1);

chart.plotValue(6,label, cal.getTime());

cal.add(Calendar.DATE, +1);
chart.plotValue(7,label, cal.getTime());

cal.add(Calendar.DATE, +1);
chart.plotValue(1,label, cal.getTime());
chart.setTypeName(Chart.PNG_TYPE_NAME);


Color[] colors = { Color.RED};

chart.setSeriesColors(Arrays.asList(colors));
chart.setBackgroundColor(Color.WHITE);
chart.setValueLabel("GB(s)");

chart.setGraphType(Chart.AREA_GRAPH_TYPE);


IO.writeFile(new File(filePath), chart.getBytes());
	
Debugger.println("Write to "+filePath);

FOP PDF

FOP is a wrapper for Apache FOP API to generate PDF document using XSL-FO.

###Use Case

String fo = IO.readClassPath("pdf/example.fop");
		
File file = new File("src/test/resources/pdf/test.pdf");
file.delete();
		
FOP.writePDF(fo, file);
Assert.assertTrue(file.exists());

###Example FO

  <?xml version="1.0" encoding="ISO-8859-1"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

<fo:layout-master-set>
  <fo:simple-page-master master-name="A4">
    <fo:region-body />
  </fo:simple-page-master>
</fo:layout-master-set>

<fo:page-sequence master-reference="A4">
  <fo:flow flow-name="xsl-region-body">
    <fo:block>Hello World</fo:block>
  </fo:flow>
</fo:page-sequence>
</fo:root>

###Add images FO example

   <fo:block>
    <fo:external-graphic src="../graphics/xml_feather_transparent.gif"/>
  </fo:block>

Also see http://w3schools.sinsixx.com/xslfo/default.asp.htm

Versions

Version
0.0.3
0.0.2
0.0.1