Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void Mat_Multiply(Args _args)
- {
- CCADOConnection adoConnection;
- CCADOCommand adoCommand,adoCommands2;
- CCADORecordSet adoRecordSet,adoRecordSets2;
- CCADOFields adoFields,adoFields2;
- CCADOField adoField;
- int i,j,k,mno1,mno2,mul;
- int noofrows1,noofcols1, noofrows2,noofcols2;
- ;
- adoConnection = new CCADOConnection();
- adoRecordSet = new CCADORecordSet();
- adoConnection.open("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + 'D:\Testing.xlsx' + ";Extended Properties='Excel 12.0;HDR=No;IMEX=1'"); // for excel 2010
- adoCommand = new CCADOCommand();
- adoCommand.activeConnection(adoConnection);
- adoCommand.commandText(@"SELECT * FROM [SHEET1$]");
- adoRecordSet = adoCommand.execute();
- adoCommands2 = new CCADOCommand();
- adoCommands2.activeConnection(adoConnection);
- adoCommands2.commandText(@"SELECT * FROM [SHEET2$]");
- adoRecordSets2 = adoCommands2.execute();
- //Calculate rows and columns
- noofcols1 = adoRecordSet.fields().count();
- while(!adoRecordSet.EOF())
- {
- adoRecordSet.recordSet().MoveNext();
- noofrows1++;
- }
- noofcols2 = adoRecordSets2.fields().count();
- while(!adoRecordSets2.EOF())
- {
- adoRecordSets2.recordSet().MoveNext();
- noofrows2++;
- }
- //Calculate rows and columns
- if(noofcols1==noofrows2)
- {
- adoCommand.commandText(@"SELECT * FROM [SHEET1$]");
- adoRecordSet = adoCommand.execute();
- adoCommands2.commandText(@"SELECT * FROM [SHEET2$]");
- adoRecordSets2 = adoCommands2.execute();
- adoFields = adoRecordSet.fields();
- adoFields2 = adoRecordSets2.fields();
- for(i=0;i<noofrows1;i++)
- {
- for(j=0;j<noofcols1;j++)
- {
- mul = 0;
- for(k=0;k<noofrows2;k++)
- {
- mno1=adoFields.itemIdx(k).value();
- mno2 = adoFields2.itemIdx(j).value();
- mul+=mno1*mno2;
- adoRecordSets2.recordSet().moveNext();
- }
- adoCommands2.commandText(@"SELECT * FROM [SHEET2$]");
- adoRecordSets2 = adoCommands2.execute();
- adoFields2 = adoRecordSets2.fields();
- print mul;
- }
- adoRecordSet.recordSet().moveNext();
- }
- pause;
- }
- else
- {
- info("Mul not possible");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement