Spread.NET 13 is now available. This release features many enhancements to Microsoft Excel-compatibility and several new features and enhancements.
Spread.NET 13 WinForms features a new enhanced shapes engine that is 100% compatible with Microsoft Excel®.
To use the new Enhanced Shape Engine, you must first enable it either using the Property Grid:
Figure 1 - Enable FpSpread.Features.EnhancedShapesEngine using property grid
Or you can enable the Enhanced Shape Engine engine in code:
[C#]
Enable Enhanced Shaped Engine in code
fpSpread1.Features.EnhancedShapeEngine = true;
[VB]
Enable Enhanced Shape Engine in code
fpSpread1.Features.EnhancedShapeEngine = True
All the Excel shapes are supported:
Figure 2 - Enhanced Shapes
The Enhanced Shape Engine supports multiple selection, grouping, adjustments, and connection points, and can be used to create diagrams, cell call-outs, and flowcharts:
Figure 3 - Flowchart example created in Spread
Above is a sample flowchart created in code using the new Enhanced Shape Engine API, which mirrors the VSTO API. The flowchart comes from one of my favorite web comics.
Enhanced Shapes Engine can be used to create a rich interactive interface such as this car insurance claim example:
Figure 4 - Car Insurance Claim created using shapes
This example was created using Microsoft Excel® to port the code from an identical SpreadJS blog and demo sample, then using VBA to implement the logic to handle the clicks on the shapes.
Spread.NET 13 WinForms can import this macro-enabled XLSM workbook using the Document Caching feature and keep the embedded VBA in memory for later export. The enhanced shapes support the IShape.Action event to handle shape-clicks and implement the identical logic as the VBA in C# or VB.NET code. You can find this new demo sample in the Spread.NET 13 WinForms Control Explorer under Showcase demos.
Enhanced shape property bindings supports binding the AutoShapeType, TextEffect, Fill, Line, Top, Left, Height, and Width properties to particular cells, enabling some very rich user interface possibilities. Cell formulas can update any of those properties dynamically based on calculations.
In the example above showing the car insurance claim, the shape properties are bound to values in Sheet2:
Figure 5 - Shape property bindings for car insurance claim sample
Binding the shape properties in code is easy:
[C#]
Bind Shape Properties
IWorkbook workbook = fpSpread1.AsWorkbook();
IShapes shapes = workbook.Worksheets[0].Shapes;
// bind shape properties to cells
shapes["Front"].Bindings.Add("Left", "Sheet2!B2");
shapes["Front"].Bindings.Add("Top", "Sheet2!C2");
shapes["Front"].Bindings.Add("Width", "Sheet2!D2");
shapes["Front"].Bindings.Add("Height", "Sheet2!E2");
shapes["Front"].Bindings.Add("Line", "Sheet2!F2");
[VB]
Bind Shape Properties
Dim workbook As IWorkbook = fpSpread1.AsWorkbook
Dim shapes As IShapes = workbook.Worksheets(0).Shapes
' bind shape properties to cells
shapes("Front").Bindings.Add("Left", "Sheet2!B2")
shapes("Front").Bindings.Add("Top", "Sheet2!C2")
shapes(Front").Bindings.Add("Width", "Sheet2!D2")
shapes("Front").Bindings.Add("Height", "Sheet2!E2")
shapes("Front").Bindings.Add("Line", "Sheet2!F2")
Spread.NET 13 WinForms features new enhanced rich copy/paste between Microsoft Excel® and Spread. To enable this new functionality, you must set a property in the Property Grid:
Figure 6 - Enable FpSpread.Features.RichClipboard using property grid
Or you can set this property in code:
[C#]
Enable FpSpread.Features.RichClipboard in code
fpSpread1.Features.RichClipboard = true;
[VB]
Enable FpSpread.Features.RichClipboard in code
fpSpread1.Features.RichClipboard = True
With RichClipboard enabled, you can:
Spread.NET 13 WinForms features new slicers for table filtering, including import and export of slicers in XLSX files and all built-in slicer styles supported by Microsoft Excel®.
Slicers can be applied to the spreadsheet using the Spread Designer tool:
Figure 7 - Insert Slicer in Spread Designer
The Spread Designer will show the Insert Slicer dialog:
Figure 8 - Insert Slicer Dialog
You can also show the Insert Slicer dialog in code:
[C#]
Show Insert Slicer Dialog in code
SlicerInsertForm dlg = new SlicerInsertForm(table, new Point(25, 25));
dlg.ShowDialog(this);
[VB] Show Insert Slicer dialog in code
Dim dlg As SlicerInsertForm = new SlicerInsertForm(table, new Point(25, 25))
dlg.ShowDialog(Me)
The Slicer object shows the unique values in the table column and can quickly filter the table to show only the rows with that value in the table column:
Figure 9 - Slicer created for Country table column
You can create rich interfaces and dashboards by combining Slicers with Charts – the Slicers and Charts do not need to be on the same Worksheet as the Table for the Slicer, so you can create the Chart to hide the Series that are not visible, and user's changes to the Slicer will update the Chart.
Spread.NET 13 WinForms features support for a new type of custom calculation function called a VisualFunction. You can define a custom formula function that draws content in the cell or applies formatting.
Using this feature to draw custom content in the cell is similar to creating a custom Sparkline, but much easier, as this feature integrates with the new Calculation Engine and VisualFunction inherts from the new Function class.
Using this feature to apply a style in the cell is similar to conditional format, but easier, faster, and more powerful, since you can implement custom logic for the condition and avoid the overhead of conditional formats.
For example, you can define a VisualFunction which draws a QR code:
Figure 10 - VisualFunction showing QR code
Referencing a VisualFunction in a formula requires using the prefix "VF." on the name of the VisualFunction, and the function can have customized arguments. The function implementation determines the arguments required for the function and handles drawing the content in the cell based on those arguments specified in the cell formula. In the above example, the VisualFunction QRCODE accepts two arguments, and the formula specifies cells B1 and C1, so the result is a standard QR code encoding the GrapeCity Spread website.
Spread.NET 13 WinForms features enhanced support for the new XLOOKUP and XMATCH functions, which are at this time still only available in the Office Insiders builds of Microsoft Excel®.
These new functions are much better than the old LOOKUP, VLOOKUP, HLOOKUP, and MATCH for several reasons:
These new functions do not require enabling the Dynamic Array feature, but it is necessary to enable that feature when using the enhanced _search_mode 0 - All_ which returns all matching items if you want those values to spill to adjacent cells:
Figure 11 - Enabling Dynamic Array in ribbon bar Formulas tab
You can also enable the Dynamic Array feature in code:
[C#] Enable Dynamic Arrays in code
fpSpread1.AsWorkbook().WorkbookSet.CalculationEngine.CalcFeatures = GrapeCity.Spreadsheet.CalcFeatures.DynamicArray;
[VB] Enable Dynamic Arrays in code
fpSpread1.AsWorkbook().WorkbookSet.CalculationEngine.CalcFeatures = GrapeCity.Spreadsheet.CalcFeatures.DynamicArray
Spread.NET 13 WinForms features automatic formatting of formula values like Microsoft Excel®. You can type a formula using the DATE function and the value will automatically format as date, or type a formula which references a cell formatted as currency, accounting, or any other cell format, and that format will also get applied automatically on the value in the formula cell. You can still apply a new cell format to replace the automatic format if you want to show a different format in the cell.
The automatic format is based on the cell format in the final referenced cell in the formula which contains the value. For example, if you type a value like 1500.65 into cell A1 and then apply a Currency format, then the cell shows $1500.65. If you then type a formula =A1 in cell A2, then the value in cell A2 will also show the Currency format.
If you open the Cell Format dialog for cell A2 and change the cell format in that cell to Accounting, then the value in cell A2 will update to show Accounting format instead of Currency format.
If you then type the formula =A1 in cell B1 and then drag-fill the formula down to cell B2, then both of those cells will show the value $1500.65 formatting as Currency, because Currency format is the format that is applied to the cell at the end of the reference chain, A1:
Figure 12 - Automatic formatting of formula values based on original cell format
Please note that for backwards compatibility, this feature is not enabled by default and must be explicitly enabled in the application in code using IWorkbook.Features:
[C#]
Enable IWorkbook.Features.AutoFormatting in code
workbook.Features.AutoFormatting = True
[VB]
Enable IWorkbook.Features.AutoFormatting in code
workbook.Features.AutoFormatting = True
Spread.NET 13 WinForms features a simple enhancement which many customers have requested – dynamically-sized row headers that adjust automatically to show the row numbers as you scroll down the sheet:
Figures 13-15 Automatic adjustment of row header width while scrolling down
This feature allows the user to scroll down very large spreadsheets and see the row index numbers.
Spread.NET 13 WinForms now supports setting a background image for the workbook in the IWorkbook interface using the new overloaded method SetBackgroundPicture:
[C#] IWorksheet.SetBackgroundImage method overloads
void IWorksheet.SetBackgroundPicture(string filename, [string contentType = null])
void IWorksheet.SetBackgroundPicture(System.IO.Stream imageStream, string contentType)
[VB] IWorksheet.SetBackgroundImage method overloads
Sub SetBackgroundPicture(filename As String, Optional contentType As String = Nothing)
Sub SetBackgroundPicture(imageStream As System.IO.Stream, contentType As String)
The picture must be loaded from a file or stream. and the content type specified must be:
Figure 16 - Editing formula inserts structured references to table cells
When editing a formula using the FormulaTextBox control, you can select a table cell, table column, or entire table and a structured reference will automatically be inserted when applicable. For entire table column references and entire table references, this is always applicable, but for table cell references to use the '[@ColumnName]' syntax, the formula cell must be in the same row as the table cell – if the table cell is in a different row, then a regular cell reference must be used instead.
Spread.NET 13 WinForms features a new event BeforeRightClick which fires when the end-user right-clicks inside the spreadsheet, before any processing by the control to handle showing the context menu. You can implement code in the event handler to use the FpSpread.HitTest method to determine the clicked location and object under the cursor, and override the default behavior to show a custom context menu, or modify the default context menu, or attach event handlers to the default context menu – this new event introduces lots of new flexibility for handling right-clicks in the spreadsheet.
The new Spread.NET 13 WinForms Control Explorer has some exciting new samples to demonstrate features and common use cases. All samples are available in both C# and VB and are included in the setup installer: