AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Ayuda / WLanguage / Funciones WLanguage / Funciones estándar / Funciones de archivos XLS
  • Reading an XLS file
xlsDocument (Example)
Reading an XLS file
The following code is used to browse all the cells found in the different worksheets of an XLS file.
// File name
sNameExcelFile is string
 
// The file to open is selected by the user
sNameExcelFile = fSelect("", sNameExcelFile, "Specify the Excel file to read", ...
"Excel workbook (*.XLS)" + TAB + "*.XLS" + CR + "All files (*.*)" + TAB + "*.*", ...
"*.XLS", fselOpen + fselExist)
 
// Cancelation?
IF sNameExcelFile = "" THEN RETURN
 
// Opens the file
xlsdoc is xlsDocument
xlsdoc = xlsOpen(sNameExcelFile)
IF ErrorOccurred THEN
Error("Failure opening the Excel workbook", ErrorInfo())
RETURN
END
 
nWorksheetNum is int
nNbWorksheetRows is int
nNbWorksheetColumns is int
nRowNum is int
nColumnNum is int
 
// For each worksheet of the workbook
FOR nWorksheetNum = 1 _TO_ xlsdoc.NumberWorksheet
// Position on the specified worksheet
xlsdoc.Worksheet = nWorksheetNum
// Number of rows
nNbWorksheetRows = xlsdoc.NumberRow
nNbWorksheetColumns = xlsdoc.NumberColumn
// Progress bar
PROGBAR_ProgBar = 0
PROGBAR_ProgBar.MaxValue = nNbWorksheetRows
FOR nRowNum = 1 _TO_ nNbWorksheetRows
PROGBAR_ProgBar++
FOR nColumnNum = 1 _TO_ nNbWorksheetColumns
Trace("Row " + nRowNum + ", Column " + nColumnNum + "=" + ..
xlsdoc.Cell[nRowNum, nColumnNum])
END
END
END
 
Info("Reading completed")
Versión mínima requerida
  • Versión 17
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