PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Use conditions
  • Various
  • Printing in an XLS file
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Creates an Excel file from the data found in a Table or TreeView Table control .
Note: This file can be opened by Excel or by OpenOffice Calc (depending on the software installed on the current computer).
Versions 16 and later
WINDEVLinux This function is now available for the WINDEV applications in Linux.
New in version 16
WINDEVLinux This function is now available for the WINDEV applications in Linux.
WINDEVLinux This function is now available for the WINDEV applications in Linux.
Versions 18 and later
WEBDEV - Server code This function can now be used to handle the treeview tables in the WEBDEV sites.
New in version 18
WEBDEV - Server code This function can now be used to handle the treeview tables in the WEBDEV sites.
WEBDEV - Server code This function can now be used to handle the treeview tables in the WEBDEV sites.
Versions 23 and later
WEBDEV - Server codeLinux This function is now available for the WEBDEV sites in Linux.
New in version 23
WEBDEV - Server codeLinux This function is now available for the WEBDEV sites in Linux.
WEBDEV - Server codeLinux This function is now available for the WEBDEV sites in Linux.
Example
WINDEVReports and QueriesUser code (UMC)
sFile is string
// Asks for the file name
sFile = fSelect("", "", "Choose the export file", ...
"Excel files (*.xls) *.xls", "xls", fselCreate + fselExist)
// If the name was not specified, cancels the export
// Otherwise, exports the content of TABLE_TABLE1
IF sFile <> "" THEN TableToWord(TABLE_TABLE1, sFile, taNoTitle)
Syntax

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

<Result> = TableToExcel(<Table Control> , <Name of XLS File> [, <Options> [, <Number of Exported Rows>]])
<Result>: Boolean
  • True if the file was created,
  • False otherwise. To find out the error details, use ErrorInfo.
<Table Control>: Control name
Name of control to use. This control can correspond to:
  • a Table control.
  • a TreeView Table control.
<Name of XLS File>: Character string (with quotes)
Name and full path of Excel file to create. The file is replaced by the new file if it already exists.
<Options>: Optional Integer constant
Configures the XLS file to create.
taWithInvisibleColumnsAlso exports the invisible control columns.
Versions 22 and later
WINDEV The columns defined as non printable and non exportable are exported. These columns are defined:
  • by programming: ..VisibleInExportAndPrint set to False.
  • in the "General" tab of the description window of columns: "Export and print" to "Never".
New in version 22
WINDEV The columns defined as non printable and non exportable are exported. These columns are defined:
  • by programming: ..VisibleInExportAndPrint set to False.
  • in the "General" tab of the description window of columns: "Export and print" to "Never".
WINDEV The columns defined as non printable and non exportable are exported. These columns are defined:
  • by programming: ..VisibleInExportAndPrint set to False.
  • in the "General" tab of the description window of columns: "Export and print" to "Never".
taWithLayoutExports the color and the font used in the control.
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. The existing data is not stored. Only the data of columns and rows found as well in the existing XLS file is kept.
taSelectedLinesExports the selected rows only (all the rows are exported by default). Does not export the totals.
taNoTitleOnly the data is copied into the file.
taNoTotalDoes not export:
  • the rows containing totals, mean and automatic count (these rows are exported by default).
  • Versions 22 and later
    WINDEV the rows containing custom calculations (these rows are exported by default).
    New in version 22
    WINDEV the rows containing custom calculations (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.
taColumnsTitles
(default value)
The title of columns is inserted into the file.
<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> , <Name of XLS File> [, <Options> [, <Start Row> [, <End Row>]]])
<Result>: Boolean
  • True if the file was created,
  • False otherwise. To find out the error details, use ErrorInfo.
<Table Control>: Control name
Name of control to use. This control can correspond to:
  • a Table control.
  • a TreeView Table control.
<Name of XLS File>: Character string (with quotes)
Name and full path of Excel file to create. The file is replaced by the new file if it already exists.
<Options>: Optional Integer constant
Configuration of XLS file to create.
taWithInvisibleColumnsAlso exports the invisible control columns.
Versions 22 and later
WINDEV The columns defined as non printable and non exportable are exported. These columns are defined:
  • by programming: ..VisibleInExportAndPrint set to False.
  • in the "General" tab of the description window of columns: "Export and print" to "Never".
New in version 22
WINDEV The columns defined as non printable and non exportable are exported. These columns are defined:
  • by programming: ..VisibleInExportAndPrint set to False.
  • in the "General" tab of the description window of columns: "Export and print" to "Never".
WINDEV The columns defined as non printable and non exportable are exported. These columns are defined:
  • by programming: ..VisibleInExportAndPrint set to False.
  • in the "General" tab of the description window of columns: "Export and print" to "Never".
taWithLayoutExports the color and the font used in the control.
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.
taSelectedLinesExports the selected rows only (all the rows are exported by default).
Does not export the totals.
taNoTitleOnly the data is copied into the file.
taNoTotalDoes not export:
  • the rows containing totals, mean and automatic count (these rows are exported by default).
  • Versions 22 and later
    WINDEV the rows containing custom calculations (these rows are exported by default).
    New in version 22
    WINDEV the rows containing custom calculations (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.
<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.
Remarks

Use conditions

TableToExcel can be used on:
  • a browsing or memory control.
  • a single-selection or multi-selection control.

Various

  • 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).
  • The "High-Precision Numeric" columns (38 significant digits) will be exported as exponential numbers.
  • The merge operation performed on the Table control columns is ignored.
  • The columns in Unicode format are exported in Unicode format into Excel.
  • The Check Box columns are exported as check boxes.
  • The following elements are not exported into the Excel file:
    • The images,
    • The charts,
    • The bar codes.

Printing in an XLS file

A print can be directly performed in an XLS file by iPreview or iDestination or from the print preview. 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.
Components
WINDEVWEBDEV - Server codeReports and Queries wd230xls.dll
Linux wd230xls.so
Minimum required version
  • Version 9
This page is also available for…
Comments
Exemplo Ler Tabela e Exportar Excel
s_path is string=CompleteDir(fExeDir())
// s_path=ComplèteRep(fRepExe()) // Em frances
TableToExcel(TABLE_pedido,s_path+"nome_excel.xls")
//TableVersExcel(TABLE_pedido,s_path+"nome_excel.xls") // em frances
ShellExecute(s_path+"nome_excel.xls")

//Blog com Video e Exemplo
http://windevdesenvolvimento.blogspot.com.br/2016/02/curso-windev-excel-002-ler-tabela-e.html
De matos AMARILDO
Feb. 02 2016