K2 SmartForms

How to register and use the Excel Control for K2 SmartForms

K2 Smartforms Export to Excel
In this article, we will learn about how to export the SmartObject data to an Excel spreadsheet using the K2 Excel custom control

The Excel control can be downloaded from here.

How to register the Excel Control

Before using the control, you need to register it to make it available in K2 SmartForm designer

First, extract the folder and copy the Excel export DLL from bin folder

(DLL Location: 20130814 Excel Controls v1.01 for community\20140305 ExcelExportv1.01 Working.zip\ExcelExport\bin\Debug)

  1. Manually copy ExcelExport.dll file to the following directories:
  • K2 Designer server: C:\Program Files (x86)\K2 blackpearl\K2 SmartForms Designer\Bin\
  • K2 SmartForms Runtime server: C:\Program Files (x86)\K2 blackpearl\K2 SmartForms Runtime\Bin\
  1. Register the control using controlutil.exe
  • The controlutil.exe can be found in C:\Program Files (x86)\K2 blackpearl\Bin
  • Syntax:

controlutil.exe register -assembly:”C:\Program Files (x86)\K2 blackpearl\K2 SmartForms Designer\bin\ExcelExport.dll”


Deploy the ExcelFile SmartObject

From Project Folder, open the ExcelSmartObjects Solution and deploy the ExcelFile SmartObject.

This SmartObject is used to store the generated Excel file in K2 SmartBox SQL Server database

After registering the control, you should be able to see the Excel export control in the K2 SmartForm designer under Excel controls section

k2 smartforms export to excel - 1 - Excel Export Control

How to use the Excel control in K2 list view control

Drag the controls below onto a new K2 listview –

  1. Toolbar button
  2. File Attachment
  3. Excel control

k2 smartforms export to excel - 2 - Export to Excel Control - Design Time

Generating an Excel File

Under Toolbar button click event

Add an action called Execute a view control method

Select control as Excel export and it has only one method “Create Excel File”

Now, configure the Excel export control by passing the ADO query as input parameter on SmartObject data.

ADO Query

For Ex: SELECT Name,Country,Age,Email,Mobile FROM Employees Having Country=’United Kingdom’

The control will extract the data based on input query and stores the generated file into K2 SmartBox and returns the file ID as parameter.

Now, execute Excel file SmartObject load method by passing a file id as input value.  The SmartObject will subsequently return a file.  Ensure to map the return value to file attachment control in the view.

By clicking on the file attachment control, you can download the generated Excel file with extracted data from SmartForm listview

k2 smartforms export to excel - 3 - Export to Excel Control - Run Time



You may also like


  • Hind Al-Boainain June 6, 2016   Reply →

    Hi, many thanks for the above, much appreciated, however, I’m stuck in 2 sections:

    1. I’m not sure if I was able to Register the control using controlutil.exe as running the file didn’t open anything and I was unable to input and run the below syntax:
    controlutil.exe register -assembly:”C:\Program Files (x86)\K2 blackpearl\K2 SmartForms Designer\bin\ExcelExport.dll”

    2. The ADO Query section was a bit unclear, but maybe because I was unable to run the above syntax, it isn’t working properly for me?

    I appreciate your assistance if possible!

    • admin October 29, 2016   Reply →

      Did you get sorted with this?

  • Asif Momin December 21, 2016   Reply →

    We implemented this control successfully.

  • Asif May 17, 2017   Reply →

    This works as expected. Thanks for sharing.

    • Violeta May 23, 2017   Reply →

      Hi Asif! Thanks for your comment. All our blog posts are written by our highly specialised developers who aim to bring you expert tips. We’re glad you appreciate this! Check back soon, we have a lot of fresh content on its way!

  • Sharmi June 28, 2017   Reply →

    Hi ,

    I am not able to implement the Export to Excel functionality. Please help me regarding this. Its really urgent

  • Sharmi July 11, 2017   Reply →

    Hi.. I am getting this error . can someone help me?

    No list methods on SmartObject

Leave a comment

PODCAST  |  Why you need to establish a K2 Center of Excellence today

Interview with Arno van Rooyen, CEO, Velocity