那位高手知道给点意见.
11 个解决方案
#1
没有什么好办法,只能用低版本的WORD组件进行开发.如果用高版本的WORD组件就会有你出现的问题.
#2
UP
#3
那么我这句wa.ActiveDocument.Tables[3].Cell(i+4,j).Range.Text = ds.Tables["ds12"].Rows[i][j-1].ToString();能不能给点意见,怎么改?
Word.ApplicationClass wa;
private DataSet ds = new DataSet();
Word.ApplicationClass wa;
private DataSet ds = new DataSet();
#4
up
#5
给你点我原来写的代码.如何新增Table并在里面插入数据.
appWord1.AddTable(3, 9);//插入题分表格,这里为固定格式
appWord1.InsertText("题 号");
appWord1.GoToRightCell();
appWord1.InsertText("一 题");
appWord1.GoToRightCell();
appWord1.InsertText("二 题");
appWord1.GoToRightCell();
appWord1.InsertText("三 题");
appWord1.GoToRightCell();
appWord1.InsertText("四 题");
appWord1.GoToRightCell();
appWord1.InsertText("五 题");
appWord1.GoToRightCell();
appWord1.InsertText("六 题");
appWord1.GoToRightCell();
appWord1.InsertText("七 题");
appWord1.GoToRightCell();
appWord1.InsertText("总 分");
appWord1.GoToRightCell();
appWord1.InsertText("题 分");
public void AddTable(int nRows, int nColumns)
{ Word.Range WdRange = oWordApplic.Selection.Range;
object oDefTableBehavior = Word.WdDefaultTableBehavior.wdWord9TableBehavior;
object oAtoFitBehavior = Word.WdAutoFitBehavior.wdAutoFitFixed;
oDoc.Tables.Add(WdRange, nRows, nColumns, ref oDefTableBehavior, ref oAtoFitBehavior);
}
public void GoToRightCell( )
{
object missing = System.Reflection.Missing.Value;
object direction = Word.WdUnits.wdCell;
oWordApplic.Selection.MoveRight(ref direction,ref missing,ref missing);
}
public void InsertText(string strText)
{
oWordApplic.Selection.TypeText(strText);
}
appWord1.AddTable(3, 9);//插入题分表格,这里为固定格式
appWord1.InsertText("题 号");
appWord1.GoToRightCell();
appWord1.InsertText("一 题");
appWord1.GoToRightCell();
appWord1.InsertText("二 题");
appWord1.GoToRightCell();
appWord1.InsertText("三 题");
appWord1.GoToRightCell();
appWord1.InsertText("四 题");
appWord1.GoToRightCell();
appWord1.InsertText("五 题");
appWord1.GoToRightCell();
appWord1.InsertText("六 题");
appWord1.GoToRightCell();
appWord1.InsertText("七 题");
appWord1.GoToRightCell();
appWord1.InsertText("总 分");
appWord1.GoToRightCell();
appWord1.InsertText("题 分");
public void AddTable(int nRows, int nColumns)
{ Word.Range WdRange = oWordApplic.Selection.Range;
object oDefTableBehavior = Word.WdDefaultTableBehavior.wdWord9TableBehavior;
object oAtoFitBehavior = Word.WdAutoFitBehavior.wdAutoFitFixed;
oDoc.Tables.Add(WdRange, nRows, nColumns, ref oDefTableBehavior, ref oAtoFitBehavior);
}
public void GoToRightCell( )
{
object missing = System.Reflection.Missing.Value;
object direction = Word.WdUnits.wdCell;
oWordApplic.Selection.MoveRight(ref direction,ref missing,ref missing);
}
public void InsertText(string strText)
{
oWordApplic.Selection.TypeText(strText);
}
#6
我要在原有模板中添加数据,不需新增Table
#7
你可以用代码先选中Table或者单元格,再用上面插入数据的方法就行了.
#8
问题就是现在我知道怎么选中Table或者单元格
#9
问题还没解决,请高手提点
#10
.................
#11
关注
#1
没有什么好办法,只能用低版本的WORD组件进行开发.如果用高版本的WORD组件就会有你出现的问题.
#2
UP
#3
那么我这句wa.ActiveDocument.Tables[3].Cell(i+4,j).Range.Text = ds.Tables["ds12"].Rows[i][j-1].ToString();能不能给点意见,怎么改?
Word.ApplicationClass wa;
private DataSet ds = new DataSet();
Word.ApplicationClass wa;
private DataSet ds = new DataSet();
#4
up
#5
给你点我原来写的代码.如何新增Table并在里面插入数据.
appWord1.AddTable(3, 9);//插入题分表格,这里为固定格式
appWord1.InsertText("题 号");
appWord1.GoToRightCell();
appWord1.InsertText("一 题");
appWord1.GoToRightCell();
appWord1.InsertText("二 题");
appWord1.GoToRightCell();
appWord1.InsertText("三 题");
appWord1.GoToRightCell();
appWord1.InsertText("四 题");
appWord1.GoToRightCell();
appWord1.InsertText("五 题");
appWord1.GoToRightCell();
appWord1.InsertText("六 题");
appWord1.GoToRightCell();
appWord1.InsertText("七 题");
appWord1.GoToRightCell();
appWord1.InsertText("总 分");
appWord1.GoToRightCell();
appWord1.InsertText("题 分");
public void AddTable(int nRows, int nColumns)
{ Word.Range WdRange = oWordApplic.Selection.Range;
object oDefTableBehavior = Word.WdDefaultTableBehavior.wdWord9TableBehavior;
object oAtoFitBehavior = Word.WdAutoFitBehavior.wdAutoFitFixed;
oDoc.Tables.Add(WdRange, nRows, nColumns, ref oDefTableBehavior, ref oAtoFitBehavior);
}
public void GoToRightCell( )
{
object missing = System.Reflection.Missing.Value;
object direction = Word.WdUnits.wdCell;
oWordApplic.Selection.MoveRight(ref direction,ref missing,ref missing);
}
public void InsertText(string strText)
{
oWordApplic.Selection.TypeText(strText);
}
appWord1.AddTable(3, 9);//插入题分表格,这里为固定格式
appWord1.InsertText("题 号");
appWord1.GoToRightCell();
appWord1.InsertText("一 题");
appWord1.GoToRightCell();
appWord1.InsertText("二 题");
appWord1.GoToRightCell();
appWord1.InsertText("三 题");
appWord1.GoToRightCell();
appWord1.InsertText("四 题");
appWord1.GoToRightCell();
appWord1.InsertText("五 题");
appWord1.GoToRightCell();
appWord1.InsertText("六 题");
appWord1.GoToRightCell();
appWord1.InsertText("七 题");
appWord1.GoToRightCell();
appWord1.InsertText("总 分");
appWord1.GoToRightCell();
appWord1.InsertText("题 分");
public void AddTable(int nRows, int nColumns)
{ Word.Range WdRange = oWordApplic.Selection.Range;
object oDefTableBehavior = Word.WdDefaultTableBehavior.wdWord9TableBehavior;
object oAtoFitBehavior = Word.WdAutoFitBehavior.wdAutoFitFixed;
oDoc.Tables.Add(WdRange, nRows, nColumns, ref oDefTableBehavior, ref oAtoFitBehavior);
}
public void GoToRightCell( )
{
object missing = System.Reflection.Missing.Value;
object direction = Word.WdUnits.wdCell;
oWordApplic.Selection.MoveRight(ref direction,ref missing,ref missing);
}
public void InsertText(string strText)
{
oWordApplic.Selection.TypeText(strText);
}
#6
我要在原有模板中添加数据,不需新增Table
#7
你可以用代码先选中Table或者单元格,再用上面插入数据的方法就行了.
#8
问题就是现在我知道怎么选中Table或者单元格
#9
问题还没解决,请高手提点
#10
.................
#11
关注