Export to Spreadsheet (Excel)

The WorkWith and SubWorkWith nodes in K2BEntityServices Pattern, as well as the Web Panel Designer Grid node, can generate spreadsheets reports based on the grid's columns. These Excel reports are created using the ExcelDocument data type

How to Enable Spreadsheet reports in K2BTools

K2BEntityServices Pattern

To enable spreadsheet generation in a K2BEntityServices instance, set the "Export enabled" property to true in the standard actions node within the WorkWith and SubWorkWith nodes.

ExportEnabledProperty
ExportEnabledProperty

By default, this property is set to true. You can modify this behavior in K2BEntityServices settings under Standard Actions -> Export to Excel -> Enable by default property.

ExportSettingsEnableByDefault
Default value of export enabled

The default procedure name for implementing the report is <ObjectName>Export. This naming convention can be changed in K2BEntityServicesSettings under GeneratedObjectNames -> Export.

WebPanelDesigner

To enable spreadsheet generation in the Web Panel Designer, set the "Export to Spreadsheet enabled" property, located in the Grid node to true.

ExportoToSpreadsheetProperty
Export to Spreadsheet in WebPanelDesigner

The default value of this property is false. The default procedure name for implementing the report is Export<ObjectName><GridName>, which can be changed in the "Generated Export Name" property located in the Grid node.

Supported Grids for Export to Spreadsheet

The Export to Spreadsheet feature is supported in:

Which columns are included

The columns included in the export are those related to attributes or variables with the "Use In Spreadsheet export" set to true.

ExportUseInSpreadsheetreport
Use column in spreadsheet report

It also considers the runtime column selection in grids; by default, only visible columns selected by the user are included in the report. This behavior can be changed using the "Use Grid Column Configuration" property located in K2BEntityServices settings under Standard Actions -> Export To Excel -> Use Grid Column Configuration.

ExportUseGridColumnConfiguration
Use Grid Column Configuration

How to customize the design of the report

In K2BEntityServices settings under Standard Actions -> Export To Excel, you can configure the start row and start column of the report. Additionally, the ShowContextHeader property can be set to false to remove title and filter information included in the Excel report.

All export reports are based on a layout that can be used for further customization. For more information about this feature, read Export Layout.

Where the excel file is generated

In GeneXus, for the ExcelDocument to be shown to the user, it needs to be temporarily stored on the server. The ExcelFileType property is available in K2BEntityServices settings under Standard Actions -> ExportToExcel. By default, ExcelDocuments are temporarily stored in Directory.TemporaryFilesPath. The ExcelDocument is returned in an HttpResponse, managed by the K2BT_ReturnFileInHttpResponse procedure, and the file is removed after 10 seconds. To change this behavior, the K2BRemoveExcelDocument procedure can be customized.