Export records to an Excel file

Introduction

Although Kintone Apps allow data to be exported as CSV files, there are no options to export data as Excel files.

 

This article introduces a method to output data as an Excel file directly from Kintone with the click of a button.

Completed customization image

The data in the Kintone App is outputted to an Excel file by clicking a button under the Record View list.

Image008.jpg

Preparing the App

Create an App from scratch

From the Kintone portal, click the [+] icon within the Apps widget.

Image001.png

 

Then click Create App from Scratch to create a new Kintone App.

Image002.png

Form settings

Add the following fields to the App form.

Image_3.png

 

Change the settings for each field as shown below.

Field type Field name Field code
Record number Record number Record_number
Text Title title
Text area Details detail

Custom view settings

Next, navigate to the Views tab. Click the [+] button to create a new view.

Image005.png

 

Select Custom view as the display format of the record view.

Image006.png

 

Enter the following code in the HTML code box.

Click the Save button, and then click Activate App to create the App.

Customizing with JavaScript

Copy the sample code below and save it as a JavaScript file named outputXLSX.js.

outputXLSX.js

Code explanation

  1. Lines 132-136: Creates data for output when the app.record.index.show event is triggered as the page loads
  2. Lines 33-47: Uses the function fetchRecords() to retrieve all Kintone records.
  3. Lines 22-31: Creates an element from the retrieved data.
  4. Lines 105-117: Creates an HTML table from the element.
  5. Lines 61-86: Uses methods from several libraries introduced later on to export from tables to xlsx at the timing of clicking the button.

The outputXLSX.js file and the libraries used inside it will need to be uploaded to the JavaScript files for PC section of the JavaScript & CSS settings of the App. Refer to the Customizing Kintone with JavaScript & CSS article in the Kintone Help Center for information on uploading JavaScript files and libraries to an App.

Libraries within the Kintone CDN: Specify by URL

  • jQuery
    • https://js.kintone.com/jquery/3.3.1/jquery.min.js

Libraries outside the Kintone CDN: Download from GitHub and upload as a file

Once all files have been uploaded, the settings should look like the following.

Image007.png

Checking the customization

When viewing the custom list view, the Download XLSX button should appear. Clicking the button should output the Kintone data in xlsx format.

Finally

This article introduced a method to output Kintone record data directly into an xlsx file, instead of converting from CSV to xlsx. This method of outputting directly to an xlsx file makes it easier to integrate with services that can read Excel files.

Was this article helpful?
0 out of 0 found this helpful
Do you have any questions or issues related to this article?
Please share your views with us in the Community forums!