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


K2 Automated Testing Software

BenchQA allows full test automation of K2, including fully automated K2 SmartForms and K2 Workflow testing. It promotes test driven development for K2 and ensures continued quality assurance for K2 solutions. Easily apply changes to test cases to accommodate changes to K2 apps and ensure all apps are regression tested to avoid defects and assure continuous quality.


BenchQA Logo


Free K2 Five Upgrade Review


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


Need further technical advice or support?

Contact Us

You may also like

Please complete the below form and a member of the Velocity IT team will call you back.