Options

Automation (export to Excel)

AngeloAngelo Member Posts: 180
I have a little problem with export data to excell

I want to transfer Item."no." = 330000000000000021(18 digits) to excell but when I open Excell, it will show 330000000000000000(18 digits).

Sheet.Cells.NumberFormat := '#####'; \:D/
//this code not help much more....

Anyone can help me to solve my problems?
Please help me sooonnn......

Comments

  • Options
    Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    Try sending it as text to Excel by preceding the Item No. with the ' sign.
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • Options
    randrewsrandrews Member Posts: 135
    I thing you must export as TEXT (not number).
  • Options
    nostrannostran Member Posts: 106
    just checking, u did you export it as csv file?
  • Options
    AngeloAngelo Member Posts: 180
    export as text?? I get my Item No. from field Item.

    My code :

    intRow := 1;
    if item.find('-') then begin
    repeat
    .... // code
    Sheet.Range('A' + FORMAT(intRow)).Value := item."No.";
    intRow := intRow + 1;
    ... // code
    until item.next = 0;
    end;

    any suggestions again?please....
  • Options
    Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    Replace
    Sheet.Range('A' + FORMAT(intRow)).Value := item."No.";
    

    with
    Sheet.Range('A' + FORMAT(intRow)).Value := ''' + item."No.";
    
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • Options
    AngeloAngelo Member Posts: 180
    I have replace my code but in excel show :

    3.3E + 17 ? :-k
  • Options
    Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    I made a typo:

    Use:
    Sheet.Range('A' + FORMAT(intRow)).Value := '''' + item."No.";
    

    This shows the number correctly in Excel (2003), with a exclamation mark "The number in this cell is if formatted as text or preceded by an apostrophe.".
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • Options
    randrewsrandrews Member Posts: 135
    May Be...
    Sheet.Cells.NumberFormat := '@';
  • Options
    AngeloAngelo Member Posts: 180
    Thanks all for giving me solution of my problem...

    Sheet.Range('A' + FORMAT(intRow)).Value := '''' + item."No.";
    OR
    Sheet.Cells.NumberFormat := '@';

    Both of above give same result n solve my problem. Thanks a lot.....

    Now, I hav another problem :
    If you saw my codes before, it show Item.no from beginning until last ( repeat until item.next = 0 ). when I click a button to begin exporting to excel, it will give a lot of time ( maybe because of a lot of Item in my item table ) before displaying in excel. is it natural happen in Navision when exporting to excel ? if not, How to handle this ?


    When Navision export to excel ( on processing ) and I deliberately close my Excel, then I back to Navision, it will show error :

    "Could not invoke the member range. The OLE Control or Automation server returned an unknown error code."

    Is it natural happen in Navision too? What should I do to not show this error message again when I close my Excel when Navision on processing ?

    Please, give me suggestions....... [-o<

    regards,
    Angelo
  • Options
    Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    To speed up processing to Excel, you should hide Excel until automation is completed. Then you can make Excel visible with all data.

    So after you create an instance of Excel, you use:
    autExcelAppl.Visible(FALSE);
    
    And after you have send all data to Excel, you use:
    autExcelAppl.Visible(TRUE);
    
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • Options
    AngeloAngelo Member Posts: 180
    Thank you for all master....especially Luc Van Dyck
    :D
Sign In or Register to comment.