类 DocxUtil

java.lang.Object
org.anyline.office.docx.util.DocxUtil

public class DocxUtil extends Object
  • 字段概要

    字段
    修饰符和类型
    字段
    说明
    static final double
     
    static final int
     
    static final int
     
    static final int
     
    static final double
     
    static final double
     
  • 构造器概要

    构造器
    构造器
    说明
     
  • 方法概要

    修饰符和类型
    方法
    说明
    static void
    addAttribute(org.dom4j.Element element, String key, String value)
     
    static org.dom4j.Element
    addElement(org.dom4j.Element parent, String tag)
     
    static org.dom4j.Element
    addElement(org.dom4j.Element parent, String tag, String key, String value)
    添加element及属性
    static void
    after(List<org.dom4j.Element> srcs, org.dom4j.Element ref)
     
    static void
    after(org.dom4j.Element src, org.dom4j.Element ref)
    src插入到ref之后
    static void
    background(org.dom4j.Element pr, Map<String,String> styles)
     
    static void
    before(org.dom4j.Element src, org.dom4j.Element ref)
    src插入到ref之前
    static List<org.dom4j.Element>
    betweens(org.dom4j.Element bookmark, String... tags)
     
    static org.dom4j.Element
    bookmark(org.dom4j.Element parent, String name)
     
    static void
    border(org.dom4j.Element border, String side, Map<String,String> styles)
     
    static void
    border(org.dom4j.Element border, Map<String,String> styles)
     
    static final int
    cm2dxa(double cm)
     
    static final double
    cm2pt(double cm)
     
    static final double
    cm2px(double cm)
     
    static void
    copyStyle(org.dom4j.Element src, org.dom4j.Element copy)
     
    static void
    copyStyle(org.dom4j.Element src, org.dom4j.Element copy, boolean override)
    copy的样式复制给src
    static int
    dxa(String src)
    宽度计算
    static final double
    dxa2emu(double dxa)
     
    static final double
    dxa2pt(double dxa)
     
    static final double
    dxa2px(double dxa)
     
    static final double
    emu2px(double emu)
     
    static void
    font(org.dom4j.Element pr, Map<String,String> styles)
     
    static int
     
    static org.dom4j.Element
    getParent(org.dom4j.Element element, String tag)
    获取element的上一级中第一个标签名=tag的上级
    static boolean
    hasParent(org.dom4j.Element element, String parent)
     
    static final double
    in2pt(double in)
     
    static final double
    in2px(double in)
     
    static int
    index(org.dom4j.Element element)
    当前节点在上级节点的下标
    static boolean
     
    static boolean
    isEmpty(org.dom4j.Element element)
     
    static org.dom4j.Element
    last(org.dom4j.Element element)
     
    static String
    lastName(org.dom4j.Element element)
     
    static String
    listStyle(File docx, String key)
    根据关键字查找样式列表ID
    static List<String>
    根据关键字查找样式列表ID
    static void
    merge(File... files)
    合并文件(只合并内容document.xml)合并到第一个文件中
    static String
    merge(List<String> docs)
     
    static final double
    mm2pt(double mm)
     
    static final double
    mm2px(double mm)
     
    static org.dom4j.Element
    next(org.dom4j.Element parent, org.dom4j.Element child)
     
    static org.dom4j.Element
    nextByName(org.dom4j.Element element)
     
    static org.dom4j.Element
    nextByName(org.dom4j.Element parent, org.dom4j.Element element)
     
    static void
    padding(org.dom4j.Element margin, String side, Map<String,String> styles)
     
    static void
    padding(org.dom4j.Element margin, Map<String,String> styles)
     
    static org.dom4j.Element
    pr(org.dom4j.Element element, String styles)
     
    static org.dom4j.Element
    pr(org.dom4j.Element element, Map<String,String> styles)
     
    static org.dom4j.Element
    prev(org.dom4j.Element element)
    前一个节点
    static org.dom4j.Element
    prev(org.dom4j.Element parent, org.dom4j.Element child)
     
    static org.dom4j.Element
    prevByName(org.dom4j.Element element)
    前一个节点
    static org.dom4j.Element
    prevByName(org.dom4j.Element parent, org.dom4j.Element element)
     
    static String
    prevName(org.dom4j.Element element)
     
    static final double
    pt2cm(double in)
     
    static final int
    pt2dxa(double pt)
     
    static final double
    pt2in(double pt)
     
    static final double
    pt2mm(double mm)
     
    static final double
    pt2px(double pt)
     
    static final double
    px2cm(double px)
     
    static final int
    px2dxa(double px)
     
    static final int
    px2dxa(int px)
     
    static final int
    px2emu(int px)
     
    static final double
    px2in(double px)
     
    static final double
    px2mm(double px)
     
    static final double
    px2pt(double px)
     
    static void
    removeAttribute(org.dom4j.Element element, String attribute)
     
    static void
    removeContent(org.dom4j.Element parent)
     
    static void
    removeElement(org.dom4j.Element parent, String element)
     
    static void
    setOrient(org.dom4j.Element pr, String orient, Map<String,String> styles)
     
    static List<String>
    拆分关键字 拆分123${key}abc成多个w:t
    static String
    text(org.dom4j.Element element)
    当前节点下的文本
    static org.dom4j.Element
    top(org.dom4j.Element element)
     
    static String
     

    从类继承的方法 java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 字段详细资料

    • PT_PER_PX

      public static final double PT_PER_PX
      另请参阅:
    • IN_PER_PT

      public static final int IN_PER_PT
      另请参阅:
    • CM_PER_PT

      public static final double CM_PER_PT
      另请参阅:
    • MM_PER_PT

      public static final double MM_PER_PT
      另请参阅:
    • EMU_PER_PX

      public static final int EMU_PER_PX
      另请参阅:
    • EMU_PER_DXA

      public static final int EMU_PER_DXA
      另请参阅:
  • 构造器详细资料

    • DocxUtil

      public DocxUtil()
  • 方法详细资料

    • listStyle

      public static String listStyle(File docx, String key)
      根据关键字查找样式列表ID
      参数:
      docx - docx文件
      key - 关键字
      返回:
      String
    • listStyles

      public static List<String> listStyles(File docx)
      根据关键字查找样式列表ID
      参数:
      docx - docx文件
      返回:
      String
    • merge

      public static void merge(File... files)
      合并文件(只合并内容document.xml)合并到第一个文件中
      参数:
      files - files
    • merge

      public static String merge(List<String> docs)
    • copyStyle

      public static void copyStyle(org.dom4j.Element src, org.dom4j.Element copy, boolean override)
      copy的样式复制给src
      参数:
      src - src
      copy - 被复制p/w或pPr/wPr
      override - 如果样式重复,是否覆盖原来的样式
    • copyStyle

      public static void copyStyle(org.dom4j.Element src, org.dom4j.Element copy)
    • prevByName

      public static org.dom4j.Element prevByName(org.dom4j.Element element)
      前一个节点
      参数:
      element - element
      返回:
      element
    • prevByName

      public static org.dom4j.Element prevByName(org.dom4j.Element parent, org.dom4j.Element element)
    • nextByName

      public static org.dom4j.Element nextByName(org.dom4j.Element element)
    • nextByName

      public static org.dom4j.Element nextByName(org.dom4j.Element parent, org.dom4j.Element element)
    • top

      public static org.dom4j.Element top(org.dom4j.Element element)
    • prev

      public static org.dom4j.Element prev(org.dom4j.Element element)
      前一个节点
      参数:
      element - element
      返回:
      element
    • prevName

      public static String prevName(org.dom4j.Element element)
    • last

      public static org.dom4j.Element last(org.dom4j.Element element)
    • lastName

      public static String lastName(org.dom4j.Element element)
    • isEmpty

      public static boolean isEmpty(org.dom4j.Element element)
    • hasParent

      public static boolean hasParent(org.dom4j.Element element, String parent)
    • getParent

      public static org.dom4j.Element getParent(org.dom4j.Element element, String tag)
      获取element的上一级中第一个标签名=tag的上级
      参数:
      element - 当前节点
      tag - 上级标签名 如tbl
      返回:
      Element
    • after

      public static void after(org.dom4j.Element src, org.dom4j.Element ref)
      src插入到ref之后
      参数:
      src - src
      ref - ref
    • after

      public static void after(List<org.dom4j.Element> srcs, org.dom4j.Element ref)
    • before

      public static void before(org.dom4j.Element src, org.dom4j.Element ref)
      src插入到ref之前
      参数:
      src - src
      ref - ref
    • index

      public static int index(org.dom4j.Element element)
      当前节点在上级节点的下标
      参数:
      element - element
      返回:
      index index
    • splitKey

      public static List<String> splitKey(String txt)
      拆分关键字 拆分123${key}abc成多个w:t
      参数:
      txt - txt
      返回:
      List
    • border

      public static void border(org.dom4j.Element border, Map<String,String> styles)
    • border

      public static void border(org.dom4j.Element border, String side, Map<String,String> styles)
    • padding

      public static void padding(org.dom4j.Element margin, Map<String,String> styles)
    • padding

      public static void padding(org.dom4j.Element margin, String side, Map<String,String> styles)
    • fontSize

      public static int fontSize(String size)
    • font

      public static void font(org.dom4j.Element pr, Map<String,String> styles)
    • background

      public static void background(org.dom4j.Element pr, Map<String,String> styles)
    • addElement

      public static org.dom4j.Element addElement(org.dom4j.Element parent, String tag, String key, String value)
      添加element及属性
      参数:
      parent - parent
      tag - element tag
      key - attribute key
      value - attribute value
      返回:
      Element
    • addAttribute

      public static void addAttribute(org.dom4j.Element element, String key, String value)
    • addElement

      public static org.dom4j.Element addElement(org.dom4j.Element parent, String tag)
    • next

      public static org.dom4j.Element next(org.dom4j.Element parent, org.dom4j.Element child)
    • prev

      public static org.dom4j.Element prev(org.dom4j.Element parent, org.dom4j.Element child)
    • text

      public static String text(org.dom4j.Element element)
      当前节点下的文本
      参数:
      element - element
      返回:
      String
    • isBlock

      public static boolean isBlock(String text)
    • betweens

      public static List<org.dom4j.Element> betweens(org.dom4j.Element bookmark, String... tags)
    • bookmark

      public static org.dom4j.Element bookmark(org.dom4j.Element parent, String name)
    • pr

      public static org.dom4j.Element pr(org.dom4j.Element element, String styles)
    • pr

      public static org.dom4j.Element pr(org.dom4j.Element element, Map<String,String> styles)
    • setOrient

      public static void setOrient(org.dom4j.Element pr, String orient, Map<String,String> styles)
    • removeAttribute

      public static void removeAttribute(org.dom4j.Element element, String attribute)
    • removeContent

      public static void removeContent(org.dom4j.Element parent)
    • removeElement

      public static void removeElement(org.dom4j.Element parent, String element)
    • dxa

      public static int dxa(String src)
      宽度计算
      参数:
      src - width
      返回:
      dxa
    • widthType

      public static String widthType(String width)
    • px2dxa

      public static final int px2dxa(int px)
    • px2dxa

      public static final int px2dxa(double px)
    • pt2dxa

      public static final int pt2dxa(double pt)
    • dxa2pt

      public static final double dxa2pt(double dxa)
    • dxa2px

      public static final double dxa2px(double dxa)
    • px2emu

      public static final int px2emu(int px)
    • dxa2emu

      public static final double dxa2emu(double dxa)
    • emu2px

      public static final double emu2px(double emu)
    • pt2px

      public static final double pt2px(double pt)
    • in2px

      public static final double in2px(double in)
    • px2in

      public static final double px2in(double px)
    • cm2px

      public static final double cm2px(double cm)
    • px2cm

      public static final double px2cm(double px)
    • mm2px

      public static final double mm2px(double mm)
    • px2mm

      public static final double px2mm(double px)
    • pt2in

      public static final double pt2in(double pt)
    • pt2mm

      public static final double pt2mm(double mm)
    • pt2cm

      public static final double pt2cm(double in)
    • px2pt

      public static final double px2pt(double px)
    • in2pt

      public static final double in2pt(double in)
    • mm2pt

      public static final double mm2pt(double mm)
    • cm2pt

      public static final double cm2pt(double cm)
    • cm2dxa

      public static final int cm2dxa(double cm)