excel help please!

FiveFive Member Posts: 32
Hello all,

I am new at navision and have a couple of questions.

i have developed a report that exports to an excel file that already exists.The export works fine but the problem is the excel fine already has data and data keeps getting over written.My question is

' Is there a way of finding the row number of the last record in the excel file?So that i can place my data in the next row.

below is the code:
j := '5';
REPEAT
Sheet.Range('A'+j).Value := Item."No." ;
Sheet.Range('B'+j).Value := Item.Description;
j:=INCSTR(j);
UNTIL ItemHistory.NEXT = 0;
etc etc

but the next time i open the file j won't be 5 it will be six
j is hardcoded...i would like j to be the next empty row in the excel file.
Thanks to all that reply..
Compile and then Recompile ....

Comments

  • SteveOSteveO Member Posts: 164
    There is a standard table called Excel Buffer (ID 370).
    This has functions for importing and exporting excel worksheets.
    Why not do the following.

    If File Exists then
    import worksheet into Excel buffer;

    Excel Buffer.Find last (it is keyed on Row No, Col No. so this will return the last row that is in the file, If the file didn't exist then this will be 0 as no record would have been found).

    Increment the row no.
    Carry on populating the Excel buffer.
    When finished
    Use Excel Buffer function to export to Excel.

    If you need any help using the Excel Buffer table then don't hesitate to ask
    :D
    This isn't a signature, I type this at the bottom of every message
  • murtazakhanmurtazakhan Member Posts: 11
    HI Steve,
    I am new to Navision and working on Navision v4.0 sp3 with no add ons. I want to export data to Excel. Kindly help. i am in a big fix and have been banging my head with Navision ](*,) but all in vein.

    Please please please help.
    Regards,
    Murtaza
  • abhi1901abhi1901 Member Posts: 102
    I think with automation variable it very much difficult to add new row at end.

    You have to use excel buffer , import excel sheet then use findlast before inserting new row.

    Or at the time of writing report you can check that current record contains a value or not.

    Have to try.
Sign In or Register to comment.