4D Blog

Home Product 4D View Pro: More options to customize your worksheets

4D View Pro: More options to customize your worksheets

May 26, 2020

Product

To create user-friendly documents, you often need to hide a gridline or header, protect certain cells, or simply change the line color to respect the corporate identity. With 4D v18 R3, you can do all this and more with the new VP SET SHEET OPTIONS command.

HDI SheetOptions

Protect a sheet

Protecting a worksheet prevents the cells within it from being edited. By default, all of a 4D View Pro document’s cells are marked as locked. If you want to protect your entire worksheet, you just need to write:

$options:=New object
// Activate protection
$options.isProtected:=True
// Apply protection on the current sheet
VP SET SHEET OPTIONS ("ViewProArea";$options)

If you want to allow users to edit specific cells, you can protect the worksheet and unlock only the cells the user can edit.

As the previous example demonstrated, setting the isProtected option to True protects the entire worksheet. If you want all of the cells protected except the C5:D10 range, simply mark the range as unlocked:

$options:=New object
// Activate protection
$options.isProtected:=True
// Apply protection on the current sheet
VP SET SHEET OPTIONS ("ViewProArea";$options)
// mark cells C5:D10 as 'unlocked'
VP SET CELL STYLE (VP Cells ("ViewProArea";2;4;2;6);New object("locked";False))

The protectionOptions property can be used to specify what you allow a user to change, such as resizing, dragging, inserting or deleting rows and columns, and so on.

Want to protect your document but allow users to resize rows and columns? You can write this:

$options:=New object
// Activate protection
$options.isProtected:=True
$options.protectionOptions:=New object
// Allow user to resize rows
$options.protectionOptions.allowResizeRows=True;
// Allow user to resize columns
$options.protectionOptions.allowResizeColumns=True;
// Apply protection on the current sheet
VP SET SHEET OPTIONS ("ViewProArea";$options)

Change the appearance of your worksheet

Change colors

The VP SET SHEET OPTIONS command also lets you customize the colors of your worksheet’s tabs, frozen lines, grid lines, or a selection’s background and border.

$options:=New object
// Customize color of Sheet 1 tab
$options.sheetTabColor:="Black"
$options.gridline:=New object("color";"Purple")
$options.selectionBackColor:="rgba(255,128,0,0.4)"
// Use rgba() for the transparency. Here : 40% transparency
$options.selectionBorderColor:="Yellow"
$options.frozenlineColor:="Gold"
VP SET SHEET OPTIONS ("ViewProArea";$options;0)
 
// Customize color of Sheet 2 tab
$options.sheetTabColor:="red"
VP SET SHEET OPTIONS ("ViewProArea";$options;1)
 
// Customize color of Sheet 3 tab
$options.sheetTabColor:="blue"
VP SET SHEET OPTIONS ("ViewProArea";$options;2)

Here’s the result:

Hide elements

VP SET SHEET OPTIONS command even lets you manage the visibility of the worksheet’s grid lines and row and column headers:

$options:=New object
$options.gridline:=New object()
$options.gridline.showVerticalGridline:=False
$options.gridline.showHorizontalGridline:=False
$options.rowHeaderVisible:=False
$options.colHeaderVisible:=False
VP SET SHEET OPTIONS ("ViewProArea";$options)

Take a look at the result:

blank

workSheet Area Offset

Because borders are drawn on the outside of cells, you can use the sheetAreaOffset property to make sure that the whole worksheet is rendered:

$options:=New object
$options.sheetAreaOffset:=New object
$options.sheetAreaOffset.left:=2
$options.sheetAreaOffset.top:=2
VP SET SHEET OPTIONS ("ViewProArea";$options)

blank

Find more information on the doc center and don’t forget to try this command with the HDI above. 

Discuss

Tags 4D View Pro, Spreadsheet, v18 R3, v19, Workbook

Latest related posts

  • June 16, 2025

    Generate, share and use web sessions One-Time Passcodes (OTP)

  • May 20, 2025

    Automatic Refresh of OEM Build Licenses

  • May 16, 2025

    New class to handle incoming TCP connections

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

  • 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-Analyzer 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R8 20 R9 Administration Authentication Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Formula Listbox Logs Mail Microsoft 365 Network Objects ORDA PDF Pictures Preemptive Programming Qodly Studio REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor

Tags

4D-Analyzer 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R8 20 R9 Administration Authentication Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Formula Listbox Logs Mail Microsoft 365 Network Objects ORDA PDF Pictures Preemptive Programming Qodly Studio 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