• Welcome to PlanetSquires Forums.
 

Question on PB

Started by Petrus Vorster, April 07, 2021, 11:26:09 AM

Previous topic - Next topic

Petrus Vorster

Hi gents

I made a little tool for our auditors that extract info from TXT reports from a real lame system.
Works like a charm, and simply finds the correct info and puts it in an Excel sheet.

I figured out how to send TEXT and Currencies/Numeric to the Excel sheet using Paul's Excel.Sll
Marvelous tool still.( Thanks Paul)

Unfortunately, it also needs to send a DATE in such a way that EXCEL will recognize it as a DATE and not TEXT.
The manual formatting in Excel later consumes copious amounts of time that the team don't have.
The reason is that we must sort those sheets in User Names and then DATE order and that wont work unless Excel recognizes the column as a date.

In time I will try and do that sorting in the tool, but for now I just need to know how to pass the DATE correctly to EXCEL.Sll

If someone here is still keeping their PB projects around.

Regards, Peter

-Regards
Peter

Paul Squires

Hi Peter,

I dug out my old code for the excel sll and found the following in my test code file. Looks like I had designed the api so that you can output a date. Take a look at the following (I am copying this directly from my test file):


    'write a date to the file. Dates can be written as literal text strings but doing so will not allow
    'the date to be formatted. The date will be eventually written as a number after conversion to a
    'Julian date number.
    'Write todays date..... Use format #12 mm/dd/yy (you can change the different formats by modifying
    'the code in xlsWriteDefaultFormats. The date is expected to be in the YYYYMMDD format. You can convert
    'from mm-dd-yyyy format to YYYYMMDD by calling the CTOD$ function.
    mDate$ = CTOD$(DATE$)
    stat& = xlsWriteDate(mDate$, 15, 1, %xlsFont1, %xlsLeftAlign, %xlsCellNormal, 12)
   
    mDate$ = "19991128"
    stat& = xlsWriteDate(mDate$, 16, 1, %xlsFont1, %xlsLeftAlign, %xlsCellNormal, 13)

    mDate$ = "20000331"
    stat& = xlsWriteDate(mDate$, 17, 1, %xlsFont1, %xlsLeftAlign, %xlsCellNormal, 14)
   
    mDate$ = "20010630"
    stat& = xlsWriteDate(mDate$, 18, 1, %xlsFont1, %xlsLeftAlign, %xlsCellNormal, 15)

    mDate$ = "19991023"
    stat& = xlsWriteDate(mDate$, 19, 1, %xlsFont1, %xlsLeftAlign, %xlsCellNormal, 20)


Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Petrus Vorster

Thank you for digging up the old Files Paul

If i use those lines, the XLSWRITEDATE gives an Error 516. Deftype, Type ID ....

This is how i currently write to those excel fields:

iCell = ws.AddCell( y&,colz&+1, Val(mydata)) ' For Values
iCell = ws.AddCell( y&,colz&+1, mydata)        ' For text

the Y&, and colz& are cell coordinates.
This is from some of your examples.
If i just change the date to YYYYMMDD it still assumes it's text.

Thanks you for spending time on old stuff for me.

Kind regards.

Peter
-Regards
Peter

Petrus Vorster

Thanks Paul.

It turns out after studying your documents all i had to do was:
Write a date string YYYY-MM-DD
Then use the icell.format(yyyy/MM/dd)

You are indeed a genius.

Regards,

Peter
-Regards
Peter

Paul Squires

Lol,  :-)   Happy that you got it working!

I rarely look at old PB code anymore. I have it all stored in some old directories collecting hard drive dust.
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Petrus Vorster

For me, PB still fulfill the need for making quick little tools that doesn't need to be installed and can be hidden from all kinds of IT policies.
On our vintage work systems that is perfectly fine.

I am also busy with freebasic, but I still have quite some distance to go to get where i am on PB.

Regards, Peter
-Regards
Peter

Jim Dunn

But... when I write those "quick little tools" with PowerBASIC... all the anti-malware alarms go off (the companies I write for use "Cylance") but the SAME code in FreeBasic... NO ALARMS...
3.14159265358979323846264338327950
"Ok, yes... I like pie... um, I meant, pi."

Petrus Vorster

So it does have benefits to still work on ancient systems!
I am certain the hard drive at work a Tutankamen Mk2 with 20gig space.

I think I will be lost at work if, by some miracle of heavens, this retarded company will move past XP and Win7 all on Pentium 4's!
So bye the way gents, I lost my apatite for programming due to the disasterous collapse of the workplace.

Maybe i should try a little of it again with FB.
I know there used to be a link where you could download the entire FB compiler, Paul's designer and al the Libraries.
Please point me in that direction if you can?

Perhaps it can lift my mood.

-Peter
-Regards
Peter


Petrus Vorster

-Regards
Peter