代码如下:
C#
int iCount;
for (int idr = 0; idr < drs.Count; idr++)
{
iCount = idr + 1;
count = 0;
wordApp.Selection.MoveLeft(ref unit, ref count, ref extend);
//
wordApp.Selection.TypeText(iCount.ToString());
for (int idbField = 0; idbField < db.FieldNames.Length; idbField++)
{
//
count = 1;
wordApp.Selection.Move(ref unit, ref count);
string text = db.FieldNames[idbField];
wordApp.Selection.TypeText(text);
}
// 插入新的记录行
wordApp.Selection.InsertRowsBelow(ref extend);
}在指定位置插入表格,db.FieldNames.Length 列;drs.Count行,请问在VC中如何实现,
C#
int iCount;
for (int idr = 0; idr < drs.Count; idr++)
{
iCount = idr + 1;
count = 0;
wordApp.Selection.MoveLeft(ref unit, ref count, ref extend);
//
wordApp.Selection.TypeText(iCount.ToString());
for (int idbField = 0; idbField < db.FieldNames.Length; idbField++)
{
//
count = 1;
wordApp.Selection.Move(ref unit, ref count);
string text = db.FieldNames[idbField];
wordApp.Selection.TypeText(text);
}
// 插入新的记录行
wordApp.Selection.InsertRowsBelow(ref extend);
}在指定位置插入表格,db.FieldNames.Length 列;drs.Count行,请问在VC中如何实现,
解决方案 »
- 关于MDI子窗口的问题
- 请问怎么样才能取到DATAGRID控件里某一行某一个字段的值
- 求助:要开发一个在线实时监测的系统,用那种语言好了?
- 如何直接连接EXCEL文件,取得它的所有表名,以及所有字段名???重谢,本人从没有提问了不结贴过。
- 紧急问题!!!!!!!!!!!!
- 请问在VC中如何实现象windows taskbar一样自动隐藏/探出的窗口?
- 如何在C++中设置3个缓冲区来存储3个不同的图片?谢谢
- 为什么C程序中许多变量和函数都有一个下划线前缀?有什么意义吗?
- 绝对难题
- mfc动态创建picture控件後,SetBitmap没几秒钟,整个主程序卡死,求解决
- ACCESS+VC查询的问题,急啊!!!
- 万能的VC区,如何用手机模拟器模拟手机上网?
你直接用ADO来访问库就行了。
_Application app;
app.CreateDispatch(_T("Word.Application"));
app.SetVisible(TRUE);
Documents docs=app.GetDocuments();
CComVariant Template(_T("")); //不使用WORD的文档模板
CComVariant NewTemplate(false),DocumentType(0),Visible;
_Document doc = docs.Add(&Template,&NewTemplate,&DocumentType,&Visible);
//绘制5*6的表格
CComVariant vFalse(false),vTrue(true);
Tables tables = doc.GetTables();
_Table table = tables.Add(sel.GetRange(),5,6,&vTrue,&vFalse);
//往表格填充文字
....................
//释放资源
table.ReleaseDispatch();
tables.ReleaseDispatch();
doc.ReleaseDispatch();
docs.ReleaseDispatch();
CComVariant SaveChanges(false),OriginalFormat,RouteDocument;
app.Quit(&SaveChanges,&OriginalFormat,&RouteDocument);
app.ReleaseDispatch();
{
iCount = i + 1;
count->intVal = 0;
spApp->Selection->MoveLeft(COleVariant("1"),COleVariant("3"),COleVariant("3"));
// 得到记录行数
int nIndexF = 5;
int j=0;
for (j =0; j < nIndexF; j++)
{
gridHF[j] = fields.GetAt(j);
count->intVal = 1;
spApp->Selection->Move(unit, count);
spApp->Selection->TypeText((_bstr_t)gridHF[j]);
}
// 插入新的记录行
spApp->Selection->InsertRowsBelow(extend);
}我按照C#格式改写了,程序不能运行,各位我写的那理由问题,请指出来,不胜感激