Word版本转换的一个小问题,在线等,急!!!! 我用Microsoft Word 11.0 Object Library制作的,将数据库数据导入Word表格中.现 把其转换到Microsoft Word 9.0 Object Library下使用时,出现"无法将带[]的索引应用于"Word.Tables"类型的表达式."那位高手知道给点意见. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 没有什么好办法,只能用低版本的WORD组件进行开发.如果用高版本的WORD组件就会有你出现的问题. 那么我这句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(); 给你点我原来写的代码.如何新增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); } 我要在原有模板中添加数据,不需新增Table 你可以用代码先选中Table或者单元格,再用上面插入数据的方法就行了. 问题就是现在我知道怎么选中Table或者单元格 问个简单的问题有好心人解答一下 请求,c#中对于结构的理解! 1个头疼的问题(鼠标事件) 怎么在webbrowser浏览的页面里增加一段js? 如何实现控件里的下拉嵌入(好像combobox + monthCalendar = datetimepacker) 一个发了三个帖没人解决的正则表达式问题 找到一个免费空间还支持.net 请问一下是先学vc++再学vc#好,还是直接就学vc#呢? 为什么控件无法显示在页面上??? 初学很菜问题:关于enum,帮帮我。 DataGridView排序问题 有多少同行在用C#做WINFORM程序???
Word.ApplicationClass wa;
private DataSet ds = new DataSet();
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);
}