Using Xml To Create Excel File

PrJlndni

Member
Hi Osborne,

The following are the samples I've been using to get the result.
 

Attachments

  • xmlSpreadDemoMulti1.p
    7.1 KB · Views: 6
  • xmlSpreadMultiSheet.p
    36.1 KB · Views: 6

Osborne

Active Member
Two problems:
1) You are not copying the data from the static temp-table to the dynamic temp-temp table.
2) You are assigning the wrong handle to thand.

For PROCEDURE getColumnsToPrint, the BUFFER-CREATE, BUFFER-COPY and thand = needs to be:
Code:
CREATE TEMP-TABLE tth.
IF tb_testdate  = TRUE THEN DO:
    tth:ADD-NEW-FIELD("testdate","date").
END.
IF tb_testchar  = TRUE THEN do:
    tth:ADD-NEW-FIELD("testchar","CHARACTER").
END.
tth:TEMP-TABLE-PREPARE("tthh").
bh = tth:DEFAULT-BUFFER-HANDLE.

FOR EACH foo:
    bh:BUFFER-CREATE().
    bh:BUFFER-COPY(BUFFER foo:HANDLE).
END.

thand = tth.
 

joey.jeremiah

ProgressTalk Moderator
Staff member
Last edited:

PrJlndni

Member
Hi Masters,

@Osborne: Sir, thank you. It worked. I have this last problem tho. Do you know how to change the column-labels of the added fields?

@HTH: Thank you Sir. I will definitely download and read it.
 

PrJlndni

Member
This is already solved. Thank you very much Masters.
I already found out the answer using this:

tth:ADD-NEW-FIELD("t_ItemNo","character",0,"","","","ITEM NO").
 

Abbashatim

New Member
Hello PrJIndni

I am not able to help you, but I tried what you did.
When I tried to run the procedure I get following error

upload_2015-11-18_17-31-23.png

Is there any way you can help me.
I want to do the same thing as what you are doing.
Thanks
abbas
 

PrJlndni

Member
Good day Abbashatim,

Can you attached the procedures that you are using? So that I can see where's the problem. Thank you.


-Pr
 

Abbashatim

New Member
Hi PrJIndni
attached is the file.
I have inserted message statements to know where the procedure fails.
It fails at the save statement.

Thanks
abbas
 

Attachments

  • create-xml-test.p
    2.3 KB · Views: 5

PrJlndni

Member
Abbas,

You should call the class procedure (xmlSpreadMultiSheet.p) that I uploaded above to create the xml file.


-Pr
 

Abbashatim

New Member
Hi PJ

Thank You for your reply.
I have called xmlspreadmultisheet.p instead of xmlspredsheet.p as advised by you.
It does not give any error. there are 2 files created now
as attached.

xmlspread.xml
11117

the file xmlspread.xml has only one line
the file 11117 is the correct file xmlfile. But the extension .xml is missing.
the file-name as a numeric and random. I do not have control over it.
If I run another time it gives another numeric number.



As I cannot upload files xmlspread.xml and 11117 (Extensions not allowed to be posted)
I have renamed both files as xmlspread.txt and 11117.txt

Where am I going wrong? Can you please help.
I would like to have control over the output file name.

Thanks
abbas
 

Attachments

  • create-xml-test.p
    2.5 KB · Views: 5
  • xmlspread.txt
    24 bytes · Views: 4
  • 11117.txt
    14.4 KB · Views: 5

PrJlndni

Member
Dear Abbas,

I think you missed the procedure that transfers your database info to create an xml. Try this one:

Code:
 DEFINE VARIABLE pHand AS HANDLE.
  DEFINE VARIABLE thand AS HANDLE.
  DEFINE VARIABLE hRows AS HANDLE.
  DEFINE VARIABLE tth  AS HANDLE NO-UNDO.
  DEFINE VARIABLE bh  AS HANDLE NO-UNDO.

 CREATE TEMP-TABLE tth.
    tth:ADD-NEW-FIELD("t_ItemNo","integer").
    tth:ADD-NEW-FIELD("t_InvID","CHARACTER").
    tth:TEMP-TABLE-PREPARE("tthh").
    bh = tth:DEFAULT-BUFFER-HANDLE.

FOR EACH foo:
    bh:BUFFER-CREATE().
    bh:BUFFER-COPY(BUFFER foo:HANDLE).
END.

thand = tth.

RUN xmlspreadmultisheet.p PERSISTENT SET pHand.   

  RUN StartDocument IN pHand (
  "c:\temp\test.xml"). /*where the xml file is located after it was created*/

  RUN makeSheet IN pHand (
  TABLE-HANDLE thand BY-REFERENCE, /* handle to temp-table */
  TRUE,  /* Include a header? */
  "MySheet")  .  /* The name of the worksheet */
   
  RUN endDocument IN pHand.   
   
  DELETE PROCEDURE pHand.
  pHand = ?.


-Pr
 
Top