ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Controls, pages and windows / Spreadsheet functions
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Saves the contents of a Spreadsheet control to a file. The supported formats are:
  • XLSX (Excel workbook),
  • XLSM (Excel macro-enabled workbook),
  • XLTX (Excel template),
  • XLTM (Excel macro-enabled template),
  • New in version 2025
    CSV (csv file).
Example
// Save the current file
PSHEET_Spreadsheet.Save("Workbook1.XLSX")
// Chargement du fichier
TBLR_SansNom1.Charge("test.xlsx")
// Modification du fichier
TBLR_SansNom1["A","1"] = "modifié"
// Sauvegarde sous un autre nom
// Le fichier "text1.xlsx" existe déjà
IF TBLR_SansNom1.Sauve("test1.xlsx") = False THEN
	// Avant la version 200051, le fichier xlsx existant est écrasé. 
	// A partir de la version 200051, le fichier xlsx existant n'est pas modifié. 
	// La fonction renvoie Faux et une erreur 
	// Pour écraser le fichier, utilisez la constante tblrEcrasementAutorisé
	Error("Fichier non sauvegardé " + ErrorInfo()
ELSE
	Info("Fichier sauvegardé")
END
Syntax
<Result> = <Spreadsheet control>.Save(<File to save> [, <Option> [, <Password>]])
<Result>: Boolean
  • True if the file of Spreadsheet control was saved,
  • False otherwise. ErrorInfo returns more details about the error.
<Spreadsheet control>: Control name
Name of the Spreadsheet control to be used.
<File to save>: Character string
Name and full path of the file where the content of Spreadsheet control will be saved. The file extension defines the backup format. The supported formats are:
  • XLSX (Excel workbook),
  • XLSM (Excel macro-enabled workbook),
  • XLTX (Excel template),
  • XLTM (Excel macro-enabled template),
  • New in version 2025
    CSV (csv file).
    Note: only the current sheet is saved. Only cell values are saved. For example, formulas are not saved, but only their result.
<Option>: Optional Integer constant
File save mode if the file already exists:
0 (or nothing)
(Default behavior)
If the XLSX file already exists and is not open (in the Spreadsheet control or another application), it is not saved.
psheetOverwriteAllowedIf the XLSX file already exists and is not open (in the Spreadsheet control or another application), it is overwritten.
<Password>: Optional string or Secret string
Password to use to protect the XLSX file at opening. This password must be specified to open the XLSX file.
New in version 2025
Secret strings: If you use the secret string vault, the type of secret string used for this parameter must be "ANSI or Unicode string".
To learn more about secret strings and how to use the vault, see Secret string vault.
Remarks
  • To open the ".xlxs" file saved with another application, it must be closed by <Spreadsheet>.Close.
  • The saved file can be reloaded in a Spreadsheet control via <Spreadsheet>.Load and xlsOpen.
  • This function can only be used on a Spreadsheet control found in a window.
  • <Spreadsheet>.Save updates the FilePath property of Spreadsheet control by associating the name of loaded file to the Spreadsheet control.
Related Examples:
The Spreadsheet control Unit examples (WINDEV): The Spreadsheet control
[ + ] Using the Spreadsheet control.
This example explains how to:
- load an xlsx file in a spreadsheet control,
- save the spreadsheet in a file,
- fill the control with data coming from the database,
- insert rows, columns,
- access the cells and handle them (modify their value, their style, ...),
- enter formulas,
- ...
Business / UI classification: UI Code
Component: wd300obj.dll
Minimum version required
  • Version 23
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 05/14/2025

Send a report | Local help