求教!如何多行输入ACCESS2000数据表里的数据到WORD表格中
请教各位大神:
TVariant mbwjlj=Form1->wjlj+"\sybgmb\\试验报告.doc";
WordDocument1->ConnectTo(WordApplication1->Documents->Add(&mbwjlj, EmptyParam));
WordDocument1->Tables->Item(1)->Cell(5,3)->Range->set_Text(WideString(ADODataSet1->Fields->Fields[2]->AsString));
WordDocument1->Tables->Item(1)->Cell(7,3)->Range->set_Text(WideString(ADODataSet1->Fields->Fields[3]->AsString));
WordDocument1->Tables->Item(1)->Cell(7,4)->Range->set_Text(WideString(ADODataSet1->Fields->Fields[4]->AsString));
WordDocument1->Tables->Item(1)->Cell(7,5)->Range->set_Text(WideString(ADODataSet1->Fields->Fields[5]->AsString));
WordDocument1->Tables->Item(1)->Cell(11,2)->Range->set_Text(WideString(ADODataSet1->Fields->Fields[6]->AsString));
WordDocument1->Tables->Item(1)->Cell(2,2)->Range->set_Text(WideString(ADODataSet1->Fields->Fields[1]->AsString));
我用的是ADO组件来读取的ACCESS数据表里的数据到WORD表格,但是它只能默认读取数据表第一行的内容,如果我要读取多行数据到word表格,请问该怎么操作,感激!!
[解决办法]
打开数据集以后,用一个循环来遍历记录集,如:
ADODataSet1->Open();
for (int i = 0; i < ADODataSet1->RecordCount; i++)
{
WordDocument1->Tables->Item(1)->Cell(5,3)->Range->set_Text(WideString(ADODataSet1->Fields->Fields[2]->AsString));
...
ADODataSet1->Next();
}