Advertisement
ramkesheoran

Import from excel to ax table

Jan 12th, 2012
3,188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XPP 0.88 KB | None | 0 0
  1. static void Import_INTO_Table(Args _args)
  2. {
  3.     CCADOConnection         adoConnection;
  4.     CCADOCommand            adoCommand;
  5.     CCADORecordSet          adoRecordSet;
  6.     CCADOFields             adoFields;
  7.     int                     firstcell;
  8.     ;
  9.     adoConnection = new CCADOConnection();
  10.     adoRecordSet = new CCADORecordSet();
  11.     adoCommand = new CCADOCommand();
  12.     adoConnection.open("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + 'D:\ImportData\\Test.xlsx' + ";Extended Properties='Excel 12.0;HDR=No;IMEX=1'"); // for excel 2010
  13.     adoCommand.activeConnection(adoConnection);
  14.     adoCommand.commandText(@"SELECT * FROM [SHEET1$]");
  15.     adoRecordSet = adoCommand.execute();
  16.     while(!adoRecordSet.EOF())
  17.      {
  18.         adoFields = adoRecordSet.fields();
  19.         firstcell = adoFields.itemIdx(0).value();
  20.         adoRecordSet.recordSet().MoveNext();
  21.      }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement