ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage functions / Controls, pages and windows / Table functions
  • Use conditions
  • Miscellaneous
  • Printing in an XLS file
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Creates an Excel file with the data from a Table or TreeView Table control.
Remark: This file can be opened by Excel or by OpenOffice Calc (depending on the software installed on the current computer).
Example
WINDEVReports and QueriesUser code (UMC)
sFic is string
// Demande le nom du fichier
sFic = fSelect("", "", "Choisissez le fichier d'exportation", "Fichiers Excel (*.xls) *.xls", "xls", fselCreate + fselExist)
// Si le nom n'a pas Ã©té fourni, abandonne l'export
// Sinon, exporte le contenu du champ Table TABLE_TABLE1
IF sFic <> "" THEN TableToExcel(TABLE_TABLE1, sFic, taNoTitle)
WINDEVReports and QueriesUser code (UMC)
sNomFichier is string
...
// Génère un fichier Excel sur le bureau
sFichierID is string
sFichierID = CompleteDir(SysDir(srDesktop) + fSep() + sNomFichier)
IF sFichierID <> "" THEN
IF TableToExcel(TABLE_Produit, sFichierID, taNoTitle) = False THEN
Info(ErrorInfo())
ELSE
ToastDisplay("Fichier généré")
END
END
Syntax

Selecting all rows or the first N rows found in the Table or TreeView Table control Hide the details

<Result> = TableToExcel(<Table control> , <XLS file to create> [, <Options> [, <Number of exported rows>]])
<Result>: Boolean
  • True if the file was created,
  • False otherwise. To get more details on the error, use ErrorInfo.
<Table control>: Control name
Name of the control to be used. This control can correspond to:
  • a Table control.
  • a TreeView Table control.
<XLS file to create>: Character strings
Name and full path of Excel file to create. The file is replaced with the new file if it already exists.
<Options>: Optional Integer constant or combination of constants
Configures the XLS file to create.
taColumnDisplayedOrderExports the columns according to the order of columns currently displayed in the control (and not according to the order of columns defined in the editor).
WEBDEV - Server code This constant is not available.
taColumnsTitles
(default value)
The title of the columns is inserted in the file.
taMergeIf the XLS file already exists, merges the existing content with the new content: the formulas, the formatting, ... of existing cells is kept. The existing data is not stored. Only the data of columns and rows found as well in the existing XLS file is kept.
taNoTitleOnly the data is copied to the file.
taNoTotalDoes not export:
  • the rows containing totals, mean and automatic count (these rows are exported by default).
  • WINDEV the rows containing custom calculations (these rows are exported by default).
WEBDEV - Server code This constant is not available.
taSelectedLinesExports the selected rows only (all the rows are exported by default). Does not export the totals.
taWithInvisibleColumnsAlso exports the invisible control columns.
WINDEV The columns defined as non printable and non exportable are exported. These columns are defined:
  • programmatically: VisibleInExportAndPrint property set to False.
  • in the "General" tab of the column description window: "Export and print" set to "Never".
taWithLayoutExports the color and the font used in the control.
<Number of exported rows>: Optional integer
Number of rows to export. Only the rows found between 1 and <Number of exported rows> will be exported.
All rows found in the Table control will be exported if this parameter is not specified.

Selecting the rows found in the Table or TreeView Table control Hide the details

<Result> = TableToExcel(<Table control> , <XLS file to create> [, <Options> [, <Start row> [, <End row> [, <Password>]]]])
<Result>: Boolean
  • True if the file was created,
  • False otherwise. To get more details on the error, use ErrorInfo.
<Table control>: Control name
Name of the control to be used. This control can correspond to:
  • a Table control.
  • a TreeView Table control.
<XLS file to create>: Character strings
Name and full path of Excel file to create. The file is replaced with the new file if it already exists.
<Options>: Optional Integer constant or combination of constants
Configuration of XLS file to create.
taColumnDisplayedOrderExports the columns according to the order of columns currently displayed in the control (and not according to the order of columns defined in the editor).
WEBDEV - Server code This constant is not available.
taMergeIf the XLS file already exists, merges the existing content with the new content: the formulas, the formatting, ... of existing cells is kept.
taNoTitleOnly the data is copied to the file.
taNoTotalDoes not export:
  • the rows containing totals, mean and automatic count (these rows are exported by default).
  • WINDEV the rows containing custom calculations (these rows are exported by default).
WEBDEV - Server code This constant is not available.
taSelectedLinesExports the selected rows only (all the rows are exported by default).
Does not export the totals.
taWithInvisibleColumnsAlso exports the invisible control columns.
WINDEV The columns defined as non printable and non exportable are exported. These columns are defined:
  • programmatically: VisibleInExportAndPrint property set to False.
  • in the "General" tab of the column description window: "Export and print" set to "Never".
taWithLayoutExports the color and the font used in the control.
<Start row>: Optional integer
Number of the row where the export will start. All the control rows will be exported if this parameter and <End row> are not specified.
<End row>: Optional integer
Number of the row where the export will end. All the control rows will be exported if this parameter and <Start row> are not specified.
<Password>: Optional character string
Password of the generated Excel file (only for XLSX files). This password is required to open the generated Excel file.
Remarks

Use conditions

TableToExcel can be used on:
  • Table or TreeView Table controls based on a data file.
  • Table or TreeView Table controls populated programmatically.
  • single-selection or multi-selection controls.

Miscellaneous

  • The Excel files cannot exceed 65536 rows and 256 columns if the extension used is ".xls". This limit can be exceeded by using the ".xlsx" extension in order to create files in Excel 2007 format. Caution: in this case, the former versions of Excel must be equipped with the "Office 2007 compatibility pack", that can be downloaded from the Microsoft site in order to open the generated documents.
  • The created file can be opened by Excel 97 (or later) or by OpenOffice Calc 2 (or later).
  • It is possible to create XLSX files: You just need to specify the extension in the <XLS file to create> parameter.
  • "High-Precision Numeric" columns (38 significant digits) will be exported as exponential numbers.
  • The merge operation performed on the Table control columns is ignored.
  • Unicode columns are exported in Unicode format to Excel.
  • Check Box columns are exported as Check Boxes.
  • RTF columns are exported without formatting.
  • The following elements are not exported into the Excel file:
    • The images,
    • The charts,
    • The bar codes.

Printing in an XLS file

It is possible to print directly in an XLS file:
The created XLS file is configured by iParameterXLS.
Related Examples:
The TableTo functions Unit examples (WINDEV): The TableTo functions
[ + ] Exporting table data with the WLanguage functions.
The following topics are presented in this example:
1/ interfacing with Word and Excel
2/ sending data to the clipboard
3/ generating a text file
This example explains how to export the content of a table to a Word document, an Excel workbook, the clipboard or a text file via the following WLanguage functions: TableToWord, TableToExcel, ToClipboard, TableToText.
Business / UI classification: UI Code
Component: wd300xls.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Tabla a Excel
// Se genera un archivo y se lo ubica en el escritorio y se especifica su nombre
sFileID is string = CompleteDir(SysDir(srDesktop)+fSep())+sNombreArchivo

// Check the creation of the file
IF sFileID <> "" THEN

TableToExcel(TABLE_Productos,sFileID,taNoTitle)
IF ErrorOccurred THEN
Error("No se logro Escribir el archivo")
RETURN
END

info("Archivo Generado con éxito")
ELSE

Error("No se logro Crear el nuevo archivo")
RETURN
END
Mecias SAMUEL
30 Aug. 2022

Last update: 06/27/2023

Send a report | Local help