ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage functions / Standard functions / XLS file functions
  • Properties specific to xlsDocument variables
  • Accessing a column of an Excel document
  • Accessing a cell of an Excel document
  • Accessing a cell of a column in an Excel document
  • Accessing a cell of a row in an Excel document
  • WLanguage functions that use xlsDocument variables
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
An xlsDocument variable is used to describe and modify an Excel document.
Note: For more details on the declaration of this type of variable and the use of WLanguage properties, see Declaring a variable.
New in version 2025
Android This type of variable is now available for Android applications.
Android Widget This type of variable is now available in Android widget mode.
iPhone/iPad This type of variable is now available for iPhone/iPad applications.
MaFeuille is xlsDocument
NomFichierXLS is string
NomFichierXLS = fSelect(fExeDir(), "", "Sélectionnez un fichier...", ...
	"Tous fichiers (*.*)" + TAB + "*.*", "*", fselOpen + fselExist)
IF NomFichierXLS = "" THEN RETURN
MaFeuille = xlsOpen(NomFichierXLS, xlsWrite)

// On va mettre OK dans la case A 25
MaFeuille[25,"A"] = "OK"
// Sauvegarde
xlsSave(MaFeuille)
IDFicXLS is xlsDocument 
NomFichierXLS is string = fRepExe + "\Suivi d'affaires1.xls"

IDFicXLS = xlsOpen(NomFichierXLS, xlsWrite)
IF ErrorOccurred = False THEN
	Azz is int = xlsFeuilleEnCours(IDFicXLS)
	Info("Feuille en cours dans le fichier Excel : " + Azz)
	// Changement de feuille
	IF xlsCurrentWorksheet(IDFicXLS, 2) = True THEN
		Info("La feuille courante a été modifiée.")
		// Lecture d'une cellule pour test
		Info(xlsData(IDFicXLS, 11, 2))
	ELSE
		Error("Le fichier sélectionné ne comporte pas de seconde feuille !")
	END 
ELSE
	Error("Attention ! le fichier est déjà ouvert sur un poste de travail !")
END
// Créer un document de type XLS
xlsDoc is xlsDocument(xlsVersionXls)
Syntax

Declaring an XLS document without specifying the format Hide the details

MyVariable is xlsDocument
In this case, the variable created does not correspond to a specific Excel format. The format will be defined when the file is saved (according to the specified extension).

Declaring an XLS document by specifying the format Hide the details

MyVariable is xlsDocument(<Format>)
<Format>: Integer constant
Format of the document used. This parameter can correspond to the following constants:
xlsVersionUndefinedUndefined version (default value). The format will be defined when the file is saved.
xlsVersionXlsXLS document.
xlsVersionXlsxXLSX document.
Properties

Properties specific to xlsDocument variables

The following properties can be used to manipulate xlsDocument variables:
NameType usedEffect
CellArray of xlsCellCells in the XLS document.
ColumnArray of xlsColumnColumn in the XLS document.
CommentArray of xlsCommentComments on XLS document cells.
FileCharacter stringName and full path of XLS file associated with the document. This property is read-only. It is assigned when using xlsOpen.
Note: when assigning a variable of type xlsDocument to another, this property is not copied (except when calling function xlsOpen).
LineArray of xlsRowRow in the XLS document.
ModifiedBoolean
  • True if the document was modified
  • False otherwise.
This property is reset to False after the call to xlsSave.
NumberColumnentierNumber of columns in the document (same as xlsNbColumn without taking into account completely empty columns).
This property is read-only.
NumberRowentierNumber of lines in the document (same as xlsNbRow without taking into account completely empty lines).
This property is read-only.
NumberWorksheetentierNumber of worksheets found in the document (identical to xlsNbWorksheet).
This property is read-only.
RecalculateWhenLoadingBoolean
  • True if the formulas of the document must be recalculated when the document is opened in Excel or OpenOffice.
  • False if no calculation must be performed when the document is opened in Excel or OpenOffice.
Note: Only formulas initially present in the document can be recalculated.
RightToLeftBoolean
  • True if the mode for reading the current worksheet is "Right to left".
  • False if the mode for reading the current worksheet is "Left to right".
SheetentierNumber of the current worksheet (identical to xlsCurrentWorksheet).
VersionentierXLS document version (same as xlsVersion). This property is read-only.
WorksheetNameCharacter stringName of the current worksheet. This property can correspond to a string containing between 1 and 31 characters. It is case insensitive.
Remarks

Accessing a column of an Excel document

The following syntaxes can be used to access a column of an Excel document:
  • MyDocumentXLS.Column[1]: Accesses column 1 of the Excel file.
  • MyDocumentXLS.Column["A "]: Accesses column A in the Excel file.

Accessing a cell of an Excel document

The following syntaxes can be used to access a cell of an Excel document:
  • MyDocumentXLS[1,2]: Accesses the cell in row 1 and column 2 of the Excel file.
  • MyDocumentXLS[5, "A "]: Accesses the cell in row 5 and column A of the Excel file.

Accessing a cell of a column in an Excel document

The following syntaxes can be used to access a cell of a column in an Excel document:
  • MyDocumentXLS.Column[1].Cell: Returns the value of the cell in column 1 for the current line..
  • MyDocumentXLS.Column["A "].Cell: Returns the value of the cell in column "A" for the current row..

Accessing a cell of a row in an Excel document

The following syntax can be used to access a cell of a row in an Excel document:
  • MyDocumentXLS.Line[1].Cell[2]: Accesses the cell in row 1 and column 2 of the Excel file.
  • MyDocumentXLS.Line[5].Cell["A "]: Accesses the cell in line 5 and column A of the Excel file.

WLanguage functions that use xlsDocument variables

  • Standard syntax:
    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.
    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.
    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.
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.
Minimum version required
  • Version 14
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 09/21/2024

Send a report | Local help