ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Standard functions / XLS file functions
  • Opening an XLS file
  • Example for modifying an Excel file via an xlsDocument variable
  • Example for creating an Excel file via an xlsDocument variable
Opening an XLS file
WINDEVWindowsUser code (UMC) The following code is used to open an XLS file. The XLS file to be opened is selected using fSelect.
// Declare the variables
XLSFile is string
XLSFileID is int
// Select the XLS file
XLSFile = fSelect("", "", "Selecting an XLS file", ...
"XLS file" + TAB + "*.XLS", "XLS", fselOpen + fselExist)
// Open the selected file
XLSFileID = xlsOpen(XLSFile)
IF ErrorOccurred = False THEN
// Processes in the XLS file
...
// End of processes in the XLS file
ELSE
// Display an error message if the opening was not performed
Error(xlsMsgError(XLSFileID))
END
Example for modifying an Excel file via an xlsDocument variable
// Open the document
MyWorksheet is xlsDocument
FileName is string
FileName = fSelect(fExeDir(), "", ...
"Select a file...", ...
"All files (*.*)" + TAB + "*.*", "*", fselOpen + fselExist)
IF FileName = "" THEN RETURN
MyWorksheet = xlsOpen(FileName, xlsWrite)
 
// Write into the cell (A;25)
MyWorksheet[25,"A"] = "OK"
 
// Save the document
xlsSave(MyWorksheet)
 
// Close document
xlsClose(MyWorksheet)
Example for creating an Excel file via an xlsDocument variable
// Declare an Excel Document variable
docExcel is xlsDocument
 
// Create the worksheet
xlsAddWorksheet(docExcel, "Worksheet 1", 1)
docExcel..Worksheet = 1
 
// Modify the worksheet
docExcel..Row[1]..Cell[1] = "...."
 
// Etc...
 
// Save the file
sFileName is string = fExeDir() + ["\"] + "ExcelFile.xls"
xlsSave(docExcel, sFileName)
 
// Close the file
xlsClose(docExcel)
 
// Display in Excel
Multitask(50)
ShellExecute(sFileName)
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