https://github.com/bsorrentino/excel-xml-mapping
Apache POI extension to support xml mapping in excel 2007
https://github.com/bsorrentino/excel-xml-mapping
Last synced: 8 months ago
JSON representation
Apache POI extension to support xml mapping in excel 2007
- Host: GitHub
- URL: https://github.com/bsorrentino/excel-xml-mapping
- Owner: bsorrentino
- Created: 2011-11-24T09:09:23.000Z (almost 14 years ago)
- Default Branch: master
- Last Pushed: 2015-11-01T00:46:45.000Z (almost 10 years ago)
- Last Synced: 2024-12-27T19:32:12.099Z (10 months ago)
- Language: Java
- Homepage:
- Size: 230 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
This project has moving to GITHUB from [KENAI](http://kenai.com/projects/excel-xmlmapping/pages/Home)
----
## What is Excel Xml Mapping
To import and export XML data in Excel, an XML Map that associates XML elements with data in cells to get the results, would be very useful. To create one, you need to have an XML schema file (.xsd) and an XML data file (.xml). After creating the XML Map, you can map XML elements the way you want.
The link below explain the xml mapping feature and how to use it.> [Map XML elements to cells in a XML Map](https://support.office.com/en-us/article/Map-XML-elements-to-cells-in-an-XML-Map-ddb23edf-f5c5-4fbf-b736-b3bf977a0c53#__create_an_xml)
## Project goal
Since, until version 3.5-beta6, seems that [apache POI project](http://poi.apache.org/) doesn't support importXML feature yet, i've created this project to provide , in a easy way and without need of native code , this very useful feature from excel 2007.
### Usage
```java
XSSFWorkbook wb;
java.io.Reader xmlSource;
java.io.OutputStream result;File file = new File("src/test/resources/TestImportXml.xlsx");
File fileXml = new File("src/test/resources/TestImportData.xml");// load an XLSX file with mapping informations
wb = new XSSFWorkbook(file.getAbsolutePath());xmlSource = new java.io.FileReader( fileXml );
result = new java.io.FileOutputStream("target/testImportXmlout.xlsx");
WorkbookUtils.importXML( wb, xmlSource, result );
```### Data Conversion
The data conversion is supported for types:
* Boolean
* Date
* DateTime - ```xs:dateTime format supported [-]CCYY-MM-DDThh:mm:ss[Z|(+|-)hh:mm]```
* Time
* Double
* Long
* Float### Customize data conversion
It is possible ovveride the default data conversion behaviour implementing the Converter interface
```java
public static interface WorkbookUtils.Converter {
T convert( SimpleValue value) throws Exception;
}
```Through the following methods published from ```WorkbookUtils``` class
```java
public static Converter registerIntConverter( Converter converter );public static Converter registerFloatConverter( Converter converter );
public static Converter registerDoubleConverter( Converter converter ) ;
public static Converter registerLongConverter( Converter converter ) ;
public static Converter registerBooleanConverter( Converter converter ) ;
public static Converter registerDateConverter( Converter converter ) ;
public static Converter registerDateTimeConverter( Converter converter ) ;
public static Converter registerTimeConverter( Converter converter ) ;
```