Faceți căutări pe acest blog

sâmbătă, 22 august 2015

ImportFromXlsx 1.1

All my post are free of charge, I've offered my work to the community as a way to thank for everything I have learned over the years. 

Recently I have blocked all comments, because of a spammer, who flooded my posts with dubious links (werbung).
I've deleted all his comments, also.

Now someone reported this post and it was blocked because it violated the spam policy (?!), so I have removed the 1.1 version of importfromxlsx and replaced it with version 4.0

If the malevolent user continues his actions and Google continues to punish me, I regretfully inform you that I will close this blog.
My time is precious and I have neither the will, nor the time to do this kind of fight.


The new version for Import from xlsx

1) Improved data type detection
2) By default is imported the first sheet, no matter which name has
3) Sheet can be passed by name (string), or by position (number)
4) Strings detection improved

ImportFromXlsx 4.0 (version 1.1 is no longer available)

Related posts
http://praisachion.blogspot.com/2016/06/inspectpptx-10.html
http://praisachion.blogspot.com/2016/06/inspectdocx-10.html

MSOffice -> DBF
http://praisachion.blogspot.com/2017/08/importfromxlsx-40.html
http://praisachion.blogspot.com/2017/06/append-from-xlsx-30.html
http://praisachion.blogspot.com/2016/08/importfromxlsx-34.html
http://praisachion.blogspot.com/2016/08/importfromxlsx-33.html
http://praisachion.blogspot.com/2016/06/importfromxlsx-32-appendfromxlsx-21.html
http://praisachion.blogspot.com/2016/06/appendfrompptx-10.html
http://praisachion.blogspot.com/2016/06/appendfromdocx-21.html
http://praisachion.blogspot.com/2016/06/importfromdocx-31.html
http://praisachion.blogspot.com/2016/06/importfrompptx-11.html
http://praisachion.blogspot.com/2016/06/importfromxlsx-31.html
http://praisachion.blogspot.com/2016/06/importfrompptx-10.html
http://praisachion.blogspot.com/2016/06/importfromdocx-30.html
http://praisachion.blogspot.com/2016/05/importfromxlsx-22.html
http://praisachion.blogspot.com/2016/02/import-dbf-from-msoffice-2007-xlsx-docx.html
http://praisachion.blogspot.com/2016/01/importfromdocx-20.html
http://praisachion.blogspot.com/2016/01/appendfromdocx-20.html
http://praisachion.blogspot.com/2016/01/importfromxlsx-13.html
http://praisachion.blogspot.com/2016/01/appendfromxlsx-20.html
http://praisachion.blogspot.com/2015/12/appendfromxlsx-15.html
http://praisachion.blogspot.com/2015/11/importfromxlsx-13.html
http://praisachion.blogspot.com/2015/09/importfromxlsx-12.html
http://praisachion.blogspot.com/2015/09/appendfromxlsx-14.html
http://praisachion.blogspot.com/2015/09/appendfromnxlsx-13.html
http://praisachion.blogspot.com/2015/08/importfromxlsx-11.html
http://praisachion.blogspot.com/2015/07/import-from-xlsx.html
http://praisachion.blogspot.com/2015/07/insert-from-focx.html
http://praisachion.blogspot.com/2015/06/append-from-docx.html

DBF -> MSOffice
Dbf2Xlsx6 4.2 (VFP6) 
http://praisachion.blogspot.com/2017/04/export-dbf-to-excel-2007.html
http://praisachion.blogspot.com/2017/01/export-dbf-to-msexcel-xlsx.html
http://praisachion.blogspot.com/2017/01/export-dbf-to-mspowerpoin-pptx.html
http://praisachion.blogspot.com/2017/01/export-dbf-to-msword-docx.html
http://praisachion.blogspot.com/2016/11/export-to-xlsx.html
http://praisachion.blogspot.com/2016/11/export-to-pptx.html
http://praisachion.blogspot.com/2016/11/export-to-docx.html
http://praisachion.blogspot.com/2016/11/export-from-vfp6-to-msoffice-docx-pptx.html
http://praisachion.blogspot.com/2016/09/copytoxlsx6-10.html
http://praisachion.blogspot.com/2016/01/export-dbf-to-msoffice-2007-xlsx-docx_24.html
http://praisachion.blogspot.com/2016/01/export-dbf-to-msoffice-2007-xlsx-docx.html
http://praisachion.blogspot.com/2016/01/exporttopptx-20.html
http://praisachion.blogspot.com/2016/01/exporttodocx-20.html
http://praisachion.blogspot.com/2016/01/copytopptx-20.html
http://praisachion.blogspot.com/2016/01/exporttoxlsx-20.html
http://praisachion.blogspot.com/2016/01/copytoxlsx-30.html
http://praisachion.blogspot.com/2015/12/exporttoxlsx-19-class.html
http://praisachion.blogspot.com/2015/12/copytoxlsx-210-procedure.html
http://praisachion.blogspot.com/2015/12/exporttoxlsx-18-class.html
http://praisachion.blogspot.com/2015/12/copytoxlsx-29.html
http://praisachion.blogspot.com/2015/02/export-pptx-13.html
http://praisachion.blogspot.com/2015/01/copytodocx-12.html
http://praisachion.blogspot.com/2015/01/exportdocx-1.html

OOffice -> DBF
http://praisachion.blogspot.com/2016/11/import-from-openoffice-libreoffice-for.html
http://praisachion.blogspot.com/2016/09/importfromoowrtext-10.html
http://praisachion.blogspot.com/2016/09/importfromooffice-1o.html
http://praisachion.blogspot.com/2016/08/importfromoocalc.html

DBF -> OOffice
http://praisachion.blogspot.com/2016/09/export-dbf-to-openoffice-libreoffice_52.html
http://praisachion.blogspot.com/2016/09/export-dbf-to-openoffice-libreoffice_16.html
http://praisachion.blogspot.com/2016/09/copy-to-ods-10-openoffice-calc.html
http://praisachion.blogspot.com/2016/09/export-dbf-to-openoffice-libreoffice.html
http://praisachion.blogspot.com/2016/09/copy-to-odt-10.html

miercuri, 19 august 2015

Changing the color of grid's HighlightRowLine

The selected row of a Grid is emphasized with a border around it.
The thickness can be controlled with the grid's HighlightRowLineWidth property.
But there is no HighlightRowLineColor property, and this color is given by the OS's "Selected Items" color.

In Windows 7 can be accessed this way :
Control Panel -> Personalization -> Window Color -> Selected Items (chosen from the combobox)
In Windows 10, I haven't found yet where it can be (I suppose lies in some registry key).

But a small VFP code can help you :
************
* Begin Code

************
Declare integer SetSysColors in user32 integer, string, string
lnNewColor = 255
setsyscolors(1,BINTOC(13,'4RS'),BINTOC(m.lnNewColor,'4RS')) && 1 means a single color would be changed; 13 is the numeric code for Selected Item

************
* End Code
************

Here is a more complete code
************
* Begin Code
************
Declare integer GetSysColor in user32 integer
Declare integer SetSysColors in user32 integer, string, string
LOCAL lnNewColor,lnOldColor
lnOldColor = GetSysColor(13) && store the old color
lnNewColor = 255
setsyscolors(1,BINTOC(13,'4RS'),BINTOC(m.lnNewColor,'4RS')) && set new color
DO FORM MyFormContainingTheGrid && verify the grid
setsyscolors(1,BINTOC(13,'4RS'),BINTOC(m.lnOldColor,'4RS')) && restore the old color

************
* End Code
************

GetSysColor
SetSysColor
Another VFP example for GetSysColor and SetSysColor

marți, 18 august 2015

Using Videolan (VLC) ActiveX to play stream media (2)

VLC media player offers two ActiveX.
The second version, is the recommended one, and is more powerful and flexible, yet is still very easy to be used.

Here is the same problem, solved with the second ActiveX.
In addition, by pressing SPACE the song is toggled between pause and play.

*************
* Begin code
*************
PUBLIC oform
oform=CREATEOBJECT("myform")
oform.Show

DEFINE CLASS myform AS form
    Height = 600
    Width = 850
    keypreview = .T. && to allow to your form to intercept the keyboard activity
    ADD OBJECT cmd as commandbutton WITH autosize = .T., caption = 'Click and Play'
    ADD OBJECT vlc AS olecontrol WITH top = 50, Height = 600, Width = 800, OleClass = "VideoLAN.VLCPlugin.2"
    PROCEDURE cmd.Click
        lnId = ThisForm.vlc.OBJECT.playlist.add("https://www.youtube.com/watch?v=-1lj0mZDrIw")
        ThisForm.vlc.OBJECT.playlist.play()

        ThisForm.vlc.SetFocus()
    ENDPROC
    PROCEDURE keypress
        LPARAMETERS nkey,nshift
        IF nkey = 32 && when SPACE is pressed
            This.vlc.OBJECT.playlist.togglePause && toggles between pause and play
        ENDIF
    ENDPROC
ENDDEFINE
*************
* End code
*************


https://wiki.videolan.org/Documentation:WebPlugin/

Related posts
http://praisachion.blogspot.com/2015/08/using-videolan-vlc-activex-to-play_18.html
http://praisachion.blogspot.com/2015/08/using-videolan-vlc-activex-to-play.html

Using Videolan (VLC) ActiveX to play stream media

It's enough to use two methods :
- addTarget
- play

addTarget has 4 parameters.
- uri as String
- options as String
- mode as VLCPlayListMod
- Position as Long

First parameters contains the URL, second can be Null (see the third link below for more details), third can be 8 (see the second link below for more details), and fourth can be 0
See the first link below for more details.

Here is the code
*************
* Begin code
*************
PUBLIC oform
oform=CREATEOBJECT("myform")
oform.Show

DEFINE CLASS myform AS form
    Height = 600
    Width = 850
    ADD OBJECT cmd as commandbutton WITH autosize = .T., caption = 'Click and Play'
    ADD OBJECT vlc AS olecontrol WITH top = 50, Height = 600, Width = 800, OleClass = "VideoLAN.VLCPlugin.1"
    PROCEDURE cmd.Click
        ThisForm.vlc.OBJECT.addTarget("https://www.youtube.com/watch?v=-1lj0mZDrIw",,8,0)
        ThisForm.vlc.oBJECT.play()
    ENDPROC
ENDDEFINE

*************
* End code
*************

https://wiki.videolan.org/ActiveX/
https://wiki.videolan.org/VLCPlaylistMode/
https://wiki.videolan.org/VLC_command-line_help

VLC media player is a free and open source utility. Reliable and has no need for decoders.
http://www.videolan.org/ 

Related posts
http://praisachion.blogspot.com/2015/08/using-videolan-vlc-activex-to-play_18.html
http://praisachion.blogspot.com/2015/08/using-videolan-vlc-activex-to-play.html

luni, 3 august 2015

Using Automation to create Equations in Word

Starting with MS Word 2007, a new type of equations can be embeded.
This new type came from Latex. Latex syntax can be used, and is autocorrected by Word, by replacing Latex keywords into Unicode special characters.
Also, the graphic interface can be used to generate these new kind of equations.

But these new type of equations can be easy created using automation.
The steps
1 Create the Unicode string
2 Add the range to the oMaths object
3 Create the oMath object
4 Convert the equation to the professional format (BuildUp the equation)
Steps 2-4 are the similar for every equation

The Unicode chars can be passed to Word as a blob constant, or using the range.insertsymbol() method.
For example, the product symbol can be inserted in Word in two ways :
orange.insertsymbol(0x220F,,.T.)
or as a blob constant
orange.insertafter(0h0F22)
(note the reversed order of the two bytes)

Examples 
1) Here is a first and very simple sample (a fraction)
owrd=CREATEOBJECT("Word.Application")
odoc=owrd.documents.add()
owrd.visible=.T.
orange=odoc.range()

* fraction
orange.Move (6)  && ctrl+end

* 1 the string
orange.text="(1.4+3)/23"+CHR(13)
* 2 Add the range to the oMath object
objRange2 = orange.OMaths.Add(orange)
* 3 create the oMath object
objEq = objRange2.OMaths(1)
* 4 Convert the equation to the professional format
objEq.BuildUp


2) The next example is almost identical. The only difference is the first step (* 1 the string)
Permutation (simple)
Permutations are delimited by brackets. The row separator is ¦ chr(166)
owrd=CREATEOBJECT("Word.Application")
odoc=owrd.documents.add()
owrd.visible=.T.
orange=odoc.range()

orange.Move (6)  && ctrl+end

* 1 the string
orange.text="(n¦k)"+CHR(13)  &&&&&&& this is the difference &&&&
* 2 Add the range to the oMath object
objRange2 = orange.OMaths.Add(orange)
* 3 create the oMath object
objEq = objRange2.OMaths(1)
* 4 Convert the equation to the professional format
objEq.BuildUp


3) For a more complex permutation, the expressions from the upper / lower row are enclosed by brackets
The only difference is contained in this row
orange.text="((n+1)¦(k+1))"+CHR(13)

 4) Superscript
The character for superscript is ^
If needed, the expressions from the base and from the superscript row are enclosed by brackets
orange.text="(x+1)^(y+2)"+CHR(13)

 5) Subscript
The character for subscript is _ (underscore)
orange.text="x_1"+CHR(13) 

 6) Square root
The symbol for square root is Unicode 8730 (0x221A)
 * 1 the string
orange.Move (6)  && ctrl+end
orange0=odoc.range(orange.start,orange.start)
orange.insertsymbol(8730,,.T.) && radical
orange.Move (6)  && ctrl+end
orange.insertafter("(x^(2^3)+y^2)"+CHR(13)) && superscript is ^
* 2 Add the range to the oMath object
* etc.


 7) Radical of order n
 Is similar with square root. First is placed Unicode 8730 (0x221A), second the order of the radical then an ampersand (&) and finally the expression
* 1 the string
orange.Move (6)  && ctrl+end
orange0=odoc.range(orange.start,orange.start)
orange.insertsymbol(8730,,.T.) && radical
orange.Move (6)  && ctrl+end
orange.text="(n&u)"+CHR(13) && n is the order of the radical, u is the expression under radical
* 2 Add the range to the oMath object
* etc.


8) Sum, product, integral, reunion, intersection, or, and
First is placed the Unicode character specific for each function. (*)
Then is placed Unicode character 9618 (0x2592) (the placeholder for the expression affected by the function)
If a lower bound is present, is added like any subscript (_expression)
If a upper bound is present, is added like any superscript (^expression)
Finally the general term
* Characters
- product 0x220F
- product overturned 0x2210
- sum 0x2211
- and 0x22C0
- or 0x22C1
- intersection 0x22C2
- reunion 0x22C3
- integral 0x222B
- double integral 0x222C
- tripple 0x222D
- line integral 0x222E
- double line integral 0x222F
- tripple line integral 0x2230
Example for sum
* 1 the string
orange.Move (6)  && ctrl+end
orange0=odoc.range(orange.start,orange.start)
orange.insertsymbol(8721,,.T.) && sum
orange.Move (6)  && ctrl+end
orange.insertafter("_(i=1)^n ") && _ lower bound (like subscript) ^upper bound (like superscript)
orange.Move (6)  && ctrl+end
orange.insertsymbol(9618,,.T.) && placeholder
orange.Move (6)  && ctrl+end
orange.insertafter("i=n(n+1)/2"+CHR(13)) && terms (what is summed)
* 2 Add the range to the oMath object
* etc.


9) Matrix
Symbol for matrix is Unicode 9632 (0x25A0) followed by an open brackets
Column break is &
Row break is @
Finally is the closed brackets
The whole matrix can be enclosed by different types of brackets
Example Matrix enclosed by square brackets
* 1 the string
orange.Move (6)  && ctrl+end
orange0=odoc.range(orange.start,orange.start)
orange.insertafter("[")
orange.Move (6)  && ctrl+end
orange.insertsymbol(9632,,.T.) && simbol for matrix
orange.Move (6)  && ctrl+end
orange.insertafter("(1 & 2 & 3 @ 4 & 5 & 6)]"+CHR(13))
* 2 Add the range to the oMath object
* etc.


Here is a list with many Unicode characters used