Successfully!

Error!

You are viewing 10.0 help doc. More details are displayed in the latest help doc

Upload and Download Files Plugin

I. Overview

1. Application Scenario

Sometimes users need to upload files to the server or FTP for saving, and file downloads can be provided. In the past, the implementation of this function in FineReport required custom function implementation, but the code implementation would be more troublesome. This plugin encapsulates this function, and it can be operated through a visual interface after installation, which is convenient and fast.


2. Functional limitations

  • When uploading multiple files in the same file widget, custom file names are not supported and will be displayed overlapping

  • The file download rename function does not support reading extended cell values

  • The file download path does not support dynamic calculation formulas

  • File download does not support "Dashboard"

  • Deleting files is not supported

  • Cluster environment is not supported

  • The mobile terminal only supports uploading files of image type, and does not support uploading other files and downloading functions

Note: If the actual scene is affected by the above functional limitations, you can consider using the file upload and download plugin of the Enjoy version, which has more functions and covered scenes.

II. Plugin introduction

1. Plugin installation

Please click to download the plugin: 

Upload and download files.zip

For the installation method of the designer plugin, refer to the designer plugin management

For the method of installing plugins on the server, please refer to Server Plugin Management


2. Plugin function

1) Upload to servere

In the report data entry attributes interface, the upload type selection has been added to the custom submit, and Upload to server can be selected.

Overwrite if name duplicates: Unchecked by default. When unchecked, the file with the same name will be renamed automatically; if checked, the file with the same name will be directly overwritten.

1.png

2) Upload to FTP

In the report data entry attribute interface, the upload type selection is added in the custom submit, and FTP Uploadcan be selected.

Overwrite if name duplicates: Unchecked by default. When unchecked, the file with the same name will be renamed automatically; if checked, the file with the same name will be directly overwritten.

2.png

3) File Download

A new option File Download has been added to the hyperlink. You can download a file from the server by setting a hyperlink, as shown in the following figure:

3.png


3. Setting item format

Setting itemContentExample
Upload path/file path

formula, fixed value

  • A1

  • "D:/photo"(windows)

  • "/data/tomcat/"(linux)

  • "ftp://192.168.1.201/"(FTP)

Fileformula
  • A1

File nameempty, formula, fixed value
  • A1

  • "test2"

  • Empty (the filename will be automatically obtained when empty)

Renameempty, formula, fixed value
  • A1

  • "test2"

  • Empty

Note 1: If the file name is empty, the uploaded file name will be obtained by default, and multiple file uploads are supported. If not empty, multi-file upload is not supported, and the file names will overlap.

Note 2: The download rename function does not support reading extended cell values. The file download path does not support dynamic calculation formulas.

III. Example

1. Report Design

1) Click File > New General Report in the FineReport Designer.

2) Select cell A1, add File Widget for cell A1, and select All Files for the file type. As shown below:

4.png


2. Upload to server

1) Click Template > Data Entry Attribute in the menu bar, add Custom Submit, select Upload to Server for the submission type, and enter the disk path, file, and file name according to the actual situation. As shown below:

5.png

The specific setting items are described in the following table:

Setting itemThis exampleDescription
Disk path"C:/Users/43886/Desktop/Document/"The location of files saved
FileA1The cell number where the file widget is located
File name

null

Optional

  • If it is empty, the uploaded file name will be obtained by default, and multiple file uploads are supported.

  • If it is not empty, you can customize the file name or use a formula to generate the file name, but multi-file upload is not supported, and the file names will overlap.

2) Save the report, click Data EntryPreview, upload the file, click Submit, and check the file save location to see the file just uploaded. As shown below:

6.png


3. Upload to FTP

1) On the menu bar, click Template > Data Entry Attribute, add Custom Submit, select FTP Upload for the submission type, click FTP Settings, and add an FTP connection.

7.png

2) To create a new FTP connection, the user needs to fill in the connection information according to the actual scene. If there is no user name and password, it can be omitted, as shown in the following figure:

8.png

Note: Sometimes the test connection will fail, but it does not affect file upload and download.

3) Set the file information, as shown below:

9.png

The description of each setting item is shown in the following table:

Setting itemThis exampleDescription
Upload path"/FineReport Document"

The relative path to where the file is saved.

An absolute path can also be used: "ftp://192.168.1.201/FineReport Document"

FileA1The cell number where the file widget is located
File nameEmpty

Optional

  • If it is empty, the uploaded file name will be obtained by default, and multiple file uploads are supported.

  • If it is not empty, you can customize the file name or use a formula to generate the file name, but multi-file upload is not supported, and the file names will overlap.

FTP siteFTP Site1FTP connection name in the second step of Section III.3 of this article

4) Save the report, click Data Entry Preview, upload the file and submit it, check the file save location to see the file just uploaded. As shown below:

10.png


4. Download files

1) Insert the formula =filename(A1) into cell A2, which means to get the filename uploaded in cell A1. In addition to using formulas, you can also use dataset fields, handwritten file names, etc. to set.

11.png

2) Select cell A2, and add a "Hyperlink" of "File Download" type to the attribute panel on the right. The specific settings are as follows:

Setting itemThis exampleDescription
File serviceDefaultSupports downloading from the server or FTP, if it is FTP, you need to select the corresponding FTP connection name
File Path"C:/Users/43886/Desktop/Document/Test.xlsx"

The disk or FTP location where the file is located. Dynamic calculation formulas are not supported.

Relative paths can also be used: "/Test.xlsx"

RenameEmptyOptional, you can rename the downloaded file, does not support reading extended cell values
Encode typeUTF-8The encoding can be set to match the environment of different encodings

12.png

4) Save the report, click Data Entry Preview, and click the download hyperlink to download the file, as shown in the following figure:

13.gif

IV. Template download

Click to download the template: 

Upload and download files.cpt


Attachment List


Theme: Data Entry
Already the First
Already the Last
  • Helpful
  • Not helpful
  • Only read

Doc Feedback