Overview
Application Scenario
FineReport allows you to copy and paste Excel data to the data entry page, and then submit the data.
Note:Solution
During data entry preview, you can add a corresponding number of blank records, then copy and paste data from Excel to these blank records.
Procedure
1. Design the data entry report as shown in the following figure.

2. Select Data Entry Preview to open the report, click the Add Record button on the toolbar, and add the corresponding rows of blank records to match the data that needs to be copied and pasted from Excel.

3. Select and copy (Ctrl + C) the data in Excel.

4. Return to the data entry preview page, and paste the data.
Click the cell in the upper left corner of the data, and paste (Ctrl + V) the data when the black frame appears as shown in the following figure.

5. Click Submit.
Template Download
For details, you can download the completed template Copying and Pasting Excel Data to Data Entry Cells.cpt.
You can download the Excel file Data Entry of the Sales Data by Region.xlsx.
Notes
Automatically Skipping Empty Values
Problem:
Empty values in Excel cannot be pasted into the data entry page. That is, the empty values will be automatically skipped.

Solution:
You can choose Template > Web Attribute > Data Entry Setting on the toolbar of the designer, select Set for This Template Separately from the drop-down list of Following Settings, and add a Loading End event. (You can either introduce a JS file or paste JS code for the event.) Alternatively, you can choose Server > Server Configuration > Data Entry Setting, and add a Loading End event. (You can either introduce a JS file or paste JS code for the event.) In this case, you must ensure that Use Server Settings is selected from the drop-down list of Following Settings.
The JS code is as follows:
FR.WritePane.prototype.dealWithPasteContent = function(value) {
// Remove the line break in the end.
if (value.endWith('\n')) {
value = value.substring(0, value.length - 1);
}
return this._parsePasteContentToArray(value);
}
FR.WritePane.prototype.cellPasteCheck = function(cell, cev, editorO) {
return cev !== null && !editorO.disabled && editorO.editable !== false && editorO.directEdit !== false;
}Failing to Paste the Last Column When Copying and Pasting Multiple Empty Columns From Excel
Problem:
The empty columns copied from the Excel data cannot be pasted to the template, as shown in the following figure.

Solution:
If you need to add the JS code in the Loading End event for the template where empty rows or columns are to be pasted from Excel, the JAR version should be generated from 2019-12-05.
FR.WritePane.prototype.dealWithPasteContent = function(value) {
if (value.endWith('/n')) {
value = value.substring(0, value.length);
}
return this._parsePasteContentToArray(value);
}
FR.WritePane.prototype.cellPasteCheck = function(cell, cev, editorO) {
return cev !== null && !editorO.disabled && editorO.editable !== false && editorO.directEdit !== false;
}
FR.WritePane.prototype._parsePasteContentToArray = function(value) {
var rows = [], start_index = 0, flag = false;
for (var i = 0; i < value.length; i++) {
var cr = value.charAt(i);
if (cr === '"') {
flag = !flag;
} else if (cr === '\n' && !flag) {
rows.push(value.substring(start_index, i)
.replaceAll('""', '\n\r')
.replaceAll('"', '')
.replaceAll('\n\r', '"'));
start_index = i + 1;
}
}
if (start_index < value.length) {
rows.push(value.substring(start_index, value.length)
.replaceAll('""', '\n\r')
.replaceAll('"', '')
.replaceAll('\n\r', '"'));
}
for (var i = 0; i < rows.length; i++) {
rows[i] = rows[i].split('\t');
}
return rows;
} Not Displaying the Widget Directly
If you select Display Widget Directly, the pasting operation will be ineffective.
