Export SQL query results to a DingTalk Sheet

更新时间:
复制 MD 格式

After you run an sql query in DataWorks, you can directly export the results to DingTalk as a DingTalk Sheet. This avoids the security risks of downloading query data as local Excel files.

Supported versions

This feature is available only in DataWorks Standard Edition and higher.

Configure DingTalk

Create a DingTalk app

  1. Go to the DingTalk Open Platform, log in to the developer console in the upper-right corner, and switch to your target organization.

  2. In the top navigation bar, click app development. The DingTalk Apps tab opens by default.

  3. Click Create App on the right. In the dialog box that appears, configure the app name, app description, and app icon.

  4. After you complete the configuration, click Save. The app configuration page opens.

Configure app permissions

On the application configuration page, click Development Configuration > Permission Management to go to the permission configuration page for the new application. On this page, you can configure different permissions for the application for different members of your organization.

  1. Permission Scope: Configure the permission scope for the app to specify which members can use it.

  2. Configure the app permissions as described in the following table:

    App permissions

    Permission

    API

    Permission code

    Personal mobile number information

    Get personal information

    Contact.User.mobile

    Read permission for personal information in Contacts

    Get a user's personal information from Contacts

    Contact.User.Read

    Basic permissions required to call SNS APIs

    Query personal authorization records

    snsapi_base

    Basic permissions to call corporate APIs

    Generate JSAPI

    qyapi_base

    Generate an access token for the micro-app backend

    Get a single master data record from a connector by business primary key

    Get connector master data by page

    Synchronize connector data

    Get an enterprise access token (for internal apps)

    Update work notification status

    Get user ID with a logon-free code (v2)

    Send messages using the service assistant

    Get user check-in records

    Send messages via custom bot integration

    Recall work notification messages

    Send work notification messages asynchronously

    Get the sending result of a work notification message

    Get the sending progress of a work notification message

    Get the scope of Contacts permissions

    Get jsapi_ticket

    Upload media files

    Get holiday data from reports

    Get column values from smart attendance reports

    Get attendance report column definitions

    Check if smart statistical reports are enabled

    Get user attendance groups

    Calculate leave duration

    Get attendance group list details

    Query enterprise attendance schedule details

    Basic permissions to get user access credentials for DingTalk open APIs

    Get user token

    open_app_api_base

    Get user information from an SNS temporary authorization code

    Knowledge Base Document Write Permission

    Remove members from a knowledge base document

    Document.WorkspaceDocument.Write

    Modify knowledge base document members

    Create a knowledge base document

    Add members to a knowledge base document

    DingTalk Sheet Read Permission

    Get all worksheets

    Document.Workbook.Read

    Get a worksheet

    Get a cell range

    DingTalk Sheet Write Permission

    Set row visibility

    Document.Workbook.Write

    Set column visibility

    Delete rows

    Delete columns

    View more

    Knowledge Base Document Read Permission

    Query directory tree

    Document.WorkspaceDocument.Read

    Query knowledge base nodes (including documents and folders)

    Knowledge Base Search Permission

    Search a knowledge base

    Wiki.Workspace.Search

    Knowledge Base Write Permission

    Create a knowledge base

    Wiki.Workspace.Write

    Knowledge Base Read Permission

    Get a list of knowledge bases

    Wiki.Workspace.Read

    Get knowledge bases in batches

    Get my documents

    Get a knowledge base

    Knowledge Base Node Read Permission

    Get a list of nodes

    Wiki.Node.Read

    Get a node by link

    Get nodes in batches

    Get a node

Configure security settings

On the Application Configuration page, click Development Configuration > Security Settings to open the Security Settings page and configure the redirect URL (callback domain). The domain information is as follows:

  • Redirect URLs for regions in China:

    China (Hangzhou): https://da-cn-hangzhou.data.aliyun.com/api/v1/oa/dingtalk/auth/callback
    China (Shanghai): https://da-cn-shanghai.data.aliyun.com/api/v1/oa/dingtalk/auth/callback
    China (Beijing): https://da-cn-beijing.data.aliyun.com/api/v1/oa/dingtalk/auth/callback
    China (Zhangjiakou): https://da-cn-zhangjiakou.data.aliyun.com/api/v1/oa/dingtalk/auth/callback
    China (Ulanqab): https://da-cn-wulanchabu.data.aliyun.com/api/v1/oa/dingtalk/auth/callback
    China (Shenzhen): https://da-cn-shenzhen.data.aliyun.com/api/v1/oa/dingtalk/auth/callback
    China (Hong Kong): https://da-cn-hongkong.data.aliyun.com/api/v1/oa/dingtalk/auth/callback
    China (Shanghai) Finance: https://da-cn-shanghai-finance-1.data.aliyun.com/api/v1/oa/dingtalk/auth/callback
    China (Beijing) Finance: https://da-cn-beijing-finance-1.data.aliyun.com/api/v1/oa/dingtalk/auth/callback
    China (Shenzhen) Finance: https://da-cn-shenzhen-finance-1.data.aliyun.com/api/v1/oa/dingtalk/auth/callback
    China North 2 (Beijing) - Gov 1: https://da-cn-north-2-gov-1.data.aliyun.com/api/v1/oa/dingtalk/auth/callback
  • Redirect URLs for regions outside China:

    Japan (Tokyo): https://da-ap-northeast-1.data.aliyun.com/api/v1/oa/dingtalk/auth/callback
    Singapore: https://da-ap-southeast-1.data.aliyun.com/api/v1/oa/dingtalk/auth/callback
    US (Virginia): https://da-us-east-1.data.aliyun.com/api/v1/oa/dingtalk/auth/callback
    US (Silicon Valley): https://da-us-west-1.data.aliyun.com/api/v1/oa/dingtalk/auth/callback
    UK (London): https://da-eu-west-1.data.aliyun.com/api/v1/oa/dingtalk/auth/callback
    Indonesia (Jakarta): https://da-ap-southeast-5.data.aliyun.com/api/v1/oa/dingtalk/auth/callback
    Germany (Frankfurt): https://da-eu-central-1.data.aliyun.com/api/v1/oa/dingtalk/auth/callback
    Malaysia (Kuala Lumpur): https://da-ap-southeast-3.data.aliyun.com/api/v1/oa/dingtalk/auth/callback
    Saudi Arabia (Riyadh): https://da-me-central-1.data.aliyun.com/api/v1/oa/dingtalk/auth/callback
Note
  • You only need to enter the URL.

  • If you need to redirect to multiple regions, enter the URLs separated by a ,.

Publish the app

  1. After you configure all the parameters, click Application Release > Version Management and Release to go to the Version Release page.

  2. Click Create New Version to open the version information editor.

  3. Configure the version details. On the version information editor, set the App Version and Version Description. Confirm the Content to Be Released and Visibility Scope, and then click Publish in the upper-right corner to release the app version.

Configure DataWorks

Connect the DingTalk app

  1. Go to the SQL Query page.

    Log on to the DataWorks console. In the target region, click Data Analysis and Service > DataAnalysis in the left-side navigation pane. Click Go to DataAnalysis to open the Data Analysis page. In the left-side navigation pane, click SQL Query.

  2. In the left navigation bar, click More > System Management, and then click the Office Software Integration tab.

  3. Select the DingTalk app integration option and configure its settings.

    Parameter

    Description

    DingTalk app name

    Go to DingTalk Open Platform > App Development, click the DingTalk app that you configured in Configure DingTalk, and then on the left navigation bar, click Basic Information > Credentials and Basic Information to view the App Name, Client ID, and Client Secret.

    Client ID

    Client Secret

  4. After you complete the configuration, click Confirm to save the integration settings.

Query and export results

  1. After you successfully obtain the query results by using SQL Query (Old Version), click Export > DingTalk Sheet in the upper-right corner of the results pane.

    Important

    If this option does not appear, go to Security Center > Data Query and Control > Query Result Control and enable Allow Download for Query Result. For more information, see Data Query and Control.

  2. In the Export to DingTalk Sheet dialog box, configure the parameters.

    New sheet

    Parameter

    Description

    Target file

    Select Create New Sheet. Each export operation creates a new DingTalk Sheet file in the specified folder within DingTalk Docs.

    Folder link

    The link to the folder in DingTalk Docs where the exported spreadsheet will be saved.

    Spreadsheet name

    The name of the exported file.

    Get the folder link

    1. Log in to DingTalk Docs and switch to the app's DingTalk organization.

    2. In the top-right corner, click New > Folder to create a folder.

    3. Hover over the folder you created, right-click, and select Copy Link to get the folder URL.

    Existing sheet

    Parameter

    Description

    Target file

    Select Import to Existing Sheet. Each export operation creates a new sheet within the selected spreadsheet and writes the query results to it.

    Workbook ID

    The ID of the spreadsheet to which you want to import the query results.

    Sheet name

    The name of the new sheet that will be created to store the exported results.

    Get the workbook ID

    1. Log in to DingTalk Docs and switch to the app's DingTalk organization.

    2. Navigate to the folder and open or create the spreadsheet where you want to import the query results.

    3. Click Workbook > Workbook Information in the top-left corner of the workbook, and in the pop-up window that appears, find the workbook ID under Basic Information > Workbook ID.