ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Crystal Reports to XML

Crystal Reports to XML

原创 Linux操作系统 作者:taimoslong 时间:2012-08-10 14:07:39 0 删除 编辑

blog034006

The simple handler here is that if the value for Country is null, still create the opening and closing tags for the element.

Next, consider the effect of using a numeric value in the XML.

blog034007

If Revenue is null, display 0. Also, when displayed, we can set the decimal places to 0 and ensure that no separator is placed within the XML (that’s important). If it has a comma in the output, the XML data may be identified as a string value instead of numeric later.

These illustrations are just two examples of the many complexities and business rules you can enforce in the formulas prior to actually rendering this information within the XML itself.

Create the XML body
blog034005With all of our formulas in place, the best way to construct the body of the result is to use a text object in the report body. In the detail section, add a text object and with the appropriate number of spaces in front of each variable, and insert as shown here.

Note that the container element in this case is child_element. This element should open and close each detail record in the output.

Close the report out with a footer that matches the opening parent tags at the top and you’ve created some well-formed XML.

Last bits

  1. Text can grow dynamically, obviously. Set the width of the text object cell here in the Details section to be 100% of the width of the available page.
  2. Right click on the text object in the details and choose “Format Text”. Ensure that the “Can Grow” property is set and set to 0 (no limit). This will ensure that no matter how many rows of detail data you see, you get them in your XML output.
  3. When finished, Export as Text (not as XML!) and set the “Number of Lines per Page” property to 0. XML is a continuous file format and should not have page breaks. Save the output file with a .xml extension, even though the Save As dialog box indicates “Paginated Text (*.txt)”.
  4. Be prepared to deal with invalid XML characters, such as “&”. Converting them to XML friendly values will avoid future headaches in your finished XML. Simple formulas will help to account for this.


Conclusion
XML is an extremely powerful way to share data. In this illustration, root_element and parent_element don’t really mean anything. However, these could have been replaced with groups on the Country and Resort to further enforce the hierarchy of the XML data.

Using Crystal Reports is a great way to rapidly create XML structures and automate the publication of this XML via the Business Objects platform.

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/24260552/viewspace-740640/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: webi function
请登录后发表评论 登录
全部评论

注册时间:2012-08-10

  • 博文量
    11
  • 访问量
    7467