Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to customize button export for JS in FineReport

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

How to customize JS button export in FineReport, for this question, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and easy way.

FineReport supports a variety of different export methods, directly use the FineReport built-in export button can be very fast and convenient to various formats of the output, but we in the web page integration, often only want to report content embedded in the iframe, while the toolbar and toolbar buttons will be hidden, and use the web page custom button, then, at this time, this custom button how to achieve export?

As shown in the figure above, create a new html page, define a toolbar and an iframe, define the button shown above in the toolbar, and embed the report in FineReport in iframe, as shown below:

FineReport report Settings

Open the designer and find the template embedded in the web page above. Because you want to use the custom button as the toolbar, the built-in toolbar in the FineReport report does not need to be displayed. Click * * template * *-> * * template web Properties * *-> Page Preview Settings, and remove the check box in front of the toolbar, as shown below:

Custom export button

Nine custom export buttons are defined in the Web page, so how can the export operation be implemented?

The JS API for FineReport export operation is:

Export PDF:exportReportToPDF ()

Export [Excel] (paging): exportReportToExcel ('page')

Export [Excel] (as is): exportReportToExcel ('simple')

Export [Excel] (paging sheet): exportReportToExcel ('sheet')

Export [Excel] (paged export xls format): exportReportToExcel ('page_isExcel2003')

Export [Excel] (export as-is xls format): exportReportToExcel ('page_isExcel2003')

Export [Excel] (paged sheet export xls format): exportReportToExcel ('page_isExcel2003')

Export [picture]: exportReportToImage ('gif') [parameters can be changed in parentheses, such as png,jpg and other image types]

Export [word]: exportReportToWord ()

Therefore, if the click event application of each button calls the above JS API to implement its corresponding export format, such as exporting PDF, then the onclick time of the button is:

Onclick= "document.getElementById ('reportFrame'). ContentWindow.contentPane.exportReportToPDF ()"

Docment.getElementById ('reportFrame') is to get the iframe framework, then get the report window through contentWindow, and get the contentPane report container, and finally you can call various export interface methods from the container.

The export events of the other buttons will not be explained here.

Complete code

Add an export event for the other buttons according to the same method above, and the complete code is as follows:

Effect view

Click on different buttons to see the results of its export:

This is the answer to the question about how to customize the JS button export in FineReport. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report