Importing Excel Data to axapta

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.