用C++或者VB写一个程序读取一个excel文件的sheet1与sheet2,并使sheet1与sheet2对应的地方相乘 20
谢谢大神!!! 展开
Sub aaa()
If Application.Dialogs(xlDialogOpen).Show Then
On Error Resume Next
For C = 1 To 3
For R = 1 To 9
ThisWorkbook.Sheets(1).Cells(R, C) = ActiveWorkbook.Sheets(1).Cells(R, C).Value
ThisWorkbook.Sheets(2).Cells(R, C) = ActiveWorkbook.Sheets(2).Cells(R, C).Value
ThisWorkbook.Sheets(3).Cells(R, C) = ThisWorkbook.Sheets(1).Cells(R, C).Value * ThisWorkbook.Sheets(2).Cells(R, C).Value
Next R
Next C
ActiveWorkbook.Close (False)
ThisWorkbook.Save
MsgBox "Done!"
End If
End Sub
附件下载下来用一下,看看是不是你要的效果。
CDaoDatabase m_db;
CDaoRecordset *m_Set;
COleVariant var;
try
{
m_db.Open(path,0,0,"Excel 4.0");
}
catch(CDaoException *e)
{
MessageBox(e->m_pErrorInfo->m_strDescription,"打开失败");
e->Delete();
}
m_set=new CDaoRecordset(&m_db);
m_set->Open(-1,"select * from [sheet1$]",0);
m_set->GetFieldValue(index,&var);
/*自己写*/
m_set->Clsoe();
m_db.Clsoe();