-
用jacob为word表格设置边框线
2012-08-15 11:37:21网上关于jacob如何操控word的例子已经有很多,但基本处理出来的表格,是没有边框线的。 在这里对此我做点补充,jacob版本是1.17 ActiveXComponent word = new ActiveXComponent("Word.Application"); word.set...网上关于jacob如何操控word的例子已经有很多,但基本处理出来的表格,是没有边框线的。
在这里对此我做点补充,jacob版本是1.17
ActiveXComponent word = new ActiveXComponent("Word.Application");
word.setProperty("Visible", new Variant(true));
Dispatch documents = word.getProperty("Documents").toDispatch();
Dispatch doc = Dispatch.call(documents, "Open", "e:/abc.doc").toDispatch();
// 所有表格
Dispatch tables = Dispatch.get(doc, "Tables").toDispatch();
// 要设置的表格,这里是第一个表格//width 是宽度值,但top时会出错,不明
Dispatch table = Dispatch.call(tables, "Item", new Variant(1)).toDispatch();
for(int b=1;b<=6;b++){
Dispatch oBorders = Dispatch.call(table, "Borders", 0-b).toDispatch();
Dispatch.put(oBorders, "LineStyle", new Variant(1));
//top第一行时,linewidth设置有错,不明原因
//Dispatch.put(oBorders, "LineWidth", new Variant(width));
}....略
-
bootstrap 黑边框表格样式_Java 设置Word表格边框
2021-01-04 02:39:22概述:本文介绍通过Java程序设置Word表格边框的方法,设置边框时可对整个表格设置,也可对指定单元格设置,同时可对边框进行格式化设置设置,包括边框类型、样式、颜色、线条宽度等等,下面将分三个示例来展示如何...概述:
本文介绍通过Java程序设置Word表格边框的方法,设置边框时可对整个表格设置,也可对指定单元格设置,同时可对边框进行格式化设置设置,包括边框类型、样式、颜色、线条宽度等等,下面将分三个示例来展示如何设置边框效果:
1. 表格边框
1.1 对整个表格设置统一的边框样式
1.2 对表格指定边框设置样式
2. 单元格边框(指定单元格设置边框)
程序环境准备:
本文使用的是IDEA,并且需要使用到Word库(Free Spire.Doc for Java免费版),可手动下载并将lib文件夹夹下的Spire.Doc.jar导入java程序;如果想通过Maven仓库下载导入,可参考这里的jar导入方法。
Java 代码示例:
【示例1】对整个表格设置统一的边框样式
import com.spire.doc.*; import com.spire.doc.documents.BorderStyle; public class TableBorder2 { public static void main(String[] args) { //加载Word文档 Document doc = new Document(); doc.loadFromFile("sample.docx"); //获取Section Section section = doc.getSections().get(0); //获取第一个表格 Table table = section.getTables().get(0); //设置表格边框样式 table.getTableFormat().getBorders().setBorderType(BorderStyle.Thin_Thick_Thin_Large_Gap); //保存文档 doc.saveToFile("TableBorder2.docx",FileFormat.Docx_2013); doc.dispose(); } }
整体边框效果:
【示例2】对表格指定边框设置样式
import com.spire.doc.*; import com.spire.doc.documents.BorderStyle; import java.awt.*; public class TableBorder { public static void main(String[] args) { //加载Word文档 Document doc = new Document(); doc.loadFromFile("sample.docx"); //获取Section Section section = doc.getSections().get(0); //获取第一个表格 Table table = section.getTables().get(0); //设置上边框 table.getTableFormat().getBorders().getTop().setBorderType(BorderStyle.Dot_Dash); table.getTableFormat().getBorders().getTop().setLineWidth(2f); table.getTableFormat().getBorders().getTop().setColor(Color.red); //设置右边框 table.getTableFormat().getBorders().getRight().setBorderType(BorderStyle.Double); table.getTableFormat().getBorders().getRight().setLineWidth(2f); table.getTableFormat().getBorders().getRight().setColor(Color.green); //设置下边框 table.getTableFormat().getBorders().getBottom().setBorderType(BorderStyle.None); //设置左边框 table.getTableFormat().getBorders().getLeft().setBorderType(BorderStyle.Hairline); table.getTableFormat().getBorders().getLeft().setLineWidth(2f); table.getTableFormat().getBorders().getLeft().setColor(Color.blue); //设置垂直边框 table.getTableFormat().getBorders().getVertical().setBorderType(BorderStyle.Dot); table.getTableFormat().getBorders().getVertical().setLineWidth(2f); table.getTableFormat().getBorders().getVertical().setColor(Color.orange); //设置水平边框 table.getTableFormat().getBorders().getHorizontal().setBorderType(BorderStyle.Wave); table.getTableFormat().getBorders().getHorizontal().setLineWidth(2f); table.getTableFormat().getBorders().getHorizontal().setColor(Color.magenta); //保存文档 doc.saveToFile("TableBorder.docx",FileFormat.Docx_2013); doc.dispose(); } }
指定边框设置效果:
【实例3】指定单元格设置边框
import com.spire.doc.*; import com.spire.doc.documents.BorderStyle; import java.awt.*; public class CellBorder { public static void main(String[] args) { //加载Word文档 Document doc = new Document(); doc.loadFromFile("sample.docx"); //获取Section Section section = doc.getSections().get(0); //获取第一个表格 Table table = section.getTables().get(0); //获取单元格,设置上、下边框 TableCell cell1 = table.get(0,0); cell1.getCellFormat().getBorders().getTop().setBorderType(BorderStyle.Single); cell1.getCellFormat().getBorders().getTop().setLineWidth(2f); cell1.getCellFormat().getBorders().getTop().setColor(Color.red); cell1.getCellFormat().getBorders().getBottom().setBorderType(BorderStyle.Dash_Dot_Stroker); cell1.getCellFormat().getBorders().getBottom().setLineWidth(2); cell1.getCellFormat().getBorders().getBottom().setColor(Color.pink); //获取单元格,设置左、右边框 TableCell cell2 = table.get(1,1); cell2.getCellFormat().getBorders().getLeft().setBorderType(BorderStyle.Hairline); cell2.getCellFormat().getBorders().getLeft().setLineWidth(2); cell2.getCellFormat().getBorders().getLeft().setColor(Color.yellow); cell2.getCellFormat().getBorders().getRight().setBorderType(BorderStyle.Double); cell2.getCellFormat().getBorders().getRight().setLineWidth(2f); cell2.getCellFormat().getBorders().getRight().setColor(Color.magenta); //保存文档 doc.saveToFile("CellBorder.docx",FileFormat.Docx_2013); doc.dispose(); } }
单元格边框设置效果:
(完)
-
Word中如何设置表格的边框线样式和颜色
2015-07-27 15:33:19在Word中完成表格制作... 首先,右键点击表格,在弹出的右键菜单中选择“边框和底纹”,在“线形”中我们可以设置边框线的样式。然后在“颜色”中选择自己需求的颜色确定即可。 以下的GIF动画演示会详细的教您Word在Word中完成表格制作工作后,我们可以将表格中的边框线的线形设置成各种样式,不仅不如此,我们还可以将边框线的颜色自由设置。这样的表格就比平常我们看到的表格要多样化一些。下面就看看是如何操作的吧!
首先,右键点击表格,在弹出的右键菜单中选择“边框和底纹”,在“线形”中我们可以设置边框线的样式。然后在“颜色”中选择自己需求的颜色确定即可。以下的GIF动画演示会详细的教您Word中如何设置表格的边框线样式和颜色的!
拖选 任意行 设定改行的边框样式
-
C#/VB.NET设置Word表格边框
2020-06-18 17:35:36文本讲述通过C#和VB.NET程序代码给Word中的表格设置边框的方法,可分为给Table表格设置边框、给表格中的指定Cell设置边框,设置边框时,可设置边框颜色、边框类型、边框线条样式、边框线条粗细等等。 工具导入 ...概述
文本讲述通过C#和VB.NET程序代码给Word中的表格设置边框的方法,可分为给Table表格设置边框、给表格中的指定Cell设置边框,设置边框时,可设置边框颜色、边框类型、边框线条样式、边框线条粗细等等。
工具导入
编辑代码前,先下载需要的Word类库工具,本文中使用的是Spire的免费版库Free Spire.Doc for .NET。下载后,需要解压安装。在VS程序中将安装路径下Bin文件下的Spire.Doc.dll文件添加引用到“解决方案资源管理器”,如下添加引用结果:
代码示例
1. 设置Table边框
[C#]using Spire.Doc; using System.Drawing; namespace SetTableBorder_Doc { class Program { static void Main(string[] args) { //加载Word文档 Document doc = new Document(); doc.LoadFromFile("test.docx"); //获取Section Section section = doc.Sections[0]; //获取第一个表格 Table table = section.Tables[0] as Table; //设置上边框 table.TableFormat.Borders.Top.BorderType = Spire.Doc.Documents.BorderStyle.DotDash; table.TableFormat.Borders.Top.LineWidth = 2.0F; table.TableFormat.Borders.Top.Color = Color.Red; //设置右边框 table.TableFormat.Borders.Right.BorderType = Spire.Doc.Documents.BorderStyle.Double; table.TableFormat.Borders.Right.LineWidth = 2.0F; table.TableFormat.Borders.Right.Color = Color.Green; //设置下边框 table.TableFormat.Borders.Bottom.BorderType = Spire.Doc.Documents.BorderStyle.None; //设置左边框 table.TableFormat.Borders.Left.BorderType = Spire.Doc.Documents.BorderStyle.Hairline; table.TableFormat.Borders.Left.LineWidth = 2.0F; table.TableFormat.Borders.Left.Color = Color.Blue; //设置垂直边框 table.TableFormat.Borders.Vertical.BorderType = Spire.Doc.Documents.BorderStyle.Dot; table.TableFormat.Borders.Vertical.LineWidth = 2.0F; table.TableFormat.Borders.Vertical.Color = Color.Orange; //设置水平边框 table.TableFormat.Borders.Horizontal.BorderType = Spire.Doc.Documents.BorderStyle.Wave; table.TableFormat.Borders.Horizontal.LineWidth = 2.0F; table.TableFormat.Borders.Horizontal.Color = Color.Purple; //保存文档 doc.SaveToFile("SetTableBorder.docx",FileFormat.Docx2013); System.Diagnostics.Process.Start("SetTableBorder.docx"); } } }
表格边框设置结果:
[VB.NET]Imports Spire.Doc Imports System.Drawing Namespace SetTableBorder_Doc Class Program Private Shared Sub Main(args As String()) '加载Word文档 Dim doc As New Document() doc.LoadFromFile("test.docx") '获取Section Dim section As Section = doc.Sections(0) '获取第一个表格 Dim table As Table = TryCast(section.Tables(0), Table) '设置上边框 table.TableFormat.Borders.Top.BorderType = Spire.Doc.Documents.BorderStyle.DotDash table.TableFormat.Borders.Top.LineWidth = 2F table.TableFormat.Borders.Top.Color = Color.Red '设置右边框 table.TableFormat.Borders.Right.BorderType = Spire.Doc.Documents.BorderStyle.[Double] table.TableFormat.Borders.Right.LineWidth = 2F table.TableFormat.Borders.Right.Color = Color.Green '设置下边框 table.TableFormat.Borders.Bottom.BorderType = Spire.Doc.Documents.BorderStyle.None '设置左边框 table.TableFormat.Borders.Left.BorderType = Spire.Doc.Documents.BorderStyle.Hairline table.TableFormat.Borders.Left.LineWidth = 2F table.TableFormat.Borders.Left.Color = Color.Blue '设置垂直边框 table.TableFormat.Borders.Vertical.BorderType = Spire.Doc.Documents.BorderStyle.Dot table.TableFormat.Borders.Vertical.LineWidth = 2F table.TableFormat.Borders.Vertical.Color = Color.Orange '设置水平边框 table.TableFormat.Borders.Horizontal.BorderType = Spire.Doc.Documents.BorderStyle.Wave table.TableFormat.Borders.Horizontal.LineWidth = 2F table.TableFormat.Borders.Horizontal.Color = Color.Purple '保存文档 doc.SaveToFile("SetTableBorder.docx", FileFormat.Docx2013) System.Diagnostics.Process.Start("SetTableBorder.docx") End Sub End Class End Namespace
2. 设置Cell边框
[C#]using Spire.Doc; using System.Drawing; namespace SetCellBorder_Doc { class Program { static void Main(string[] args) { //加载Word文档 Document doc = new Document(); doc.LoadFromFile("test.docx"); //获取Section Section section = doc.Sections[0]; //获取第一个表格 Table table = section.Tables[0] as Table; //获取单元格,设置上、下边框 TableCell cell1 = table[0, 0]; cell1.CellFormat.Borders.Top.BorderType = Spire.Doc.Documents.BorderStyle.Single; cell1.CellFormat.Borders.Top.LineWidth = 2.0F; cell1.CellFormat.Borders.Top.Color = Color.Red; cell1.CellFormat.Borders.Bottom.BorderType = Spire.Doc.Documents.BorderStyle.DashDotStroker; cell1.CellFormat.Borders.Bottom.LineWidth = 2.0F; cell1.CellFormat.Borders.Bottom.Color = Color.Pink; //获取单元格,设置左、右边框 TableCell cell2 = table[2, 2]; cell2.CellFormat.Borders.Left.BorderType = Spire.Doc.Documents.BorderStyle.Hairline; cell2.CellFormat.Borders.Left.LineWidth = 2.0F; cell2.CellFormat.Borders.Left.Color = Color.Yellow; cell2.CellFormat.Borders.Right.BorderType = Spire.Doc.Documents.BorderStyle.Double; cell2.CellFormat.Borders.Right.LineWidth = 2.0F; cell2.CellFormat.Borders.Right.Color = Color.HotPink; //保存文档 doc.SaveToFile("SetCellBorder.docx",FileFormat.Docx2013); System.Diagnostics.Process.Start("SetCellBorder.docx"); } } }
单元格边框设置结果:
[VB.NET]Imports Spire.Doc Imports System.Drawing Namespace SetCellBorder_Doc Class Program Private Shared Sub Main(args As String()) '加载Word文档 Dim doc As New Document() doc.LoadFromFile("test.docx") '获取Section Dim section As Section = doc.Sections(0) '获取第一个表格 Dim table As Table = TryCast(section.Tables(0), Table) '获取单元格,设置上、下边框 Dim cell1 As TableCell = table(0, 0) cell1.CellFormat.Borders.Top.BorderType = Spire.Doc.Documents.BorderStyle.[Single] cell1.CellFormat.Borders.Top.LineWidth = 2F cell1.CellFormat.Borders.Top.Color = Color.Red cell1.CellFormat.Borders.Bottom.BorderType = Spire.Doc.Documents.BorderStyle.DashDotStroker cell1.CellFormat.Borders.Bottom.LineWidth = 2F cell1.CellFormat.Borders.Bottom.Color = Color.Pink '获取单元格,设置左、右边框 Dim cell2 As TableCell = table(2, 2) cell2.CellFormat.Borders.Left.BorderType = Spire.Doc.Documents.BorderStyle.Hairline cell2.CellFormat.Borders.Left.LineWidth = 2F cell2.CellFormat.Borders.Left.Color = Color.Yellow cell2.CellFormat.Borders.Right.BorderType = Spire.Doc.Documents.BorderStyle.[Double] cell2.CellFormat.Borders.Right.LineWidth = 2F cell2.CellFormat.Borders.Right.Color = Color.HotPink '保存文档 doc.SaveToFile("SetCellBorder.docx", FileFormat.Docx2013) System.Diagnostics.Process.Start("SetCellBorder.docx") End Sub End Class End Namespace
-
下边框_C#/VB.NET 设置Word表格边框
2021-01-15 00:19:28概述文本讲述通过C#和http://VB.NET程序代码给Word中的表格设置边框的方法,可分为给Table表格设置边框、给表格中的指定Cell设置边框,设置边框时,可设置边框颜色、边框类型、边框线条样式、边框线条粗细等等。... -
wps怎么把边框加粗_怎么设置WPS表格边框线加粗 - 卡饭网
2020-12-20 00:49:23如何给excel表格边框线加粗如何给excel表格边框线加粗 1.拖动鼠标,选中表格数据~ 2.然后右键鼠标,选中设置单元格选项~ 3.点击边框按钮~ 4.点选外边框和内部两项~ 5.再在左边设置边框加粗的线条大小和颜色~ 6.确定... -
Word线条边框和表格的应用
2015-03-23 11:52:46用Word进行编辑的时候,需要使用线条、边框和表格进行美化,1.下划线:编辑试卷的填空题时要使用下划线做空格,我们可以先输入一些空格,然后选中这些空格,在给空格设置横线为下划线就可以了。2.文字边框首先选择要... -
word横向网格线设置在哪里_用了这么久的Word,居然才知道边框还能这么玩
2021-01-08 20:12:12想让自己设置的Word表格看起来更加美观,表格边框的设置是非常重要的,本期Word妹与大家分享如何玩转表格边框。1、常规的方法选中表格,点击表格工具——设计——边框,之后即可根据自己需要来设置。当然也可以在... -
word横向网格线设置在哪里_word表格中横向网格线
2020-12-24 19:08:20首先显示word的网格线,如下图:接下来,设置网格线,具体路径如下图所示,调出网格线设置窗口:单击绘图网格图标,进行高级设置,上述参数可根据自己的需要进行设置。word中制作的表格如何打印时显示网格线?我在... -
word 如何设置表格边框和文字间的距离
2015-01-07 15:45:20word 如何设置表格边框和文字间的距离 2010-06-23 14:58OlandoV | 分类:办公软件 |...是文字的和两侧的边框线隔得很近 不知道如何实现啊 急求啊 ~~麻烦各位大大了 分享到: 2010-06- -
使用Jacob操作word 添加表格时 如何给表格添加边框线
2018-04-09 09:27:05``` /** *//** * 创建表格 * * @param pos 位置 * @param cols 列数 * @param rows 行数 */ public void createTable(String pos, int numCols,...上面是代码 生成的表格时没有边框线的 请问怎么设置边框线 -
storyboard设置边框颜色_word页面美化技巧:给页面加个漂亮边框,提高吸睛指数...
2020-12-09 19:50:38那就是边框,它可以说是提升Word文档的一大利器,不信?你往下看!学习更多技巧,请收藏关注部落窝教育word图文教程。俗话说“人靠衣装马靠鞍,Word美化靠边框”。当然后半句是我自己说的,不过,非常押韵,嘻嘻!不... -
4设置图片大小_Word制作图片边框、效果与版式,图片SmartArt图形样式设置等技巧...
2021-01-11 18:37:24在 Word 中,图片也跟形状一样可以设置边框和效果,并且还能设置版式。图片版式其实就是把图片转换为 SmartArt 图形,这样可以为图片添加标题或描述,也可以按照选择的 SmartArt 图形样式排列图片,还可以调整图片... -
itext导出word表格,怎么设置表格虚线边框
2016-12-31 22:25:43我看了,貌似只有一些设置表格线宽度,颜色的方法,没有找到设置表格虚线框的方法 -
word表格边框消失怎么办_Word页眉横线一直删除不了?试试这几招轻松搞定!
2020-12-31 13:45:28你是不是经常遇到这种情况:在文档页眉中输入...2、设置无框线进入页眉编辑状态,选中内容,点击开始——段落——边框——无框线。3、设置正文样式进入页眉编辑状态,点击开始——样式——正文。4、利用快捷键进入页... -
word2007、word2010三线表格 自定义表格设置
2011-08-15 15:56:01比业论文里有很多要用三线表,经常有人问我怎么作其实很单,学会了,你两分钟就能做出来,下面我用...2.单击开始→边框和底纹,并设置边框为无 如图: 此时表格变成如下样子: 3.再先中整个表格→单击开始→边框和... -
word表格保存后缺失框线_word表格框线突然没了
2021-01-12 07:28:271. 要想设置Word表格的边框线条不显示出来,最好的办法就是设置线条为无,即不启用边框线。这是最好的办法,方法如下:2. 选中表格,如下图,然后点击鼠标右键,弹出如下图的菜单。3. 如上图,选择“表格属性”,弹... -
Word论文书写--页眉线设置
2019-06-26 19:39:02开始-->段落-->边框和底纹 基本设置如下: 结果: -
word 删除页眉线
2019-03-05 13:15:20word技能 删除页眉线 1、双击页眉 2、选中段落号 3、选择->开始菜单下 段落设置的 表格边框 选中“ 无框线” -
word横向网格线设置在哪里_2分钟学会在Word中制作田字格 米字格 书法练字再也不用买本子了...
2021-01-04 11:11:06昨天朋友留言问到在Excel中如何制作田字格,其实如果真用Excel做,肯定是可以的,主要就是设置表格的边框线等等操作,Excel的功能主要是在数据处理和分析方面,而田字格是纯文字性质的内容,那么是不是我们用Word来... -
python给批量图片添加文字 脚本_word文档添加图片边框很简单?1分钟批量添加100张图片边框的方法...
2021-01-10 03:03:30添加图片边框的基础方法选择文档中需要添加边框的图片,右击选择【设置图片格式】,选择【线条】,添加线条边框即可。利用宏批量为图片添加边框点击【视图】-【宏】按钮,然后选择【查看宏】输入宏的名字【img】,... -
柱状图设置边框_薯条组成的PPT柱状图,你见过吗?
2021-01-15 04:04:31微信扫码观看全套Excel、Word、PPT视频编按: PPT中有很多柱形图、条形图,怎么做能更直观更让人愿意多看一眼?很简单,用实物图案或者图形来组成或排列成柱形图、条形图即可。表格也是,传统的线框表,很容易流于... -
word顶部有一道线_word文档上方总有一条线怎样去掉?
2021-02-05 01:23:40设置“边框和底纹”去掉word页眉横线在“边框和底纹”对话框中可以去掉word页眉横线,操作步骤如下所述:第1步,打开word文档窗口,在菜单栏依次单击“视图”→“页眉和页脚”菜单命令,使“页眉”处于编辑状态。... -
word删除水平线(分割线)的方法(原创)
2013-06-29 14:32:00在word里面,有时候我们会输入3个“-”或者“=”等符合,然后一个回车,生成了一条水平线(分割线)。 研究了很久,今天终于发现删除它的方法了。 选中文本,点“格式”,选中“边框和底线”,点第一个子页面... -
word三线格模版绘制
2020-11-24 16:58:19启动word2013或2016,点击插入表格,在表格...按上述步骤选定细实线,线宽为0.5磅,边框选择下框线。 6 最后选则“基于该模版的新文档”,单击确定退出。 7 从表格样式栏中即可看到刚刚成功创建的三线表格样.. -
wps怎么把边框加粗_WPS文字表格怎么把表格外框线加粗?
2021-02-05 01:33:38一、对word表格整个表格进行边框加粗:选中表格,右击-“边框和底纹”,有个“线形”和“宽度”的选项,这里默认的是选择“全部”,这样即可将整个表格的边框线进行加粗了。二、单独对word表格的外边框和网格线进行... -
lisp加粗匣线框_怎么在word中给表格加粗匣框线
2021-01-27 06:28:36一、对word表格整个表格进行边框加粗:选中表格,右击-“边框和底纹”,有个“线形”和“宽度”的选项,这里默认的是选择“全部”,这样即可将整个表格的边框线进行加粗了。二、单独对word表格的外边框和网格线进行... -
word文档最上面有一条不是页眉的线
2019-04-10 21:22:00word2013文档最上面有一条不是页眉的线 在编辑Word文档时发现文档上面出现了一条实线,而且并非页眉,这里我采取了一个方式: 找到【设计】---【页面边框】 找到【边框和底纹】----【页面边框】,选择【设置... -
WORD2010如何添加双线页眉
2012-12-30 21:55:24定位在页眉,点“格式——边框和底纹”,在线型中选择你需要的线型、颜色、宽度,在右边“应用于”中选择“段落”,在左边 “设置”中选择“自定义”,在右边“预览”中只保留下线。 -
关于word2010指定位置插入页码及三线表格绘制问题
2016-01-26 16:13:45关于word2010在指定位置插入页码及三线表格绘制问题 一、word指定位置插入页码 1.首先将光标移到该页的首位置; 2.页面布局->插入分隔符;...3.右击鼠标,选择边框底纹,在边框位置选择自定义,可以设置最上面和最