仿站小工具官网,郑州网站模板建设,可以商用的电视app永久软件,大丰做网站费用概述在Word创建表格时#xff0c;可设置表格“自动调整”#xff0c;有3种情况#xff0c;通过Java程序设置可调用相应的方法来实现#xff0c;即#xff1a;根据内容调整表格AutoFitBehaviorType.Auto_Fit_To_Contents根据窗口调整表格AutoFitBehaviorType.Auto_Fit_To_W…概述在Word创建表格时可设置表格“自动调整”有3种情况通过Java程序设置可调用相应的方法来实现即根据内容调整表格AutoFitBehaviorType.Auto_Fit_To_Contents根据窗口调整表格AutoFitBehaviorType.Auto_Fit_To_Window固定列宽AutoFitBehaviorType.Fixed_Column_Widths程序中需要使用Word类库工具(Free Spire.Doc for Java 免费版)导入方法方法1.可方法2.创建Maven程序在pom.xml配置Maven仓库路径并指定Free Spire.Doc for Java的Maven依赖。完成配置后如果使用的是IDEA点击“Import Changes”导入如果使用的是Eclipse点击“保存”即可自动下载导入。com.e-icebluehttp://repo.e-iceblue.cn/repository/maven-public/ e-iceblue spire.doc.free2.7.3import com.spire.doc.*;public class TableAutoFit {public static void main(String[] args) {//加载Word文档Document doc new Document();doc.loadFromFile(test.docx);//获取sectionSection section doc.getSections().get(0);//获取表格Table table section.getTables().get(0);//设置表格列宽适应内容table.autoFit(AutoFitBehaviorType.Auto_Fit_To_Contents);//设置表格列宽适应窗体//table.autoFit(AutoFitBehaviorType.Auto_Fit_To_Window);//设置表格固定列宽//table.autoFit(AutoFitBehaviorType.Fixed_Column_Widths);//保存文档doc.saveToFile(TableAutoFit2.docx,FileFormat.Docx_2013);doc.dispose();}}