AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Ayuda / WLanguage / Funciones WLanguage / Funciones estándar / Funciones de archivos XLS
  • 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
WINDEVWindowsCódigo de Usuario (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)
Versión mínima requerida
  • Versión 9
Esta página también está disponible para…
Comentarios
Haga clic en [Agregar] para publicar un comentario

Última modificación: 27/05/2022

Señalar un error o enviar una sugerencia | Ayuda local