PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
This page concerns the 270056D version of WINDEV 27. Update your version.
  • In this lesson you will learn the following concepts
  • Overview
  • Handling text or CSV files
  • Overview
  • Practical example
  • Handling directories
  • Practical example
  • Handling XML files
  • Overview
  • Practical example
  • Handling XLS files
  • Practical example
Lesson 7.3. Handling external files
In this lesson you will learn the following concepts
  • Handling text files (CSV, etc.).
  • Handling directories.
  • Handling XML files.
  • Handling XLS files.
Lesson duration

Estimated time: 20 mn
Previous LessonTable of contentsNext Lesson
Overview
WINDEV allows you to easily handle the most common data formats:
  • text files (INI, CSV, etc.),
  • XML files,
  • XLS files, ...
Several families of WLanguage functions can be used to read and create these files. This allows you to easily read data generated by another software in your WINDEV applications or create files that require a specific formatting.
Furthermore, you can use multiple WLanguage functions to handle the directories containing the files.
In this chapter, we will focus on:
  • Text files (text files, INI files and CSV files),
  • XML files,
  • XLS files,
  • the management of directories.
Handling text or CSV files

Overview

External files are also called text files or files with direct access. These types of files usually contain text but they can also contain binary information such as images, sounds, etc.
In this lesson as in the entire WINDEV documentation, this will be referred to as external files.
WINDEV allows you to handle external files through programming. The WLanguage functions allow you to create, read and handle external files. All functions can easily be identified: they all start with the letter "f".
The notion of "record" does not necessarily exist in an external file. To handle an external file, you must know its structure, i.e. how the data is organized inside the file.
CSV files are text files that use a specific structure. Therefore, they can be handled like text files.
The .INI files are also text files that use a specific structure. To handle them, WINDEV includes two specific functions: INIRead and INIWrite.

Practical example

  • Open the unit example named "Handling text files".
  • Test the "WIN_Text_File" window. This window groups the different operations that can be performed on the external files with WINDEV.
    Handling text files
The different buttons in the window allow you to:
  • Create a text file.
  • Read and write to a text file.
  • Handle existing files (copy, delete, read information, etc.).
  • Copy a text file.
For more details on external file handling functions, see Functions for handling directories and external files.
Handling directories
WLanguage includes multiple functions to handle directories and files.

Practical example

  • Open the "Handling directories" unit example and test the corresponding window.
  • This window groups the operations that can be performed on disks and directories:
    • create a directory,
    • get the current directory,
    • check the existence of a directory,
    • list directories,
    • copy and delete directories, etc.
For more details on directory handling functions, see Functions for handling directories and external files.
Handling XML files

Overview

XML (Extensible Markup Language) is a markup language, which means a language that presents information enclosed in tags. XML is a metalanguage used to invent new tags to isolate essential information a Web page may contain.
XML structures a document containing data. An HFSQL data file containing several items and records can be exported to an XML file for example (XML* functions).
WINDEV supports:
The XML file can also be handled in the code editor directly. To do so:
  1. Drag the XML file from the file explorer and drop it onto the "Project explorer" pane, in the "External descriptions" folder.
  2. Drag the XML file from the "Project explorer" pane and drop it onto the code editor. The xmlDocument variable is automatically created as follows:
    <Variable name> is xmlDocument, description =  <Document name>
  3. You can directly access the variable nodes by their names. These names are automatically proposed by the automatic completion mechanism of the code editor.

Practical example

  • Open the unit example named "Reading and writing in XML format".
  • Test the "WIN_HandleXML" window. This window is used to:
    • create an XML file. This file is created by the XML functions.
      Reading and writing in XML format
    • read an XML file.
  • See the code associated with each button.

Note

We won't go into details about all the features of the XML functions.
For more details, see XML functions.
Handling XLS files
To handle Excel files, WINDEV inclides:
  • xlsXXX functions. These functions allow you to read the data in the different worksheets of an Excel file.
  • advanced variables (xlsDocument, xlsRow, xlsColumn, xlsCell).

Practical example

Let's quickly test these functions.
  • To test the xlsXXX functions, open the unit example named "The Excel functions".
  • Test the "WIN_XLSFunction" window. This window is used to:
    • import data from an Excel worksheet.
    • export data from a Table control to Excel.
    Go back to the editor to see the code of the different Button controls in the window.
  • To test the advanced variables, open the unit example named "XLS type".
  • Test the "WIN_XLS_Type" window.
    Excel functions
  • Go back to the editor to see the code of the different Button controls in the window.

Note

We won't go into details about all the features of the XLS functions and the advanced types.
For more details, see XLS file handling functions.
Previous LessonTable of contentsNext Lesson
Minimum version required
  • Version 27
Comments
Click [Add] to post a comment