PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • 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 open is selected with 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
// Opening 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"

// Saving the document
xlsSave(MyWorksheet)

// Close the 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 required version
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment