SaveAsHTML / XML to .Net

ECEC Member Posts: 56
Hi.

Is there any way to send a report either as HTML or XML to a .net app?

Preferably wihtout writing the report to a file and afterwards sending that file.

Otherwise any suggestions are welcome.

/EC

Comments

  • krikikriki Member, Moderator Posts: 9,118
    You can run the report with preview and then save as HTML. Problem is that the layout goes completely wrong.
    The better solution would be to write an XML-port (in 4.00+) or use the XML-codeunits to create an XML-file (pre 4.00).

    with XML-port, you can stream the data directly in a .NET app. (actually a DLL that bridges between Navision and the .NET app. For more info about using .NET in Navision, search the forum, there is a lot about it)
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • ECEC Member Posts: 56
    Hi.

    I have created an XMLPort. But I don't know how to design it as it will probably only have one element that contains the HTML. But if I save a report to a file and then creates an instream from that file and then sets the xmlports source to that instream, the xmlport is returned but it is empty.
  • krikikriki Member, Moderator Posts: 9,118
    Lets go step by step (I am not a specialist with XML-ports and neither with .NET):

    1) create the XML-port.
    2) in another object (form,codeunit,...) you should make a variable of the XML-port and also make an export-stream and run the XML-port from there (look in the manual or the forum for an example on how to do it). XML-ports cannot be run stand-alone like dataports.
    3) now you have a file, and you should stream it into .NET. So probably you will have to write a DLL that reads the file and streams it into the .NET app. For this you need to know how to write DLL's. I am afraid I cannot help you with that.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • ECEC Member Posts: 56
    Hi again.

    And thanks for the help.

    The communication between Navision and .net is no problem. I've got that implemented and tested.

    My problem is that I've an xmlport with one element of type text (bigText). I then create an instream from the file the report is saved as and sets the xmlport's source to this instream. I thought that this would write the instream (that is the HTML) to the text element of the xmlport. But this just doesn't happen and I don't know how to map the content of the file to the xmlport.
  • krikikriki Member, Moderator Posts: 9,118
    A few things to clarify
    -Your report (saved as HTML) created HTML and an XML-port needs an XML-file
    -Anyway, you would need a codeunit (or other object) with an INSTREAM to read the data from the file and then an OUTSTREAM to write the data to .NET.

    -I also think that you can't use a report to generate the file, but you need to put code in the XML-port to create the records (=lines on the report). Then let the XML-port read the temptable and write the info to the OUTstream.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • ECEC Member Posts: 56
    I just thought I could read a file (HTML, TXT, whatever) and map that file to an element in the xmlport. But I guess that isn't possible.

    Any other way to "export" a report to .Net? (btw. the communication between Navision and .Net is NO problem, so that's not what I'm asking)!

    I kindda hoped there would be some easy way to do it instead of reading throught temptables and creating the HTML by hand/programmatically.
  • DenSterDenSter Member Posts: 8,307
    I think all you need to do is translate the stream into a bigtext and set the xml element's value to it. I don't know if an XMLPort likes bigtexts though.
  • ECEC Member Posts: 56
    Hi. Thanks for all the replies.

    I finally got it to work. I just saved the report to a file and then in the XMLport checked if the file was created and if it was I read the file's instream to the xmlport. It worked.

    /EC
  • DenSterDenSter Member Posts: 8,307
    Would you be willing to share the code with us?
Sign In or Register to comment.