ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Standard functions / XLS file functions
  • Using the XLS functions in read/write
  • The XLS file cannot be opened
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Opens an Excel file (xls or xlsx files).
Remark: To create an Excel file without using an initial file, you just you have to create a variable of type xlsDocument (in this case, xlsOpen has no effect).
Linux Only the xlsx format is supported.
Example
Example used to open an Excel file while retrieving an integer
doc is xlsDocument
doc = xlsOpen(fExeDir() + ["\"] + "gpac.xls")
 
IF ErrorOccurred() THEN
Error(ErrorInfo())
RETURN
END
 
Info("Content of [1,1] cell:", doc[1,1])
 
xlsClose(doc)
Syntax
<Result> = xlsOpen(<Path of XLS file> [, <Opening mode> [, <Password>]])
<Result>: xlsDocument variable
Name of the xlsDocument variable corresponding to the XLS file. This variable can be used by all the XLS functions. Using this type of variable allows you to modify the XLS documents.
Warning
Result compatible with version 12. For compatibility reasons, this variable can be converted to an integer corresponding to the specified XLS file ID. This ID can be used in all XLS functions that support the file ID. This syntax only allows you to read XLS documents: no modification is possible.
In an error occurs, the ErrorOccurred variable is set to True and ErrorInfo returns the details of the error.
<Path of XLS file>: Character string
Full or relative path of XLS file to open (up to 260 characters).
<Opening mode>: Optional integer constant
Indicates the opening mode of XLS file.
By default:
  • the Excel file is opened in read-only mode. You can write to the Excel file with another application.
  • the Excel file uses the multi-sheet management mode for XLS files.
xlsCompatibleUsed to open the Excel file in mode compatible with version 10.
In this mode:
  • A single workbook sheet is supported.
  • Unicode is not supported.
  • The groups of strings are not supported.
  • Some functions (xlsData or xlsNbRow for example) may return inconsistent results.
Warning
From version 11, this constant is available for backward compatibility.
xlsWriteOpens the Excel file in "Read/Write" mode: the XLS file is opened and locked until it is closed.
Caution: the modifications performed in the XLS file will be taken into account only if you are using an xlsDocument variable.
<Password>: Optional character string
Password to open the XLS file to use.
Remarks

Using the XLS functions in read/write

To handle the XLS files in read/write, you must use an xlsDocument variable. This type of variable can also be used to handle the files specific to Office 2007 (.xlsx files) in read/write.
The use of the file identifier is kept for backward compatibility with version 12. The XLS documents (including the ".xlsx" files specific to Office 2007) handled with this identifier cannot be modified (even if the xlsWrite constant is specified).
Example using the syntax kept for backward compatibility:
XLSFileID is int
XLSFileID = xlsOpen(CompleteDir(fExeDir()) + "GPACS.XLS")
IF ErrorOccurred = False THEN
Info("The XLS file was opened")
// Close the file
xlsClose(XLSFileID)
ELSE
Info(ErrorInfo())
END
END

The XLS file cannot be opened

The possible error cases are as follows:
  • The specified XLS file was not found.
  • The specified XLS file does not exist.
  • The specified XLS file cannot be opened.
  • The specified XLS file is invalid.
  • Insufficient memory to open the XLS file.
  • The version of Excel used is unknown or too old (the XLS functions cannot read the files in Excel version 2 or earlier).
To get more details on the error, use xlsMsgError (if your are using version-12-compatible syntax) or ErrorInfo with the errMessage constant.
Component: wd290xls.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 05/26/2022

Send a report | Local help