4D Blog

Home Product Work with .xlsx documents using 4D View Pro

Work with .xlsx documents using 4D View Pro

October 22, 2018

Product

Do you need to open a Microsoft Excel document directly in your 4D View Pro area, or convert a 4D View Pro document to Microsoft Excel format to send it to a customer? It’s now possible! Thanks to this feature, your 4D business applications have taken a further step towards better compatibility with the MS Office environment.

To do this, the existing 4D View Pro commands, VP IMPORT DOCUMENT and VP EXPORT DOCUMENT, have been enhanced so that they now support files using the .xlsx extension. Just pass your file path to the commands, and you’re all set!

This video shows you how simple it is to open and save an Excel file with a 4D View Pro area. Check it out!

To see this new feature in action, download our database example:

 4DVP Export Excel Example

code examples

These commands are very simple to use, as you can see in the following code:

$areaName:="ViewProArea"
// File name with an .xslx extension
$filePath:="c:\\tmp\\convertedfile.xlsx"
 
VP IMPORT DOCUMENT ($areaName;$filePath)

Because the import and export are asynchronous, you can pass an optional formula which will be called once the import or export is finished. The New formula command allows assigning an expression or method as formula to an object. For more information about this new command, take a look at this blog post.

In the following example, the formula is a method which sends an email once the file is created.

$areaName:="ViewProArea"
$filePath:="c:\\tmp\\convertedfile.xlsx"
$params:=New object
// Formula called when the export is finished
$params.formula:=New formula(AfterExport )
// Specific parameters
$params.email:=New object("address";$user.emailAddress;"name";$user.name)
VP EXPORT DOCUMENT ($areaName;$filePath;$params)

The AfterExport method takes the three parameters passed to VP EXPORT DOCUMENT with an additional parameter for the error status:

$areaName:=$1 // Area name passed to VP EXPORT DOCUMENT
$filePath:=$2 // Filepath passed to VP EXPORT DOCUMENT
$params:=$3 // Optional object passed to VP EXPORT DOCUMENT
$status:=$4 // Error status
If ($status.success=False)
   ALERT($status.errorMessage)
Else
   // Method which sends email with attached file
   SendEmail($params.email;$filePath)
End if

If you need to pass some specific parameters to the callback method, just add them in your $param object. The example above sends an email when the document is ready, so we pass the email information to the callback method with an email object added to the $params object.

Discuss

Tags 4D View Pro, Document creation, Excel, Export, Import, Spreadsheet, v17 R3, v18

Latest related posts

  • November 14, 2025

    Event Report in 4D Qodly Pro: See Every Interactions at a Glance

  • November 14, 2025

    4D Qodly Pro: Page Zoom Controls

  • November 13, 2025

    macOS Tahoe, Windows 11, which operating systems for 4D 20 and 21?

Fabrice Mainguené
Fabrice Mainguené
• Product Owner •Fabrice Mainguené joined 4D Program team in November, 2016. As a Product Owner, he is in charge of writing the user stories then translating it to functional specifications. His role is also to make sure that the feature implementation delivered is meeting the customer need.After obtaining a Bachelor degree in Computer Science at CNAM, Fabrice joined a small software publishing company as a Windev developer. Then he worked for different companies in industry and trade areas as a Windev and web developer as well as technical advisor on new features.
  • Deutsch
  • Français
  • English
  • Português
  • Čeština
  • Español
  • Italiano
  • 日本語

Categories

Browse categories

  • AI
  • 4D View Pro
  • 4D Write Pro
  • 4D for Mobile
  • Email
  • Development Mode
  • 4D Language
  • ORDA
  • User Interface / GUI
  • Qodly Studio
  • Server
  • Maintenance
  • Deployment
  • 4D Tutorials
  • Generic
  • 4D Summit sessions and other online videos

Tags

4D AIKit 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R10 21 Administration AI Artificial Intelligence Build application Class Client/Server Code editor Collections Compatibility settings Formula Google Listbox Logs Mail Network Objects OpenAI ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor

Tags

4D AIKit 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R10 21 Administration AI Artificial Intelligence Build application Class Client/Server Code editor Collections Compatibility settings Formula Google Listbox Logs Mail Network Objects OpenAI ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor
Subscribe to 4D Newsletter

© 2025 4D SAS - All rights reserved
Terms & Conditions | Legal Notices | Data Policy | Cookie Policy | Contact us | Write for us


Subscribe to 4D Newsletter

* Your privacy is very important to us. Please click here to view our Policy

Contact us

Got a question, suggestion or just want to get in touch with the 4D bloggers? Drop us a line!

* Your privacy is very important to us. Please click here to view our Policy