Help / WLanguage / WLanguage functions / Standard functions / XLS file functions
  • Other functions linked to Excel
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WindowsLinuxPHPWEBDEV - Browser code
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Stored procedures
Remark: These functions are also available in prefix syntax (Functions for managing XLS files (prefix syntax)).
The following functions are used to manage XLS files:
xlsAddWorksheetAdds or inserts a new worksheet into an Excel document.
xlsCloseCloses an XLS file.
xlsColumnTitleRetrieves the title of a column found in an XLS file.
xlsColumnTypeReturns the type of data entered in a column of an XLS file.
xlsCoordinatesToNameRetrieves the name of a cell, XLS worksheet or Spreadsheet control according to its coordinates.
xlsCurrentWorksheetUsed to find out and modify the current worksheet in an XLS file.
xlsDataRetrieves the content of a cell found in an XLS file.
xlsDeleteWorksheetDeletes a worksheet from the Excel document.
xlsGetMergeDetermines if a cell is merged with other cells and gets the merged cell range.
xlsMergeCellMerges the specified cells in an Excel document.
xlsMsgErrorReturns the caption of the last error caused by an XLS function.
xlsNameToCoordinatesReturns the coordinates of a cell, XLS file or spreadsheet control according to its name.
xlsNbColumnReturns the number of columns found in a worksheet of an XLS file.
xlsNbColumnsxlsNbColumns is kept for backward compatibility only.
xlsNbRowReturns the number of rows found in an XLS file.
xlsNbRowsxlsNbRows is kept for backward compatibility only.
xlsNbWorksheetReturns the number of worksheets found in an XLS file.
xlsOpenOpens an Excel file (xls or xlsx files).
xlsRecalculateAllRecalculates all formulas in an Excel (XLSX) document.
xlsSaveSaves an XLS document.
xlsUnmergeCellUnmerges a range of cells.
xlsVersionReturns the Excel version that was used to save the file.
Other functions linked to Excel
AAFDisableDisables the export of Table control content or content selection to Excel or to OpenOffice Calc (depending on the software installed on the user's computer).
AAFExecuteExports the content of Table control or the selection performed in the Table control to Excel or to OpenOffice Calc (depending on the software installed in the user computer).
HImportXLSImports an XLS file into a data file in HFSQL Classic or Client/Server format (data file described in the data model editor or declared by HDeclare, HDeclareExternal or HDescribeFile).
LooperToExcelCreates an Excel file with data from a Looper control (based on a data file or populated programmatically).
TableToExcelCreates an Excel file with the data from a Table or TreeView Table control (based on a data file or populated programmatically).
Related Examples:
The Excel functions Unit examples (WINDEV): The Excel functions
[ + ] Using the functions for importing/exporting a WINDEV table to/from Excel and Word. This is automatically performed by the WLanguage functions.
The following topics are presented in this example:
1/ How to export the content of a table to Excel or Word
2/ How to import the content of an Excel file to a WINDEV table
A button is used to import the entire data from a Excel file into an application table.
A second button is used to export the table content to the source Excel file in order to apply the modifications.
The table can also be exported in table format into Word.
XLS Type Unit examples (WINDEV): XLS Type
[ + ] Handling the xlsDocument, xlsColumn, xlsRow and xlsCell variables.
The purpose of this example is to explain how these types of variables can be easily handled.
WD Controlling Excel Training (WINDEV): WD Controlling Excel
[ + ] This example explains how to control Excel via OLE Automation.
All the features included in Excel can be emulated.

This example requires Excel 97 or later.

Summary of the example supplied with WINDEV:
Controlling a spreadsheet as Excel may be useful to allow the user to keep his own habits from the software powered by WINDEV.
This process is very easy via the "CExcel" class supplied with WINDEV.
The main features of Excel can be directly called (chart, inserting objects, sorts, ...).
How do I control Excel via OLE Automation?
An OLE Automation contains methods and properties. This allows you to emulate it directly in WLanguage.
For example, to display the selected cell in bold:
MyOLEAutomationObject>>Selection>>Font>>Bold = True
WD Controlling Spreadsheets Training (WINDEV): WD Controlling Spreadsheets
[ + ] This example explains how to control OpenOffice Calc and Excel with a generic code.
It gives you the ability to create, open and handle the workbooks opened in OpenOfficeCalc and Excel from a WINDEV application.
You can position on a worksheet, select cells, read and modify their content, save the workbook and close it.
The use of an abstract class (CSpreadsheet) enables you to implement a unique code, regardless of the spreadsheet installed on the user computer
Minimum version required
  • Version 9
This page is also available for…
// Define the nome do arquivo XLS e o caminho
XLSFile is string = "C:\temp\Comandos.xlsx"

IF fFileExist(XLSFile) = False THEN

Info("Erro arquivo nao encontrado")


// Abre um novo arquivo XLS
MyXLSDocument is xlsDocument
MyXLSDocument = xlsOpen(XLSFile,xlsWrite)

// Adiciona uma nova planilha
xlsAddWorksheet(MyXLSDocument,"Comandos e Descrições",2)

// Define os títulos das colunas
xlsData(MyXLSDocument, 1, 1, "Comando/Função")
xlsData(MyXLSDocument, 1, 2, "Descrição")

// Adiciona comandos e descrições - você deve substituir esses valores pelos comandos e descrições reais
xlsData(MyXLSDocument, 2, 1, "xlsAddWorksheet")
xlsData(MyXLSDocument, 2, 2, "Adiciona ou insere uma nova planilha em um documento Excel.")
xlsData(MyXLSDocument, 3, 1, "xlsClose")
xlsData(MyXLSDocument, 3, 2, "Fecha um arquivo XLS.")

// Salva o arquivo XLS

// Fecha o arquivo XLS

10 Jun. 2024

Last update: 05/27/2024

Send a report | Local help