Axapta provides some classes for Excel operations. These classes are actually encapsulation of the COM Object excel. application. Because axapta does not support Unicode, the following errors may occur for Excel files containing Chinese characters:CodeIf it is a Chinese character in Excel, only half of the output can be made.
Void Getdatafromexcel ()
{
Sysexcelapplication app;
Sysexcelworksheets WSS;
Sysexcelworksheet ws;
Sysexcelworkbooks WBS;
Sysexcelworkbook WB;
Container C;
STR strvalue;
Int Rowline;
Int Colline;
;
App = Sysexcelapplication: Construct ();
WBS = App. workbooks ();
WBS. Open (strfilepath, 0 , True );
WB = WBS. Item ( 1 );
WSS = WB. worksheets ();
WS = WSS. itemfromname ( " Itemdata " );
Print ws. cells (). Item ( 1 , 1 ). Value (). BSTR ();
App. Quit ();
Pause;
}
I don't want to take the effort to convert between COM and Excel files. I think that excel is actually a database, so reading data through odbcconnection is also a good way. Static Void Readdatafromexcel (ARGs _ ARGs)
{
Loginproperty LP;
Odbcconnection OD;
Statement st;
Resultset RS;
;
Lp = New Loginproperty ();
LP. setdsn ( " Itemdata " );
Od = New Odbcconnection (LP );
St = OD. createstatement ();
RS = St.exe cutequery ( " Select * from [itemdata $] " );
While (Rs. Next ())
{
Print Rs. getstring (1);
}
Pause;
}
in this way, all data can be read.