Example #1
0
        public XSSFMap GetXSSFMapByName(string name)
        {
            XSSFMap xssfMap1 = (XSSFMap)null;

            foreach (XSSFMap xssfMap2 in this.maps.Values)
            {
                if (xssfMap2.GetCTMap().Name != null && xssfMap2.GetCTMap().Name.Equals(name))
                {
                    xssfMap1 = xssfMap2;
                }
            }
            return(xssfMap1);
        }
Example #2
0
        public XSSFMap GetXSSFMapByName(String name)
        {
            XSSFMap matchedMap = null;

            foreach (XSSFMap map in maps.Values)
            {
                if (map.GetCTMap().Name != null && map.GetCTMap().Name.Equals(name))
                {
                    matchedMap = map;
                }
            }

            return(matchedMap);
        }
Example #3
0
        public void TestExportToXMLInverseOrder()
        {
            XSSFWorkbook wb = XSSFTestDataSamples
                              .OpenSampleWorkbook("CustomXmlMappings-inverse-order.xlsx");

            MapInfo mapInfo = null;

            foreach (POIXMLDocumentPart p in wb.GetRelations())
            {
                if (!(p is MapInfo))
                {
                    continue;
                }
                mapInfo = (MapInfo)p;

                XSSFMap         map      = mapInfo.GetXSSFMapById(1);
                XSSFExportToXml exporter = new XSSFExportToXml(map);
                MemoryStream    os       = new MemoryStream();
                exporter.ExportToXML(os, true);
                os.Position = 0;
                XmlDocument xml = new XmlDocument();
                xml.Load(os);
                Assert.IsNotNull(xml);
                Assert.IsTrue(xml.OuterXml != "");

                String docente   = xml.SelectSingleNode("//DOCENTE").InnerText.Trim();
                String nome      = xml.SelectSingleNode("//NOME").InnerText.Trim();
                String tutor     = xml.SelectSingleNode("//TUTOR").InnerText.Trim();
                String cdl       = xml.SelectSingleNode("//CDL").InnerText.Trim();
                String durata    = xml.SelectSingleNode("//DURATA").InnerText.Trim();
                String argomento = xml.SelectSingleNode("//ARGOMENTO").InnerText.Trim();
                String progetto  = xml.SelectSingleNode("//PROGETTO").InnerText.Trim();
                String crediti   = xml.SelectSingleNode("//CREDITI").InnerText.Trim();

                Assert.AreEqual("aa", nome);
                Assert.AreEqual("aaaa", docente);
                Assert.AreEqual("gvvv", tutor);
                Assert.AreEqual("g", cdl);
                Assert.AreEqual("gs", durata);
                Assert.AreEqual("ds", argomento);
                Assert.AreEqual("ro", progetto);
                Assert.AreEqual("ro", crediti);
            }
        }
Example #4
0
        public void TestXPathOrdering()
        {
            XSSFWorkbook wb = XSSFTestDataSamples
                              .OpenSampleWorkbook("CustomXmlMappings-inverse-order.xlsx");

            MapInfo mapInfo = null;

            foreach (POIXMLDocumentPart p in wb.GetRelations())
            {
                if (p is MapInfo)
                {
                    mapInfo = (MapInfo)p;

                    XSSFMap         map      = mapInfo.GetXSSFMapById(1);
                    XSSFExportToXml exporter = new XSSFExportToXml(map);

                    Assert.AreEqual(1, exporter.Compare("/CORSO/DOCENTE", "/CORSO/NOME"));
                    Assert.AreEqual(-1, exporter.Compare("/CORSO/NOME", "/CORSO/DOCENTE"));
                }
            }
        }
Example #5
0
        public void TestMultiTable()
        {
            XSSFWorkbook wb = XSSFTestDataSamples
                              .OpenSampleWorkbook("CustomXMLMappings-complex-type.xlsx");

            foreach (POIXMLDocumentPart p in wb.GetRelations())
            {
                if (p is MapInfo)
                {
                    MapInfo mapInfo = (MapInfo)p;

                    XSSFMap map = mapInfo.GetXSSFMapById(2);

                    Assert.IsNotNull(map);

                    XSSFExportToXml exporter = new XSSFExportToXml(map);
                    MemoryStream    os       = new MemoryStream();
                    exporter.ExportToXML(os, true);
                    String xml = Encoding.UTF8.GetString(os.ToArray());
                    Assert.IsNotNull(xml);

                    String[] regexConditions =
                    {
                        "<MapInfo",                                          "</MapInfo>",
                        "<Schema ID=\"1\" SchemaRef=\"\" Namespace=\"\" />",
                        "<Schema ID=\"4\" SchemaRef=\"\" Namespace=\"\" />",
                        "DataBinding",
                        "Map ID=\"1\"",
                        "Map ID=\"5\"",
                    };

                    foreach (string condition in regexConditions)
                    {
                        Regex pattern = new Regex(condition, RegexOptions.Compiled);
                        Assert.IsTrue(pattern.IsMatch(xml), condition);
                    }
                }
            }
        }
Example #6
0
 /**
  * Creates a new exporter and Sets the mapping to be used when generating the XML output document
  *
  * @param map the mapping rule to be used
  */
 public XSSFExportToXml(XSSFMap map)
 {
     this.map = map;
 }
 public XSSFImportFromXML(XSSFMap map) {
     _map = map;
 }