End users design and modify Web reports online

Source: Internet
Author: User

I encountered a new problem in the recently developed human resource management system: the end user must be able to design and edit reports. A basic function in the human resource management system is to edit and print employee work permits. Employees of different positions may have different work permits, the work permits of the same employee in different working periods (such as intern employees and formal employees) may also be different. The project team requires that the operator be able to design and modify the work permit format online (in fact, the Report); otherwise, everything will be free of discussion. The customer is God! Haha, please do it. So we collected all the Web printing software, and the results included the well-known Crystal Reports.
Fortunately, there is no path to perfection. I made a lot of modifications on a FastReport-based Web Printing control previously designed, and finally realized the online design and report editing functions of end users, the user is also satisfied.
The report preview window is as follows:

The online design and editing window for the report end user is as follows:

Of course, the online Report Editing window is a little professional, and the operator needs to be trained to use it. However, we generally help the User Design the template first, and the operator only needs to make some fine-tuning at ordinary times, for example, you can change a word or format. After the report is edited, click it to automatically save the Report to the server and prompt.
The following describes in detail how to use the Web Print control I designed to implement online design and modify reports for end users, and automatically save the reports to the server. Taking ASP. NET as an example, other languages can also be easily implemented. Because the print control is always called using cirpt, the data submitted to the server is Post in the Http protocol, which is common.
Part of the code for the end user to design and modify Web reports online is as follows:

Call the Web Print Control

Protectedvoid BtnDepsitAmtDesignPost_Click (object sender, EventArgs e)
{
String FileValue, PrintValue, ParaName, ParaValue;

FileValue = FileToString (". \ Frp \ DepositAmt. fr3 ");
ParaName = "ShopName '~ Printdepositadd '~ Printpaperno '~ Title ";//'~ It is the separator of each parameter.
ParaValue = "test restaurant"
+ "'~ Note: This document is a credential for your customer's deposit and is stamped effectively. Please present it at check-out. The lost person is at your own risk. Please save it properly. When the check-out time is, the fee is charged for half-day before, and the price for all-day is calculated after. The deposit is valid for one month and expired. For valuables, please submit them to the front-end for storage. Thank you! "
+ "'~ ID: 4325011980639512"
+ "'~ Deposit ticket ";

SqlConnection ConPrintTest = new SqlConnection (ConfigurationManager. ConnectionStrings ["PrintTestConnectionString"]. ToString ());
ConPrintTest. Open ();
DataSet DsCashLog = new DataSet ();
SqlDataAdapter DaCashLog = new SqlDataAdapter ("Select top 1 CashNo, CashDate, CashAmt, PayName, GuestName, RoomNo, ItemRemark, CashUserName, Remark From CashLog", ConPrintTest );
DaCashLog. FillSchema (DsCashLog, SchemaType. Source, "CashLog ");
DaCashLog. Fill (DsCashLog, "CashLog ");

PrintValue = TableToXml (DsCashLog. Tables ["CashLog"]);

DsCashLog. Dispose ();
ConPrintTest. Close ();

String ScriptStr;

ScriptStr = "<script language = 'javascript '> window. onload = function () {try {var ObjPrintMange = new ActiveXObject ('webprint. webPrintUnit ');} catch (e) {if (confirm ('print control is not installed. Do you want to download it now? ') {Window. location = '. /PrintActivex.exe ';} return;} var OldVersion = ObjPrintMange. version; NewVerion = '3. 5 () '; if (OldVersion <NewVerion) {ObjPrintMange = null; alert ('print controls need to be upgraded. Download it first, Disable IE, and install the upgraded version. '); Window. location ='./PrintActivex.exe '; return ;}"
+ "ObjPrintMange. CheckReg ('Company name', '3b8e5b998a3125ee89983ea940bb2aee ');" // registration code
+ "ObjPrintMange. ReportFileName = 'destotamt. fr3 ';"
+ "ObjPrintMange. PostURL = 'HTTP: // www.xinyuerj.com/ASPPost/Show.asp? FileName = DepsitAmt. fr3 ';"
+ "ObjPrintMange. DesignReport ('"
+ FileValue + "','"
+ ParaName + "','"
+ ParaValue + "','"
+ PrintValue + "','','','','','');"
+ "ObjPrintMange = null ;}</script> ";
ScriptStr = ScriptStr. Replace (System. Environment. NewLine, string. Empty );

Response. Write (ScriptStr );

}

The PostURL attribute is added to the report control. To set this attribute, click the Save button or save menu item when the report is edited online, the report content is organized as String and submitted directly to the configured URL page through Http Post. You can receive the report content in the URL, save the report content in a specified file or database. The field name of Post is specified as ReportFileValue. You can save the online edited report content by receiving the value of this field. The report content is String. You can directly call this content when printing or previewing the report. You do not need to use the FileToStr function for conversion.
The DesignReport function of the report control. It supports online Report Editing. parameters: report file string, report parameter name string, report parameter value string, Dataset 1 string, and Dataset 2 string, the string of dataset 3, the string of dataset 4, the string of dataset 5, and the string of dataset 6. The report file string is generated by calling the FileToStr function. The report parameter name string is the name of the parameters used in the report '~ The report parameter value string is the value corresponding to the parameters used in the report '~ Separated; the dataset string is generated by calling the FileToStr function. It is null if no data exists.
The page design of the server that receives Http Post data is as follows:

Receive submitted report content

Publicpartialclass Show: System. Web. UI. Page
{
Protectedvoid Page_Load (object sender, EventArgs e)
{
String FileName, FileValue;

FileName = Request. QueryString ["FileName"];
FileValue = Request. Form ["ReportFileValue"];

WriteReportFile (FileName, FileValue );

Response. Write ("File Name" + FileName );
Response. Write ("File Value" + FileValue );
}

Privatevoid WriteReportFile (string FileName, string FileValue)
{
If (FileName = null | FileName = "" | FileValue = null | FileValue = "")
Return;

File. WriteAllText (Server. MapPath (FileName), FileValue );
}
}

FileName is the name of the saved report file set in PostURL, and ReportFileValue is the content of the report file.
If your project also requires end users to design and modify reports online, the Web Print control I designed is a quick and convenient solution. The Web Print control can be applied for free registration by individuals currently. If you have any questions, please join the QQ group: 218392762 (group 1: 135506194, group 2: 150850837 is full. Please join the three groups) alternatively, directly ask me: 12988672.

Reports preview, edit, and download URL: http://www.xinyuerj.com/ASP/
Http://www.xinyuerj.com/ASP.NET/

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.