日期:2014-05-19  浏览次数:20878 次

如何拆分word的表格。很急啊!!!!!!!
大家好。在word的工具里有个“绘制表格”。他是个画笔样的东西。
现在程序里怎么调用呢。也就是说在指定位置拆分表格。

------解决方案--------------------
告诉你一个简单的方法,在word的工具\宏菜单中,录制新宏。
然后你在word中做拆分表格的操作,word会自动在宏中记录实现的脚本。
这些脚本只要改动一下就可以在.net使用。
------解决方案--------------------
楼上正是,
录制宏再看其代码
------解决方案--------------------
可以先创建一个表格
using Word=Microsoft.Office.Interop.Word;

Word.Application wordApp=newWord.ApplicationClass();
Word.Document wordDoc=wordApp.Documents.Add(refNothing,refNothing,refNothing,refNothing);

//设置文档宽度
wordApp.Selection.PageSetup.LeftMargin=wordApp.CentimetersToPoints(float.Parse( "2 "));
wordApp.ActiveWindow.ActivePane.HorizontalPercentScrolled=11;
wordApp.Selection.PageSetup.RightMargin=wordApp.CentimetersToPoints(float.Parse( "2 "));

//设置横向排版
wordApp.Selection.PageSetup.Orientation=Word.WdOrientation.wdOrientLandscape;

Object start=Type.Missing;
Object end=Type.Missing;
start=o;
end=o;
Word.Rangerng=wordDoc.Range(refstart,refend);
rng.InsertBefore(strInfo);
rng.SetRange(rng.End,rng.End)

//创建16行7列的表格
Word.Tabletbl=rng.Tables.Add(rng,16,7,refmissingValue,refmissingValue);
tbl.Rows.HeightRule=Word.WdRowHeightRule.wdRowHeightAtLeast;
tbl.Rows.Height=wordApp.CentimetersToPoints(float.Parse( "0.8 "));
tbl.Range.Font.Size=9;
tbl.Range.Font.Name= "宋体 ";
tbl.Range.Font.Bold=1;
tbl.Range.ParagraphFormat.Alignment=Word.WdParagraphAlignment.wdAlignParagraphCenter;
tbl.Range.Cells.VerticalAlignment=Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
tbl.Borders.InsideLineWidth=Word.WdLineWidth.wdLineWidth150pt;
......

然后合并某些相邻的单元格

tbl.Cell(1,1).Merge(tbl.Cell(2,1));
------解决方案--------------------
Selection.SplitTable