PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Content of the cells: taking the empty rows and columns into account
  • Managing errors
  • Type of data retrieved
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
xlsData (Function)
In French: xlsDonnée
Retrieves the content of a cell found in an XLS file. The result depends on the opening mode of XLS file:
  • In multi-sheet mode, the data retrieved is found on the worksheet selected by xlsCurrentWorksheet.
  • In compatible mode, the data retrieved is always found on the first worksheet of the workbook.
The performance of this function was improved in version 14.
Note: The content of a cell found in an XLS file can be retrieved if:
  • The XLS file exists.
  • The XLS file is opened.
Versions 16 and later
WINDEVLinux This function is now available for the WINDEV applications in Linux.
WEBDEV - Server codeLinux This function is now available for the WEBDEV sites in Linux.
New in version 16
WINDEVLinux This function is now available for the WINDEV applications in Linux.
WEBDEV - Server codeLinux This function is now available for the WEBDEV sites in Linux.
WINDEVLinux This function is now available for the WINDEV applications in Linux.
WEBDEV - Server codeLinux This function is now available for the WEBDEV sites in Linux.
// Declare the variables
ResData is string
XLSFileID is int

// Open an XLS file
XLSFileID = xlsOpen("C:\MyDirectory\File.XLS")
IF XLSFileID <> -1 THEN
// Retrieve the value of a cell
ResData = xlsData(XLSFileID, 3, 4)
...
END
cMyXLSFile is xlsDocument

cMyXLSFile = xlsOpen(sMyFile, xlsWrite)
IF ErrorOccurred = False THEN
Azz is int = xlsCurrentWorksheet(cMyXLSFile)
Info("Current worksheet in the Excel file: " + Azz)
// Change the worksheet
IF xlsCurrentWorksheet(cMyXLSFile, 2) = True THEN
Info("The current worksheet was modified.")
// Read a cell for test
Info(xlsData(cMyXLSFile, 11, 2))
ELSE
Error("The selected file does not include a second worksheet!")
END
ELSE
Error(ErrorInfo(errFullDetails))
END
xlsClose(cMyXLSFile)
Syntax

Syntax that is using the xlsDocument type Hide the details

<Result> = xlsData(<XLS Document> , <Row Number> , <Column Number> [, <Empty Rows and Columns>])
<Result>: Character string
  • Content of specified cell.
  • If the cell content corresponds to an empty string (""), this may correspond to an error. In this case, the ErrorOccurred variable is set to True and xlsMsgError returns the error details.
<XLS Document>: xlsDocument variable
Name of xlsDocument variable to use.
<Row Number>: Integer
Number of the row for the cell to read.
<Column Number>: Integer
Number of the column for the cell to read.
<Empty Rows and Columns>: Optional boolean
Defines how the empty rows and columns will be taken into account:
True
(by default)
The empty rows and columns are ignored.
FalseThe empty rows and columns are taken into account.

Syntax kept for backward compatibility with version 12 Hide the details

<Result> = xlsData(<Identifier of XLS File> , <Row Number> , <Column Number> [, <Empty Rows and Columns>])
<Result>: Character string
  • Content of specified cell.
  • If the cell content corresponds to an empty string (""), this may correspond to an error. In this case, the ErrorOccurred variable is set to True and xlsMsgError returns the error details.
Note: If the Excel file was opened in compatible mode, the content of the cell cannot exceed 255 characters.
<Identifier of XLS File>: Integer
Identifier of XLS file to handle, returned by xlsOpen.
<Row Number>: Integer
Number of the row for the cell to read.
<Column Number>: Integer
Number of the column for the cell to read.
<Empty Rows and Columns>: Optional boolean
Defines how the empty rows and columns will be taken into account:
True
(by default)
The empty rows and columns are ignored.
FalseThe empty rows and columns are taken into account.
Remarks

Content of the cells: taking the empty rows and columns into account

The empty rows and columns can be taken into account or not. For example:
xlsData(XLSFileID, 2, 3, True)
// Returns the content of D2 cell: "23"
xlsData(XLSFileID, 2, 3, False)
// Returns the content of C2 cell: ""
In this example, the column C (that is entirely empty) can be taken into account or not.

Managing errors

If an error occurs, xlsData returns an empty string (""). To find out the error details, use xlsMsgError or ErrorInfo associated with the errMessage constant.
xlsData generates an error in the following cases:
  • The specified row and/or column is empty.
  • The specified XLS file does not exist.
  • The specified XLS file is not opened.

Type of data retrieved

xlsData returns a string, regardless of the cell format defined in Excel.
Caution: The "High-precision numeric" type is not supported by Excel: the value of the numeric that is retrieved will be truncated.
If the content of the specified cell has the following type:The result is converted into:
NumericString
DateString in DD/MM/YYYY format
TimeString in HH:MM:SS format
Components
WINDEVWEBDEV - Server codeReports and Queries wd230xls.dll
Linux wd230xls.so
Minimum required version
  • Version 9
This page is also available for…
Comments
Exemplo Ler Excel
n_abre_excel is int=xlsOpen("nome_excel.xls")
n_numero_linhas is int=xlsNbRow(n_abre_excel)
n_contador is int=0
FOR n_contador = 2 TO n_numero_linhas
HReset(nota_rps_servico)
s_codigo_municipio is string=xlsData(n_abre_excel,n_contador,3)
nota_rps_servico.codigo_municipio=s_codigo_municipio
HAdd(nota_rps_servico)
END
Info("Final da Gravacao")
//-----------------------------------------------------------
//Blog com Video e Exemplo
http://windevdesenvolvimento.blogspot.com.br/2016/01/curso-windev-excel-001-ler-planilha.html
De matos AMARILDO
Feb. 02 2016