栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

java导入visio文件

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

java导入visio文件

String filePath = "E:/桌面/cesgi.vsdx";
        File file = new File(filePath);
        XmlVisiodocument xmlVisiodocument = new XmlVisiodocument(new FileInputStream(file));
        Collection pages = xmlVisiodocument.getPages();
        Iterator iterator = pages.iterator();
        //存储所有连线起点的集合
        List startLine = new ArrayList<>();
        //存储所有连线起点的集合
        List endLine = new ArrayList<>();
        //存储所有形状id和文字的集合
        HashMap idAndName = new HashMap<>();
        //存储所有形状id和样式的集合
        HashMap idAndStyle = new HashMap<>();
        //存储所有形状id和宽高的集合
        HashMap idAndSize = new HashMap<>();
         while (iterator.hasNext()) {
            XDGFPage xdgfPage = iterator.next();
            XDGFPageContents content = xdgfPage.getContent();

            //所有包含文字的形状节点
            Collection shapes = content.getShapes();
            Iterator iterator1 = shapes.iterator();

         

            while (iterator1.hasNext()) {
                XDGFShape xdgfShape = iterator1.next();
                if (xdgfShape.hasText() && !xdgfShape.getText().getTextContent().equals("")) {
                    //存储文字
                    idAndName.put(Long.toString(xdgfShape.getID()), xdgfShape.getTextAsString());
                    //存储形状类型
          
                    idAndStyle.put(Long.toString(xdgfShape.getID()), xdgfShape.getName());
                    //存储形状数据,xml结构中*100为业务需要
                    idAndSize.put(Long.toString(xdgfShape.getID()), " ");
            }
        

可以实现对vsdx文件的实时读取,解析,将数据转化为自定义xml

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/424585.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号