ExcelDocument data type

Official Content
This documentation is valid for:

Unify interaction with the generation of Microsoft Excel documents for the different languages generated. It allows you to generate and handle Microsoft Excel worksheets. In addition, the ExcelCells data type is implemented internally and is used to handle the group of cells contained in the worksheet.

An important advantage that this implementation has over the previous ones is that spreadsheets are handled with an object-oriented model and it is no longer necessary to control Handles.

Properties

AutoFit property MacroReturnNumber Property
Delimiter Property MacroReturnText Property
ErrCode Property Extended Data Types Read-Only property
ErrDescription Property Template Property
ErrDisplay Property UseAutomation Property
MacroReturnDate Property  

Methods

Cells Method RenameSheet Method
Clear method RunMacro Method
Close Method Save Method for excel document and word document extended data types
Hide Method SelectSheet Method
Open Method Show Method
Print Method Unbind Method

Scope

Languages .NET, Java

Examples

Event "Excel"
   &ExcelDocument.Open(&File)  

   If &ExcelDocument.ErrCode <> 0 
       msg(&ExcelDocument.ErrDescription) 
   Else 
       &ExcelDocument.Clear()  
    
       &ExcelDocument.Cells(1,1).Text = 'Customers list'  
       &ExcelDocument.Cells(1,1).Bold = 1 
       &ExcelDocument.Cells(1,1).Color = RGB(0, 0, 255) 
       &ExcelDocument.Cells(1,1).Size = 10 
        
       &ExcelDocument.Cells(3,1).Text = 'Customer Id' 
       &ExcelDocument.Cells(3,1).Italic = 1 
       &ExcelDocument.Cells(3,1).Bold = 1 
    
       &row = 4 
       &col = 1 
       For Each Line in Grid 
    
               &ExcelDocument.Cells(&row,&col).Number = CustomerId 
               &ExcelDocument.Cells(&row,&col).Color = RGB(0, 0, 255) 
               &row += 1    
              
       Endfor  
       &ExcelDocument.Save()  
   Endif
EndEvent 

.NET

There are two possible implementations:

  • EPPLUS: Genexus uses this implementation when xlsx file extension is configured (which is recommendable). Check here for more information.
  • ExcelLite DLL: Genexus uses this implementation when the necessary file - GemBox.Spreadsheet.dll - is available after installing GemBox's spreadsheet software

Note: The only way to generate the proprietary xls files is using ExcelLite.

Java

Check here for more information.

Managing excel documents common issues

See also

ExcelCells data type