The crystal report text cannot be aligned on both ends on the web.

Source: Internet
Author: User
A piece of text is displayed in a crystal Report on the web, and the RPT is dynamically loaded. The result is as follows:

The right side is not neat, so return to the Crystal Report 10 Program In RPT, the text Alignment Method is set to the two ends of alignment, and the effect is very good, just like word. Save, re-compile, and display. The results have changed, but the changes are not large, but they are still not consistent.
Next, try to directly import the RPT, and the result shows that the two ends cannot be set to alignment, -- there is no alignment at all, in. NET environment, even if the two sides of the aligned button to add the toolbar, it is also gray.
As a result, I plan to control the alignment of the text field in the program mode before assigning the reportdocument object to the report object during dynamic loading. The results showed that it was not really difficult. The blind trial did not produce any results, and Zhang Limin's "Learning Crystal Report with instances" was still useless. It is difficult to get the reference of the field. Finally, I finally got it done. I also had a little bit of further understanding about the CR object structure:
The main namespace of the crystal report in. NET is crystaldecisions. crystalreports. engine, and crystaldecisions. shared.
One of the main members of reportdocument is the tables set, which is the set of tables related to the report. You can find fields and the number of times each field is referenced. This is useless for me. I just want to control fields that have already been added to the report.
Another member of reportdocument, datadefinition, looks very similar, but its members have nothing, that is, there is no field object.
Finally, it is still in the namespace crystaldecisions. crystalreports. the following figure shows fieldobject in the engine. A report is composed of a lot of reportobject, and fieldobject is derived from it. To obtain reportobject, you must use reportdocument. reportdefinition. reportobjects [fieldname] To obtain the reference, and then forcibly convert it to fieldobject.
However, the problem is that fieldname is not an expression like "t1.a1", but "A11". It can be used to cope with multiple references. The following are some things we can see during debugging.

Finally, you can control the field. Try again.ReportDocument Rd = New ReportDocument ();
Rd. Load ( This . Server. mappath ( " \ RPT " ) + " \ Document. rpt " );
Rd. setdatasource (xmlpage. getdataset (session [ " Gw_gwxml " ]. Tostring (), " Flowdata " ));
Fieldobject Field = (Fieldobject) RD. reportdefinition. reportobjects [ " A51 " ];
Field. objectformat. horizontalalignment = Crystaldecisions. Shared. Alignment. leftalign;
Session [ " Gw_rd " ] = Rd;
Cr1.reportsource = Rd;

The result shows that the left and right alignment settings are good, but the two sides are the same as the original ones. The problem lies not in the report, but in the limitation of the webpage display mode. You can view the displayed webpage in the alignment mode of both ends:

Originally, it only used CSS to align the two ends. This alignment method cannot produce perfect results. At least it cannot be achieved by local applications such as Word or report system. Find some solutions online, such
Bytes.

Luo luochao, it is a pity that it took me a long time to spend this thing.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.