• create,save,open excel file sorted on a col#

    From timepro timesheet@21:1/5 to All on Mon Dec 12 16:51:16 2022
    hi:

    -what is the code/syntax to create,save,open an excel file 'sorted' on col#12 (cF.Y)-

    xtitlecolumns:={{'n#',1},{'cClient',2},{'dInvDate',3},{'nFees-Amt',4}...{'nOPE-Amt',10},{'nTax',11},{'cF.Y',12},...{'nCredit-Note',48}}

    oexcel=createobject('excel.application')
    oexcel:workbooks:add()
    osheet=oexcel:activesheet

    sele billfile;set orde to 4
    do whil !eof() && .dbf file indexed on 'dInvDate'
    ...
    ...
    end
    *end of writing to excel file

    for xx=scol to xcol;osheet:columns(xx):autofit();next osheet=oexcel:activesheet();osheet:rows(freezerow):select();oexcel:activewindow:freezepanes=.t.
    oexcel:activeworkbook:saveas(xlsname)
    oexcel:workbooks:open(xlsname)
    oexcel:visible=.t. && [should save & open 'xlsname.xlsx' sorted on 'cF.Y']

    -thanks

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Claudio H@21:1/5 to All on Fri Dec 16 13:51:49 2022
    Here you have a googled vb example, you can easily port to xhb and adapt it to your needs.
    Regards

    Claudio H

    * The following proceedure builds and sorts data in a range in
    * the active worksheet.
    *
    * Visual Basic for Applications
    * Sub SortData()
    *
    * 'Building data to sort on the active sheet.
    * Range("A1").Value = "Name"
    * Range("A2").Value = "Bill"
    * Range("A3").Value = "Rod"
    * Range("A4").Value = "John"
    * Range("A5").Value = "Paddy"
    * Range("A6").Value = "Kelly"
    * Range("A7").Value = "William"
    * Range("A8").Value = "Janet"
    * Range("A9").Value = "Florence"
    * Range("A10").Value = "Albert"
    * Range("A11").Value = "Mary"
    * MsgBox "The list is out of order. Hit Ok to continue..."
    * , vbInformation
    *
    * 'Selecting a cell within the range.
    * Range("A2").Select
    *
    * 'Applying sort.
    * With ActiveWorkbook.Worksheets(ActiveSheet.Name).Sort
    * .SortFields.Clear
    * .SortFields.Add Key:=Range("A2:A11"), _
    * SortOn:=xlSortOnValues, Order:=xlAscending,
    * DataOption:=xlSortNormal
    * .SetRange Range("A1:A11")
    * .Header = xlYes
    * .MatchCase = False
    * .Orientation = xlTopToBottom
    * .SortMethod = xlPinYin
    * .Apply
    * End With
    * MsgBox "Sort complete.", vbInformation

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From timepro timesheet@21:1/5 to All on Mon Jan 23 20:49:13 2023
    -is there a simpler/shorter way to check which record (.dbf) is locked/unlocked.
    currently i lock 'each' record to get the lock status, then unlock it - if lock was successful (after status determined).

    -are rlock & dbrlock similar - locks only the current record. (without unlocking any 'other' record/s that are locked)
    -if similar, which should be preferred in coding.

    -will dbrunlock(recno), unlock just 'that' recno.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Enrico Maria Giordano@21:1/5 to All on Tue Jan 24 09:46:46 2023
    Il 24/01/2023 05:49, timepro timesheet ha scritto:

    -is there a simpler/shorter way to check which record (.dbf) is locked/unlocked.
    currently i lock 'each' record to get the lock status, then unlock it - if lock was successful (after status determined).

    -are rlock & dbrlock similar - locks only the current record. (without unlocking any 'other' record/s that are locked)
    -if similar, which should be preferred in coding.

    -will dbrunlock(recno), unlock just 'that' recno.

    Only if you are using DbRLock():

    DbRLockList()

    --
    Enrico Maria Giordano

    http://www.emagsoftware.it
    http://www.emagsoftware.it/emgmusic
    http://www.emagsoftware.it/spectrum
    http://www.emagsoftware.it/tbosg

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Enrico Maria Giordano@21:1/5 to All on Tue Jan 24 16:01:09 2023
    Il 24/01/2023 15:18, dlzc ha scritto:

    Only if you are using DbRLock():

    DbRLockList()

    This only works if your one executable is the one doing locking. If another process is running, they could have a lock on a record you'd not know about. "Brute force" (or using a server side database engine) is the only way to be sure. And of course
    "Exclusive" open is another way to be sure.

    Yes, you are right. Sorry for the wrong info.

    --
    Enrico Maria Giordano

    http://www.emagsoftware.it
    http://www.emagsoftware.it/emgmusic
    http://www.emagsoftware.it/spectrum
    http://www.emagsoftware.it/tbosg

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From dlzc@21:1/5 to Enrico Maria Giordano on Tue Jan 24 06:18:23 2023
    On Tuesday, January 24, 2023 at 1:46:45 AM UTC-7, Enrico Maria Giordano wrote:
    Il 24/01/2023 05:49, timepro timesheet ha scritto:

    -is there a simpler/shorter way to check which record (.dbf) is locked/unlocked. currently i lock 'each' record to get the lock
    status, then unlock it - if lock was successful (after status
    determined).

    If there are other processes running (not just your one instance of this program), this is the only way to know for sure.

    -are rlock & dbrlock similar - locks only the current record.
    (without unlocking any 'other' record/s that are locked)
    -if similar, which should be preferred in coding.

    -will dbrunlock(recno), unlock just 'that' recno.

    Only if you are using DbRLock():

    DbRLockList()

    This only works if your one executable is the one doing locking. If another process is running, they could have a lock on a record you'd not know about. "Brute force" (or using a server side database engine) is the only way to be sure. And of course "
    Exclusive" open is another way to be sure.

    David A. Smith

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)