ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Standard functions / XLS file functions
  • Overview
  • Method 1: Dynamically manipulating XLS and XLSX files
  • Method 2: Reading the Excel files (kept for backward compatibility)
  • WLanguage functions
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Overview
WINDEV and WEBDEV propose two methods to handle Excel files:
  • Method 1: Dynamically manipulating XLS and XLSX sheets
    This method uses different types of variables as well as WLanguage functions. This method allows you to manage Excel files (XLS or XLSX files) in read and write mode.
  • Method 2 (for backward compatibility): Using WLanguage functions to manage XLS files.
    This method manages XLS files in read-only mode.
New in version 2025
Android This feature is now available for Android applications.
Android Widget This feature is now available in Android widget mode.
iPhone/iPad This feature is now available for iPhone/iPad applications.
Method 1: Dynamically manipulating XLS and XLSX files
To manipulate XLS and XLSX files, WLanguage includes:
  • different types of variables. These variable types can be used to manipulate XLS documents, rows, columns and cells.
  • several WLanguage functions that handle the different types of data.
To handle the XLS and XLSX files:
  1. Declare a variable of type xlsDocument. This type of variable is used to describe and modify an Excel document.
  2. Open the XLS file if necessary (xlsOpen) and associate it with the xlsDocument variable.
  3. The different elements in the Excel document can be manipulated:
    • with the WLanguage functions.
    • with the xlsDocument properties.
Example:
XLSFileID is xlsDocument 
AFile is string 
AFile = fExeDir + "\Business info1.xls"

XLSFileID = xlsOpen(AFile, xlsWrite)
IF ErrorOccurred = False THEN
	Azz is int = xlsCurrentWorksheet(XLSFileID)
	Info("Current worksheet in the Excel file: " + Azz)
	// Change worksheet
	IF xlsCurrentWorksheet(XLSFileID, 2) THEN
		Info("The current worksheet was modified.")
		// Read a cell for test
		Info(xlsData(XLSFileID, 11, 2))
	ELSE
		Error("The selected file does not include a second worksheet!")
	END 
ELSE
	Error("Caution, the file is already opened on a computer!")
END
Remarks:
  • If the Excel file is opened in read/write mode (xlsWrite constant), the file is opened and locked until it is closed. To save the modifications performed, use xlsSave.
  • The XLS functions do not require "Microsoft Excel" to be installed on the user computers.
  • The XLS files and the files specific to Office 2007 (.xlsx files) are supported.
Related Examples:
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.
Method 2: Reading the Excel files (kept for backward compatibility)
WINDEV and WEBDEV propose several functions allowing you to manage your ".XLS" files from your WINDEV applications and from your WEBDEV websites. These functions allow you to retrieve the data entered in Excel.
To manipulate an XLS document:
  1. Use the xlsOpen function. This function returns the identifier of the XLS file used.
  2. Use the XLS functions to retrieve the requested information about the Excel file and its data.
Remarks:
  • The XLS functions do not require "Microsoft Excel" to be installed on the user computers.
  • Only XLS files are supported. Files specific to Office 2007 (.xlsx files) are not supported.
  • There are two modes available for XLS functions:
    • Mode compatible with earlier versions of WINDEV and WEBDEV: In this mode, only the first sheet of the workbook can be accessed.
    • New multi-sheet mode: In this mode, you can select the sheet of the workbook where the operations are performed.
Use xlsOpen to change the mode for manipulating XLS functions.
WLanguage functions
These functions are used to:
  • open and close ".XLS" files.
  • get information on ".XLS files": Cell data, number of rows, number of columns, column type, column title (see diagram).
  • find out the Excel version used.
  • identify the errors that occurred during the operations performed on an ".XLS" file.
To get the list of functions that can be used with Excel files, see XLS functions.
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…
Comments
Click [Add] to post a comment

Last update: 10/09/2024

Send a report | Local help