Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ExportXlsx 1.8 and CopyToXlsx 1.9.1 4

Status
Not open for further replies.

vgulielmus

Programmer
Jan 27, 2014
522
RO
Improved versions of class (ExportXlsx 1.8) and procedure (CopyToXlsx 1.9.1) that exports data from VFP into Excel 2007+ workbooks
The links from my blog (first link) contains some explanations

CopyToXlsx 2.9.1
direct link
CopyToXlsx 2.9.1

ExportXlsx 1.8
direct link
ExportXlsx 1.8

Respectfully,
Vilhelm-Ion Praisach
Resita, Romania
 
>Still without a progressbar

It would be easy to add at least an indeterminate marquee progressbar, but that can also be done from outside, is it does not need any callback or progress value:

Code:
PUBLIC oform1

oform1=NEWOBJECT("form1")
oform1.Show
RETURN

DEFINE CLASS form1 AS form
    Top = -2
    Left = 0
    Height = 85
    Width = 360
    ShowWindow = 2
    DoCreate = .T.
    Caption = "Progress Bar"
    Name = "Form1"
    AutoCenter = .T.
    
    ADD OBJECT oleprogress AS olecontrol WITH ;
        Top = 30, ;
        Left = 30, ;
        Height = 25, ;
        Width = 300, ;
        Name = "oleProgress", ;
        OleClass = "COMCTL.ProgCtrl.1"
        
    Add Object Timer1 as Timer WITH;
        Interval=30, ;
        Enabled=.T.
        

    PROCEDURE Init()
        #Define GWL_STYLE -16
        #Define WM_USER 0x0400
        #Define WS_VISIBLE 0x10000000
        #Define WS_CHILD 0x40000000

        #Define PBM_SETRANGE 0x0401
        #Define PBM_SETPOS 0x0402
        #Define PBM_DELTAPOS 0x0403
        #Define PBM_SETSTEP 0x0404
        #Define PBM_STEPIT 0x0405
        #Define PBM_SETRANGE32 0x0406
        #Define PBM_GETRANGE 0x0407
        #Define PBM_GETPOS 0x0408
        #Define PBM_SETBARCOLOR 0x0409
        #Define PBM_SETBKCOLOR 0x2001
        #Define PBM_SETMARQUEE 0x040A
        #Define PBM_GETSTEP 0x040D
        #Define PBM_GETBKCOLOR 0x040E
        #Define PBM_GETBARCOLOR 0x040F
        #Define PBM_SETSTATE 0x0410
        #Define PBM_GETSTATE 0x0411

        #Define PBS_SMOOTH 0x01
        #Define PBS_VERTICAL 0x04
        #Define PBS_MARQUEE 0x08
        #Define PBS_SMOOTHREVERSE 0x10

        #Define PBST_NORMAL 0x0001
        #Define PBST_ERROR 0x0002
        #Define PBST_PAUSED 0x0003

        LOCAL lnStyle, lnReturn, lnState

        Declare Integer SendMessage In user32 Integer, Integer, Integer, Integer
        Declare Integer SetWindowLong In WIN32API Integer, Integer, Integer

        m.lnStyle = Bitor(WS_CHILD, WS_VISIBLE, PBS_MARQUEE)
        SetWindowLong(This.oleProgress.Object.HWnd, GWL_STYLE, m.lnStyle)
        * SendMessage(This.oleProgress.Object.HWnd, PBM_SETMARQUEE, 1, 30) && does not work in Win7
    EndProc
    
    Procedure Timer1.Timer()
        Thisform.oleprogress.Value=0
    ENDPROC
ENDDEFINE
 
Thank you for the progressbar.

There are a few time consuming processes:
1 populating a cursor containing the strings and generate the corresponding XML (to avoid duplicates)
2 creating the main XML (that describe the sheet)
3 compressing all the files

The first mentioned process also can be partial, if the table contains memo fields, because memo are processed when is created the main XML.
And the third process has it's own progressbar.
Maybe the solution is to show the progressbar two times, starting for each step from zero.
If you insist I could add a new parameter for showing a progressbar, because I'm pretty sure it will cost some additional time.

Respectfully,
Vilhelm-Ion Praisach
Resita, Romania

 
>it will cost some additional time.
The main secret to make showing progress fast is not drawing it every iteration.

You know that, you were even much involved in getting my last self made progress bar show smoothly in thread184-1737918
I introduced a lastpaint property there, updated in the paint event and checked in the cls method:
Code:
If Seconds()-Thisform.lastpaint<1/50
   Nodefault
Endif

I often see and also recommend using counter modulus 10 or 100 or 1000. Waiting for a time passed is making it smooth enough and taking less time itself. And it automatically adjusts to computers becoming faster and adjusts at the frame rate for a smooth display. You can also decide to only update once a second or even less in longer running processes. It doesn't always need a 50 frames per second rate.

Rule of thumb is starting a progress display first only after a process already runs for 3 seconds anyway, so every short running process has no bar at all.

Bye, Olaf.
 
>If you insist I could add a new parameter for showing a progressbar, because I'm pretty sure it will cost some additional time.

That sounds good!
 
With the courtesy of Olaf Doschke, finally I made this change.
I apologize for the delay, but I must finish a project this first semester of the year, and I'm a little overwhelmed.

Improvements
- the speed is increased with 0-5% (it depends)
- new parameter llPBar; when .T. a progressbar is displayed (the speed could decrease with about 10%)

I made the changes only to copytoxlsx procedure.
If the feedback is positive, then I will add the same feature to all other exporting procedures / classes.

Respectfully,
Vilhelm-Ion Praisach
Resita, Romania

 
ImportFromXlsx 2.2

Improved effect of "llEmptyCells" parameter
(See test5.prg)

1. Detect the data type of the column from the first non-empty cell of each column
2. Preserve values when a column contains mixed values (don't loose values)
3. Detect columns after the rightmost continue column, from the point of view of the first imported row

Respectfully,
Vilhelm-Ion Praisach
Resita, Romania

 
ImportFromPptx 1.0

Tries to mimic the native Import command
Creates / overwrites a DBF table, with the same name of the pptx
The field type are guessed from the first imported row (depends on lnStartRows, the starting row)

Parameters
[pre]lcFileName name of the pptx
lnSlide slide# ; optional ; default 1
lnStartRows starting row (the first lnStartRows - 1 rows are skipped) ; optional ; default 1 (all rows)
lnTable table# ; optional ; default 1
lcTrue the text representing "true" for boolean fields ; optional default "true"
lcFalse the text representing "false" for boolean fields ; optional default "false"
llCursor when .T., the result is a cursor instead of a DBF ; optional ; default .F.
lnHeader table headers row number; optional ; default 0[/pre]

Alternative link for download

Respectfully,
Vilhelm-Ion Praisach
Resita, Romania

 
ImportFromXlsx 3.1

Bugs fixed:
- when lnHeader > 0 and the number of table header is bigger than the number of follosing rows
- when number of columns > 254

Improvements
- if the sheet starts with other column than A and llEmptyCells = true, now the generated table is without empty columns A,B,...
- Messages in Dutch (thanks to Koen Piller)


Respectfully,
Vilhelm-Ion Praisach
Resita, Romania

 
ImportFromPptx 1.1

Bug fixed
- correct name of the lcFalse parameter

Improvements

- The number of columns is not depending anymore on the firs row (read all cell, no matter how the first row is)
- Process complex tables layout, with merged cells (merged cells are placed in the right columns)
- Letters with accents are correctly imported (apply STRCONV() to strings - suggested by Koen Piller)
- Messages in DUTCH (suggested by Koen Piller)

Download link
ImportFromPptx 1.1

Respectfully,
Vilhelm-Ion Praisach
Resita, Romania

 
ImportFromDocx 3.1

Bug fixed
- correct name of the lcFalse parameter

Improvements
- The number of columns is not depending anymore on the firs row (read all cell, no matter how the first row is)
- Process complex tables layout, with merged cells (merged cells are placed in the right columns)
- Letters with accents are correctly imported (apply STRCONV() to strings - suggested by Koen Piller)
- Messages in DUTCH (suggested by Koen Piller)

Download link
ImportFromDocx 3.1

Respectfully,
Vilhelm-Ion Praisach
Resita, Romania

 
AppendFromDocx 2.1

Bug fixed
- correct name of the lcFalse parameter

Improvements
- The number of columns is not depending anymore on the firs row (read all cell, no matter how the first row is)
- Process complex tables layout, with merged cells (merged cells are placed in the right columns)
- Letters with accents are correctly imported (apply STRCONV() to strings - suggested by Koen Piller)
- Messages in DUTCH (suggested by Koen Piller)

The main difference between Import and Append is that Import creates a new table, while append add records to an opened table

Download link
AppendFromDocx 2.1

Respectfully,
Vilhelm-Ion Praisach
Resita, Romania

 
AppendFromPptx 1.0

First version
With the same possibilities
- The number of columns is not depending on the firs row (read all cell, no matter how the first row is)
- Process complex tables layout, with merged cells (merged cells are placed in the right columns)
- Letters with accents are correctly imported (apply STRCONV() to strings - suggested by Koen Piller)
- Messages in DUTCH (suggested by Koen Piller)

The main difference between Import and Append is that Import creates a new table, while append add records to an opened table

Download link
AppendFromPptx 1.0

Respectfully,
Vilhelm-Ion Praisach
Resita, Romania

 
A class that allows previewing the tables contained in a Word document.

01_ux0yoc.png


Select the desired file (docx document) and browse through its tables
Please read InspectDocx.txt

Download link
InspectDocx 1.0

Respectfully,
Vilhelm-Ion Praisach
Resita, Romania

 
A class that allows previewing the tables contained in a PowerPoint document.

01_v1n4jp.png


Select the desired file (pptx document) and browse through its slides and its tables
Please read InspectPptx.txt

Download link
InspectPptx 1.0


Respectfully,
Vilhelm-Ion Praisach
Resita, Romania

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top