Import axapta 3.0 in Excel

Source: Internet
Author: User

Void clicked () <br/>{< br/> sysexcelapplication Excel; <br/> sysexcelworkbooks books; <br/> sysexcelworkbook book; <br/> sysexcelworksheets; <br/> sysexcelworksheet sheet; <br/> sysexcelcells; <br/> sysexcelcell cell; <br/> sysexcelstyles; <br/> sysexcelstyle style; <br/> int rowcount, recnum, N; <br/> filename _ filenameopen; <br/> xyf_contactstable _ contactstable; <br/> dialog _ d Ialog; <br/> dialogfield dlgpath; <br/> dictenum <br/>; </P> <p> _ dialog = new dialog ('import ...... '); <br/> dlgpath = _ dialog. addfield (typeid (filenameopen); <br/> dictenum = new dictenum (enumname2id ('xyf _ contacststype '); <br/> _ dialog. doinit (); <br/> If (_ dialog. run () <br/>{< br/> try <br/>{< br/> _ filenameopen = dlgpath. value (); <br/> Excel = sysexcelapplication: Construct (); <br/> B Ooks = excel. workbooks (); <br/> books. open (_ filenameopen, true); </P> <p> book = books. item (1); <br/> sheets = book. worksheets (); <br/> Sheet = sheets. itemfromnum (1); <br/> cells = sheet. cells (); <br/> delete_from _ contactstable; </P> <p> rowcount = 2; // data is retrieved from the second row and the field name is stored in the first row. <br/> for (rowcount = 2; cells. item (rowcount, 1 ). value (). BSTR ()! = ""; Rowcount ++) <br/>{< br/> recnum ++; </P> <p> n = 1; <br/> _ contactstable. name = cells. item (rowcount, n ). value (). BSTR (); <br/> N ++; <br/> _ contactstable. namealias = cells. item (rowcount, n ). value (). BSTR (); <br/> N ++; </P> <p> _ contactstable. tel = cells. item (rowcount, n ). value (). BSTR (); <br/> If (! _ Contactstable. tel) <br/> _ contactstable. tel = cells. item (rowcount, n ). value (). tostring (); <br/> If (strscan (_ contactstable. tel, ',', 1, strlen (_ contactstable. tel) <br/> _ contactstable. tel = strreplace (_ contactstable. tel, ',', ''); <br/> If (strscan (_ contactstable. tel ,'. ', 1, strlen (_ contactstable. tel) <br/> _ contactstable. tel = strreplace (_ contactstable. tel ,'. ', ''); <br/> N ++; </P> <p> _ contactstable. tel _ Fixed = cells. item (rowcount, n ). value (). BSTR (); <br/> N ++; <br/> _ contactstable. qq = cells. item (rowcount, n ). value (). double (); <br/> N ++; <br/> _ contactstable. email = cells. item (rowcount, n ). value (). BSTR (); <br/> N ++; <br/> // _ contactstable. xyf_contacststype = dictenum. symbol2value (cells. item (rowcount, n ). <br/> // the English name of symbol2value is converted to an integer value <br/> _ contactstable. xyf_contacststype = dictenum. name2value (Cells. Item (rowcount, n ). <br/> value (). BSTR (); // convert the label value of the name2value Chinese enumeration to an integer value </P> <p> N ++; <br/> _ contactstable. address = cells. item (rowcount, n ). value (). BSTR (); </P> <p> // n ++; <br/> // _ contactstable. photo = cells. item (rowcount, n ). value (). container (); </P> <p> If (_ contactstable. name! = "") <Br/> _ contactstable. doinsert (); </P> <p >}< br/> catch (exception: Error) <br/> excel. quit (); <br/> Info (strfmt ("import into xyf_contactstable of % 1", recnum); <br/> excel. quit (); <br/> xyf_contactstable_ds.executequery (); <br/> xyf_contactstable_ds.research (); <br/>}< br/>}

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.