|
|
|
|
|
- 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
xlsDocument (Variable type) In french: xlsDocument
An xlsDocument variable is used to describe and modify an Excel document. Remark: For more details on the declaration of this type of variable and the use of WLanguage properties, see Declaring a variable.
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)
MaFeuille[25,"A"] = "OK"
xlsSave(MaFeuille)
IDFicXLS is xlsDocument
NomFichierXLS is string = fExeDir + "\Suivi d'affaires1.xls"
IDFicXLS = xlsOpen(NomFichierXLS, xlsWrite)
IF ErrorOccurred = False THEN
Azz is int = xlsCurrentWorksheet(IDFicXLS)
Info("Feuille en cours dans le fichier Excel : " + Azz)
IF xlsCurrentWorksheet(IDFicXLS, 2) = True THEN
Info("La feuille courante a été modifiée.")
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
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:
| | xlsVersionUndefined | Undefined version (default value). The format will be defined when the file is saved. | xlsVersionXls | XLS document. | xlsVersionXlsx | XLSX document. |
Remarks Properties specific to xlsDocument variables The following properties can be used to manipulate xlsDocument variables: | | | nom | Type used | Effect |
---|
Cell | Array of xlsCell | Cells in the XLS document. | Column | Array of xlsColumn | Column in the XLS document. | comment | Array of xlsComment | Document XLS cell comments. | File | Character string | Name and full path of XLS file associated with the document. This property is read-only. It is assigned when using xlsOpen. Remark: when assigning an xlsDocument variable into another one, this property is not copied (except during the call to xlsOpen). | Modified | Boolean | - True if the document was modified
- False otherwise.
This property is reset to False after the call to xlsSave. | NumberColumn | entier | Number of columns in Document (same as xlsNbColumn, but without taking into account completely empty columns). This property is read-only. | NumberRow | entier | Number of rows in the Document (same as xlsNbRow, but without taking completely empty rows into account). This property is read-only. | NumberWorksheet | entier | Number of worksheets found in the document (identical to xlsNbWorksheet). This property is read-only. | RecalculateWhenLoading | Boolean | - 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.
Remark: Only the formulas initially found in the document can be recalculated. | RightToLeft | Boolean | - 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".
| Row | Array of xlsRow | Row in the XLS document. | Sheet | entier | Number of the current worksheet (identical to xlsCurrentWorksheet). | SheetName | Character string | Name of the current worksheet. This property can correspond to a string containing between 1 and 31 characters. It is case insensitive. | Version | entier | XLS document version (same as xlsVersion). This property is read-only. |
Accessing a column of an Excel document The following syntaxes can be used to access a column of an Excel document: - MyXLSDocument.Column[1]: Accesses the column 1 of the Excel file.
- MyXLSDocument.Column["A"]: Accesses the column A of the Excel file.
Accessing a cell of an Excel document The following syntaxes can be used to access a cell of an Excel document: - MyXLSDocument[1,2]: Accesses the cell found in row 1 and column 2 of the Excel file.
- MyXLSDocument[5, "A"]: Accesses the cell found 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: - MyXLSDocument.Column[1].Cell: Returns the value of the cell found in column 1 for the current row.
- MyXLSDocument.Column["A"].Cell: Returns the value of the cell found 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: - MyXLSDocument.Row[1].Cell[2]: Accesses the cell found in row 1 and column 2 of the Excel file.
- MyXLSDocument.Row[5].Cell["A"]: Accesses the cell found in row 5 and column A of the Excel file.
WLanguage functions that use xlsDocument variables - Standard syntax:
| | xlsAddWorksheet | Adds or inserts a new worksheet into an Excel document. | xlsClose | Closes an XLS file. | xlsColumnTitle | Retrieves the title of a column found in an XLS file. | xlsColumnType | Returns the type of data entered in a column of an XLS file. | xlsCurrentWorksheet | Used to find out and modify the current worksheet in an XLS file. | xlsData | Retrieves the content of a cell found in an XLS file. | xlsDeleteWorksheet | Deletes a worksheet from the Excel document. | xlsGetMerge | Determines if a cell is merged with other cells and gets the merged cell range. | xlsMergeCell | Merges the specified cells in an Excel document. | xlsMsgError | Returns the caption of the last error caused by an XLS function. | xlsNbColumn | Returns the number of columns found in a worksheet of an XLS file. | xlsNbColumns | xlsNbColumns is kept for backward compatibility only. | xlsNbRow | Returns the number of rows found in an XLS file. | xlsNbRows | xlsNbRows is kept for backward compatibility only. | xlsNbWorksheet | Returns the number of worksheets found in an XLS file. | xlsOpen | Opens an Excel file (xls or xlsx files). | xlsRecalculateAll | Recalculates all formulas in an Excel (XLSX) document. | xlsSave | Saves an XLS document. | xlsUnmergeCell | Unmerges a range of cells. | xlsVersion | Returns the Excel version that was used to save the file. |
Related Examples:
|
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.
|
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|