use of org.apache.poi.xssf.usermodel.XSSFMap in project poi by apache.
the class CustomXMLMapping method main.
public static void main(String[] args) throws Exception {
OPCPackage pkg = OPCPackage.open(args[0]);
XSSFWorkbook wb = new XSSFWorkbook(pkg);
for (XSSFMap map : wb.getCustomXMLMappings()) {
XSSFExportToXml exporter = new XSSFExportToXml(map);
ByteArrayOutputStream os = new ByteArrayOutputStream();
exporter.exportToXML(os, true);
String xml = os.toString("UTF-8");
System.out.println(xml);
}
pkg.close();
}
use of org.apache.poi.xssf.usermodel.XSSFMap in project poi by apache.
the class TestMapInfo method testMapInfoExists.
public void testMapInfoExists() {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("CustomXMLMappings.xlsx");
MapInfo mapInfo = null;
SingleXmlCells singleXMLCells = null;
for (POIXMLDocumentPart p : wb.getRelations()) {
if (p instanceof MapInfo) {
mapInfo = (MapInfo) p;
CTMapInfo ctMapInfo = mapInfo.getCTMapInfo();
assertNotNull(ctMapInfo);
assertEquals(1, ctMapInfo.sizeOfSchemaArray());
for (XSSFMap map : mapInfo.getAllXSSFMaps()) {
Node xmlSchema = map.getSchema();
assertNotNull(xmlSchema);
}
}
}
XSSFSheet sheet1 = wb.getSheetAt(0);
for (POIXMLDocumentPart p : sheet1.getRelations()) {
if (p instanceof SingleXmlCells) {
singleXMLCells = (SingleXmlCells) p;
}
}
assertNotNull(mapInfo);
assertNotNull(singleXMLCells);
}
use of org.apache.poi.xssf.usermodel.XSSFMap in project poi by apache.
the class TestXSSFImportFromXML method testImportFromXML.
@Test
public void testImportFromXML() throws IOException, XPathExpressionException, SAXException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("CustomXMLMappings.xlsx");
try {
String name = "name";
String teacher = "teacher";
String tutor = "tutor";
String cdl = "cdl";
String duration = "duration";
String topic = "topic";
String project = "project";
String credits = "credits";
String testXML = "<CORSO>" + "<NOME>" + name + "</NOME>" + "<DOCENTE>" + teacher + "</DOCENTE>" + "<TUTOR>" + tutor + "</TUTOR>" + "<CDL>" + cdl + "</CDL>" + "<DURATA>" + duration + "</DURATA>" + "<ARGOMENTO>" + topic + "</ARGOMENTO>" + "<PROGETTO>" + project + "</PROGETTO>" + "<CREDITI>" + credits + "</CREDITI>" + "</CORSO>