Quantcast
Channel: Spread Help » WinForms
Viewing all 38 articles
Browse latest View live

Spread Windows Forms and Renderers

$
0
0

You can customize renderers in Spread Windows Forms. The renderers are used in headers, corners, cells, and other areas. You can also customize the renderers used to create the styles in Spread Windows Forms. This can be useful if you want to create a specific style for your application.

The default style uses the ColumnHeaderDefaultEnhanced, CornerDefaultEnhanced, CornerFooterDefaultEnhanced, FilterBarDefaultEnhanced, and RowHeaderDefaultEnhanced fields.

The Office2013 or Office2016 style uses the FlatCornerHeaderRenderer, FlatColumnHeaderRenderer, FlatRowHeaderRenderer, FlatScrollBarRenderer, and FlatFocusIndicatorRenderer classes.

The Office2007 style uses the EnhancedCornerRenderer, EnhancedFocusIndicatorRenderer, EnhancedColumnHeaderRenderer, EnhancedScrollBarRenderer, and EnhancedRowHeaderRenderer classes.

The classic style uses the ColumnHeaderRenderer, RowHeaderRenderer, and CornerRenderer classes.

The following example customizes the renderers for the column header and footer, row header, corner header, and corner footer.

SpreadWinMainRenderer

Custom Renderers

C#

//header/footer column
fpSpread1.ActiveSheet.ColumnFooter.Visible = true;
fpSpread1.ActiveSheet.ColumnFooter.RowCount = 3;
fpSpread1.ActiveSheet.ColumnHeader.RowCount = 3;
//Create a new renderer and set the renderer properties.
FarPoint.Win.Spread.CellType.FlatColumnHeaderRenderer flatcolumnheader = new FarPoint.Win.Spread.CellType.FlatColumnHeaderRenderer();
flatcolumnheader.NormalBackgroundColor = Color.Orchid;
fpSpread1.ActiveSheet.ColumnHeader.DefaultStyle.Renderer = flatcolumnheader;
FarPoint.Win.Spread.CellType.FlatColumnFooterRenderer flatcolumnfooter = new FarPoint.Win.Spread.CellType.FlatColumnFooterRenderer();
flatcolumnfooter.GridLineNormalColor = Color.Gold;
//Set the renderer for the default style area such as column footer. 
fpSpread1.ActiveSheet.ColumnFooter.DefaultStyle.Renderer = flatcolumnfooter;
//header row
fpSpread1.ActiveSheet.RowHeader.ColumnCount = 3;
FarPoint.Win.Spread.CellType.FlatRowHeaderRenderer flatrowheader = new FarPoint.Win.Spread.CellType.FlatRowHeaderRenderer();
flatrowheader.NormalBackgroundColor = Color.Gray;
fpSpread1.ActiveSheet.RowHeader.DefaultStyle.Renderer = flatrowheader;
//sheet corner header render
FarPoint.Win.Spread.CellType.FlatCornerHeaderRenderer flatcornerheader = new FarPoint.Win.Spread.CellType.FlatCornerHeaderRenderer();
flatcornerheader.NormalTriangleColor = Color.Yellow;
fpSpread1.ActiveSheet.SheetCorner.DefaultStyle.Renderer = flatcornerheader;
//sheet corner footer render
FarPoint.Win.Spread.SpreadSkin a1 = new FarPoint.Win.Spread.SpreadSkin(FarPoint.Win.Spread.DefaultSpreadSkins.Default);
a1.Apply(fpSpread1);
fpSpread1.ActiveSheet.ColumnFooter.Visible = true;
FarPoint.Win.Spread.CellType.FlatCornerFooterRenderer flatcornerfooter = new FarPoint.Win.Spread.CellType.FlatCornerFooterRenderer();
flatcornerfooter.NormalTriangleColor = Color.Aquamarine;
FarPoint.Win.Spread.NamedStyle corner = new FarPoint.Win.Spread.NamedStyle("corner", "HeaderDefault");
corner.BackColor = Color.Olive;
corner.Renderer = flatcornerfooter;
//Apply the new corner styles to the control. 
fpSpread1.NamedStyles.Add(corner);
a1.CornerFooterDefaultStyle = corner;

VB

'header/footer column
FpSpread1.ActiveSheet.ColumnFooter.Visible = True
FpSpread1.ActiveSheet.ColumnFooter.RowCount = 3
FpSpread1.ActiveSheet.ColumnHeader.RowCount = 3
'Create a new renderer and set the renderer properties.
Dim flatcolumnheader As New FarPoint.Win.Spread.CellType.FlatColumnHeaderRenderer()
flatcolumnheader.NormalBackgroundColor = Color.Orchid
FpSpread1.ActiveSheet.ColumnHeader.DefaultStyle.Renderer = flatcolumnheader
Dim flatcolumnfooter As New FarPoint.Win.Spread.CellType.FlatColumnFooterRenderer()
flatcolumnfooter.GridLineNormalColor = Color.Gold
'Set the renderer for the default style area such as column footer.
FpSpread1.ActiveSheet.ColumnFooter.DefaultStyle.Renderer = flatcolumnfooter
'header row
FpSpread1.ActiveSheet.RowHeader.ColumnCount = 3
Dim flatrowheader As New FarPoint.Win.Spread.CellType.FlatRowHeaderRenderer()
flatrowheader.NormalBackgroundColor = Color.Gray
FpSpread1.ActiveSheet.RowHeader.DefaultStyle.Renderer = flatrowheader
'sheet corner header render
Dim flatcornerheader As New FarPoint.Win.Spread.CellType.FlatCornerHeaderRenderer()
flatcornerheader.NormalTriangleColor = Color.Yellow
FpSpread1.ActiveSheet.SheetCorner.DefaultStyle.Renderer = flatcornerheader
'sheet corner footer render
Dim a1 As New FarPoint.Win.Spread.SpreadSkin(FarPoint.Win.Spread.DefaultSpreadSkins.Default)
a1.Apply(FpSpread1)
FpSpread1.ActiveSheet.ColumnFooter.Visible = True
Dim flatcornerfooter As New FarPoint.Win.Spread.CellType.FlatCornerFooterRenderer()
flatcornerfooter.NormalTriangleColor = Color.Aquamarine
Dim corner As New FarPoint.Win.Spread.NamedStyle("corner", "HeaderDefault")
corner.BackColor = Color.Olive
corner.Renderer = flatcornerfooter
'Apply the new corner styles to the control. 
FpSpread1.NamedStyles.Add(corner)
a1.CornerFooterDefaultStyle = corner

You can customize the corner renderer, which draws the sheet corner.

There are two pre-defined corner renderers in Spread.

The default renderer draws the sheet corner with or without the Windows XP style depending on the setting of the system. The enhanced corner renderer always draws the sheet corner with an appearance similar to Microsoft Excel 2007.

This example lists the methods that are used to create a custom corner renderer.

C#

public class MyCornerRenderer : IRenderer {
public Size GetPreferredSize(Graphics g, Size size, Appearance appearance, object value, float zoomFactor)
{
///Your code here
}
public virtual void PaintCell(Graphics g, Rectangle r, Appearance appearance, object value, bool isSelected, bool isLocked, float zoomFactor)
{
///Your code here
}
public virtual void PaintCorner(Graphics g, Rectangle r, Color backColor, Color foreColor, Font f, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment, string s, TextOrientation textOrientation, bool wordWrap, HotkeyPrefix hotkeyPrefix, StringTrimming stringTrim, VisualStyles visualStyles, bool mouseOver, bool rightToLeft, float zoomFactor)
{
///Your code here
}
public bool CanOverflow()
{
///Your code here
}
public bool CanBeOverflown()
{
///Your code here
}
}
// Assign new corner render to draw sheet corner:
fpSpread1.ActiveSheet.SheetCornerStyle.Renderer = new MyCornerRenderer();

This example creates a custom corner renderer.

C#

public class MyCornerRenderer : FarPoint.Win.Spread.CellType.IRenderer
        {
public bool CanOverflow() { return true; }
            public bool CanBeOverflown() { return true; }
            public virtual void PaintCell(Graphics g, Rectangle r, FarPoint.Win.Spread.Appearance appear, object value, bool issel, bool isl, float zoom) {
                g.FillRectangle(Brushes.Green, 0, 0, 30, 30);                
            }
            public Size GetPreferredSize(Graphics g, Size size, FarPoint.Win.Spread.Appearance appear, object value, float zoomFactor)
            {
                size = new Size(10, 10);
                return size;
            }            
        }

        private void Form1_Load(object sender, EventArgs e)
        {      
            fpSpread1.ActiveSheet.SheetCornerStyle.Renderer = new MyCornerRenderer();       
        }

VB

Public Class MyCornerRenderer
        Implements FarPoint.Win.Spread.CellType.IRenderer

        Public Sub PaintCell(g As Graphics, r As Rectangle, appearance As FarPoint.Win.Spread.Appearance, value As Object, isSelected As Boolean, isLocked As Boolean, zoomFactor As Single) Implements FarPoint.Win.Spread.CellType.IRenderer.PaintCell
            g.FillRectangle(Brushes.Green, 0, 0, 30, 30)
        End Sub

        Public Function CanBeOverflown() As Boolean Implements FarPoint.Win.Spread.CellType.IRenderer.CanBeOverflown
            Return True
        End Function

        Public Function CanOverflow() As Boolean Implements FarPoint.Win.Spread.CellType.IRenderer.CanOverflow
            Return True
        End Function

        Public Function GetPreferredSize(g As Graphics, size As Size, appear As FarPoint.Win.Spread.Appearance, value As Object, zoomFactor As Single) As Size Implements FarPoint.Win.Spread.CellType.IRenderer.GetPreferredSize
            size = New Size(10, 10)
            Return size
        End Function
    End Class

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        FpSpread1.ActiveSheet.SheetCornerStyle.Renderer = New MyCornerRenderer()
    End Sub

This example sets colors for the enhanced corner renderer.

SpreadWinCornerR

Corner Renderer

C#

FarPoint.Win.Spread.CellType.EnhancedCornerRenderer rend = new FarPoint.Win.Spread.CellType.EnhancedCornerRenderer(Color.Bisque, Color.Tomato, Color.Maroon);
fpSpread1.ActiveSheet.SheetCorner.DefaultStyle.Renderer = rend;
fpSpread1.ActiveSheet.AllowTableCorner = true;

VB

Dim rend As New FarPoint.Win.Spread.CellType.EnhancedCornerRenderer(Color.Bisque, Color.Tomato, Color.Maroon)
FpSpread1.ActiveSheet.SheetCorner.DefaultStyle.Renderer = rend
FpSpread1.ActiveSheet.AllowTableCorner = True

This example sets the background color for the flat column header renderer.

C#

FarPoint.Win.Spread.CellType.FlatColumnHeaderRenderer flatcolumnheader = new FarPoint.Win.Spread.CellType.FlatColumnHeaderRenderer();
flatcolumnheader.NormalBackgroundColor = Color.Bisque;            
fpSpread1.ActiveSheet.ColumnHeader.DefaultStyle.Renderer = flatcolumnheader;

VB

Dim flatcolumnheader As New FarPoint.Win.Spread.CellType.FlatColumnHeaderRenderer()
flatcolumnheader.NormalBackgroundColor = Color.Bisque
FpSpread1.ActiveSheet.ColumnHeader.DefaultStyle.Renderer = flatcolumnheader

This example creates a custom corner renderer.

SpreadWinPaint

Custom Corner Renderer

C#

public class MyCornerRenderer : FarPoint.Win.Spread.CellType.CornerRenderer
        {                              
            public override void PaintCorner(Graphics g, Rectangle r, Color c, Color back, Font f, FarPoint.Win.HorizontalAlignment halign, FarPoint.Win.VerticalAlignment valign, string s, FarPoint.Win.TextOrientation to, bool wordwrap, System.Drawing.Text.HotkeyPrefix hk, StringTrimming st, FarPoint.Win.VisualStyles vs, bool mouseover, bool rtl, float zf)
            {              
                c = Color.Red;
                back = Color.Aqua;
                f = new Font("Arial", 10);
                halign = FarPoint.Win.HorizontalAlignment.Center;
                hk = System.Drawing.Text.HotkeyPrefix.None;
                valign = FarPoint.Win.VerticalAlignment.Center;
                to = FarPoint.Win.TextOrientation.TextHorizontal;
                wordwrap = true;
                s = "C";
                st = StringTrimming.None;
                vs = FarPoint.Win.VisualStyles.Off;
                mouseover = false;
                rtl = false;
                zf = 0.5F;
                base.PaintCorner(g, r, c, back, f, halign, valign, s, to, wordwrap, hk, st, vs, mouseover, rtl, zf);
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            fpSpread1.ActiveSheet.SheetCornerStyle.Renderer = new MyCornerRenderer();
}

VB

Public Class MyCornerRenderer
        Inherits FarPoint.Win.Spread.CellType.CornerRenderer

        Public Overrides Sub PaintCorner(g As Graphics, r As Rectangle, c As Color, back As Color, f As Font, halign As FarPoint.Win.HorizontalAlignment,
                               valign As FarPoint.Win.VerticalAlignment, s As String, tor As FarPoint.Win.TextOrientation, wordwrap As Boolean, hk As System.Drawing.Text.HotkeyPrefix, sf As StringTrimming, vs As FarPoint.Win.VisualStyles, mouseover As Boolean, rtl As Boolean, zf As Single)

            c = Color.Red
            back = Color.Aqua
            f = New Font("Arial", 10)
            halign = FarPoint.Win.HorizontalAlignment.Center
            hk = System.Drawing.Text.HotkeyPrefix.None
            valign = FarPoint.Win.VerticalAlignment.Center
            tor = FarPoint.Win.TextOrientation.TextHorizontal
            wordwrap = True
            s = "C"
            sf = StringTrimming.None
            vs = FarPoint.Win.VisualStyles.Off
            mouseover = False
            rtl = False
            zf = 0.5F
            MyBase.PaintCorner(g, r, c, back, f, halign, valign, s, tor, wordwrap, hk, sf, vs, mouseover, rtl, zf)
        End Sub
    End Class

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        FpSpread1.ActiveSheet.SheetCornerStyle.Renderer = New MyCornerRenderer()
    End Sub

This example implements the IRenderer interface and creates a custom renderer for the first cell in the spreadsheet.

SpreadWinCellR

Cell Renderer

C#

public static CheckBox ck = new CheckBox();
        class MyRenderer : FarPoint.Win.Spread.CellType.IRenderer
        {
            public bool CanOverflow()
            {
                return true;
            }
            public bool CanBeOverflown()
            {
                return true;
            }
            public Size GetPreferredSize(Graphics g, Size s, FarPoint.Win.Spread.Appearance appr, object value, float zoom)
            {
                s = new Size(50, 50);
                return s;
            }
            public void PaintCell(Graphics g, Rectangle r, FarPoint.Win.Spread.Appearance appr, object value, bool issel, bool islocked,
          float zoom)
            {
                string s;
                ck.CheckState = CheckState.Checked;
                s = ck.CheckState.ToString();
                Font f = new Font("MS Sans Serif", 10);
                appr.BackColor = Color.Red;
                appr.ForeColor = Color.Yellow;
                appr.Font = f;
                Brush b, b1;
                b = new SolidBrush(appr.BackColor);
                b1 = new SolidBrush(appr.ForeColor);
                g.FillRectangle(b, r);
                g.DrawString(s, appr.Font, b1, r);
                b.Dispose();
                b1.Dispose();
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            fpSpread1.ActiveSheet.Cells[0, 0].Renderer = new MyRenderer();
        }

VB

Shared ck As New CheckBox()

    Public Class MyRenderer
        Implements FarPoint.Win.Spread.CellType.IRenderer

        Public Function CanBeOverflown() As Boolean Implements FarPoint.Win.Spread.CellType.IRenderer.CanBeOverflown
            Return True
        End Function

        Public Function CanOverflow() As Boolean Implements FarPoint.Win.Spread.CellType.IRenderer.CanOverflow
            Return True
        End Function

        Public Function GetPreferredSize(ByVal g As Graphics, ByVal s As Size, ByVal appr As FarPoint.Win.Spread.Appearance, ByVal value As Object, ByVal zoom As Single) As Size Implements FarPoint.Win.Spread.CellType.IRenderer.GetPreferredSize
            s = New Size(50, 50)
            Return s
        End Function

        Public Sub PaintCell(ByVal g As Graphics, ByVal r As Rectangle, ByVal appr As FarPoint.Win.Spread.Appearance, ByVal Value As Object, ByVal issel As Boolean, ByVal islocked As Boolean, ByVal zoom As Single) Implements FarPoint.Win.Spread.CellType.IRenderer.PaintCell
            Dim s As String
            ck.CheckState = CheckState.Checked
            s = ck.CheckState.ToString()
            Dim f As New Font("MS Sans Serif", 10)
            appr.BackColor = Color.Red
            appr.ForeColor = Color.Yellow
            appr.Font = f
            Dim b, b1 As Brush
            b = New SolidBrush(appr.BackColor)
            b1 = New SolidBrush(appr.ForeColor)
            g.FillRectangle(b, r)
            g.DrawString(s, appr.Font, b1, r.X, r.Y)
            b.Dispose()
            b1.Dispose()
        End Sub

    End Class
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        FpSpread1.ActiveSheet.Cells(0, 0).Renderer = New MyRenderer()
    End Sub

Spread Windows Forms and Alternating Rows

$
0
0

Some types of spreadsheets, such as ledgers, have different appearances for alternating rows. This makes it easier to see the data. Spread for Windows Forms allows you to set different appearances for multiple alternating rows.

You can set up the alternating rows using an index for the alternating row appearance. The default row appearance is the first alternating row style (or style zero, since the index is zero-based). Set other alternating row appearances to subsequent indexes.

Use the AlternatingRow class to create alternating row styles. The AlternatingRow class has the following properties and methods.

Property Description
BackColor Gets or sets the background color for cells in this alternating row.
Border Gets or sets the border for cells in this alternating row.
CanFocus Gets or sets whether the user can set focus to the cell using the keyboard or mouse for cells in this row.
CellPadding Gets or sets the amount of space, in pixels, to pad cells in the alternating row(s).
CellType Gets or sets the cell type for cells in this alternating row.
Editor Gets or sets the editor for cells in this alternating row.
Font Gets or sets the default font for text in cells in this alternating row.
ForeColor Gets or sets the text color for cells in this alternating row.
Formatter Gets or sets the formatter for cells in this alternating row.
HorizontalAlignment Gets or sets the horizontal alignment for text in the cells in this alternating row.
ImeMode Gets or sets the IME mode for an alternating row.
ImeSentenceMode Gets or sets the IME sentence mode for an alternating row.
Index Gets the index of this alternating row.
InputScope Gets or sets the input scope for an alternating row.
Locked Gets or sets whether cells in this alternating row are marked as locked.
NoteIndicatorColor Gets or sets the default color for the note indicator for cells in this row.
NoteIndicatorPosition Gets or sets the position of the note indicator for cells in this row.
NoteIndicatorSize Gets or sets the default size for the note indicator for cells in this row.
Parent Gets the parent AlternatingRows object that contains this alternating row.
ParentStyleName Gets or sets the name of the parent style from which style properties are inherited for cells in this alternating row.
Renderer Gets or sets the renderer for cells in this alternating row.
StyleName Gets or sets the name of the custom style for cells in this alternating row.
TabStop Gets or sets whether the user can set focus to cells in this row using the Tab key.
TextIndent Gets or sets the amount of space, in pixels, to indent text in cells in this row.
VerticalAlignment Gets or sets the vertical alignment for text in the cells in this alternating row.
Method Description
Equals Determines whether the specified object is equal to another object in this alternating row.
GetHashCode Gets the hash code of the alternating row.
Invalidate Invalidates the displayed cells and sends the message to repaint them.
ResetBackColor Resets the background color for this row and makes this row inherit the background color from the default row.
ResetBorder Resets the cell border for this row and makes this row inherit the cell border from the default row.
ResetCanFocus Resets to the default value whether cells in this row can receive focus.
ResetCellPadding Resets the cell padding of the alternate row.
ResetCellType Resets the cell type for this row and makes this row inherit the cell type from the default row.
ResetFont Resets the font for this row and makes this row inherit the font from the default row.
ResetForeColor Resets the foreground color for this row and makes this row inherit the foreground color from the default row.
ResetHorizontalAlignment Resets the horizontal alignment for this row and makes this row inherit the horizontal alignment from the default row.
ResetLocked Resets the locked state for this row and makes this row inherit the locked state from the default row.
ResetNoteIndicatorColor Resets the cell note indicator color for cells in this row.
ResetNoteIndicatorPosition Resets the position of the note indicator for cells in this row to the default value.
ResetNoteIndicatorSize Resets the cell note indicator size for cells in this row.
ResetTabStop Resets to its default value whether the user can set focus to cells in this row using the Tab key.
ResetTextIndent Resets the text indent for the row and makes the row inherit the text indent from the default row.
ResetVerticalAlignment Resets the vertical alignment for this row and makes this row inherit the vertical alignment from the default row.

This example code creates a sheet that has three different appearance settings for rows. This pattern repeats for all subsequent rows.

SpreadWinAlternating

Alternating Rows

The data in this file is from – https://www.ncdc.noaa.gov/cdo-web/datasets.

C#

fpSpread1.Sheets[0].LoadTextFile("C:\\ANNUAL_sample_csv.csv", FarPoint.Win.Spread.TextFileFlags.None, 
FarPoint.Win.Spread.Model.IncludeHeaders.None, "\n", ",", "");
fpSpread1.Sheets[0].AlternatingRows.Count = 3;
fpSpread1.Sheets[0].AlternatingRows[0].BackColor = Color.Bisque;
fpSpread1.Sheets[0].AlternatingRows[0].ForeColor = Color.Navy;
fpSpread1.Sheets[0].AlternatingRows[1].BackColor = Color.LightYellow;
fpSpread1.Sheets[0].AlternatingRows[1].ForeColor = Color.Navy;
fpSpread1.Sheets[0].AlternatingRows[2].BackColor = Color.PaleGoldenrod;
fpSpread1.Sheets[0].AlternatingRows[2].ForeColor = Color.Navy;
fpSpread1.Font = new System.Drawing.Font("Calibri", 11);

VB

FpSpread1.Sheets(0).LoadTextFile("C:\ANNUAL_sample_csv.csv", FarPoint.Win.Spread.TextFileFlags.None, 
FarPoint.Win.Spread.Model.IncludeHeaders.None, Chr(10), ",", "")
FpSpread1.Sheets(0).AlternatingRows.Count = 3
FpSpread1.Sheets(0).AlternatingRows(0).BackColor = Color.Bisque
FpSpread1.Sheets(0).AlternatingRows(0).ForeColor = Color.Navy
FpSpread1.Sheets(0).AlternatingRows(1).BackColor = Color.LightYellow
FpSpread1.Sheets(0).AlternatingRows(1).ForeColor = Color.Navy
FpSpread1.Sheets(0).AlternatingRows(2).BackColor = Color.PaleGoldenrod
FpSpread1.Sheets(0).AlternatingRows(2).ForeColor = Color.Navy
FpSpread1.Font = New System.Drawing.Font("Calibri", 11)

You can set alternating rows in the designer with the AlternatingRow editor under the Settings tab in the designer.

SpreadWinAltRowD

Spread Designer

You can use the SetDirectInfo method to set other style properties for a cell, column, or row directly. Cell, column, and row styles have precedence over alternating row styles.

“Direct” in the style model means “not composite” or “not inherited.” The SetDirectAltRowInfo method sets the alternating style properties. The alternating style is used by the viewport controls for merging alternating row styles with the composite style for a cell immediately prior to rendering. The index is zero-based and must be between 0 and (AltRowCount-1).

This example uses the SetDirectAltRowInfo method to set the specified alternating row style in the model.

C#

FarPoint.Win.Spread.Model.DefaultSheetStyleModel defstyleModel = new FarPoint.Win.Spread.Model.DefaultSheetStyleModel();
FarPoint.Win.Spread.StyleInfo sInfo = new FarPoint.Win.Spread.StyleInfo();
FarPoint.Win.Spread.StyleInfo composite = new FarPoint.Win.Spread.StyleInfo();
defstyleModel = (FarPoint.Win.Spread.Model.DefaultSheetStyleModel)fpSpread1.ActiveSheet.Models.Style;
sInfo.BackColor = Color.LightBlue;
defstyleModel.SetDirectAltRowInfo(0, sInfo);
composite = defstyleModel.GetDirectAltRowInfo(0, sInfo);
listBox1.Items.Add(composite.BackColor.ToString());

VB

Dim defstyleModel As New FarPoint.Win.Spread.Model.DefaultSheetStyleModel()
Dim sInfo As New FarPoint.Win.Spread.StyleInfo()
Dim composite As New FarPoint.Win.Spread.StyleInfo()
defstyleModel = FpSpread1.ActiveSheet.Models.Style
sInfo.BackColor = Color.LightBlue
defstyleModel.SetDirectAltRowInfo(0, sInfo)
composite = defstyleModel.GetDirectAltRowInfo(0, sInfo)
ListBox1.Items.Add(composite.BackColor.ToString())

Spread Windows Forms Ribbon Control

$
0
0

The Spread for Windows Forms spreadsheet control can be combined with other components, such as a Ribbon control in order to provide design functionality and other control to the user. In this example, you will learn how to add a Ribbon control to a project and connect it to a Spread component in a Windows Forms application.

If you want to follow along, make sure to download the CodePlex open-source ribbon library from here: CodePlex Ribbon

In addition, the DLL for this particular Spread Ribbon Control can be found here: Spread Ribbon Control

Set Up the Project

Create a new C# Windows Forms application in Visual Studio 2015. Once you have done so, click and drag the FpSpread component from the Toolbox onto a form in your application:

The form with a Spread instance on it.

The form with a Spread instance on it.

When you click on the FpSpread component in your form, switch the “Dock” property to “Bottom”:

The docking option in the properties window.

The docking option in the properties window.

Next, add the reference for the open source Ribbon to the project by right-clicking References in the Solution Explorer and clicking Add Reference…. Browse to the path where you downloaded the CodePlex Ribbon and choose the “System.Windows.Forms.Ribbon35.dll” file.

The References for the Project in the Solution Explorer

The References for the Project in the Solution Explorer

Once the correct references are added and the FpSpread component is on the form, you are now ready to add the Ribbon control.

Adding the Spread Ribbon Control

In order to easily add the Ribbon control, it has to be added to the Toolbox in Visual Studio. With the Toolbox open, right click the open space below the items and click Choose Items… Once the Choose Toolbox Items window is open, click Browse…

The Choose Toolbox Items window.

The Choose Toolbox Items window.

Navigate to the path where you saved the SpreadRibbonControlLibrary.zip file. Make sure to extract it first, and then choose the SpreadRibbonControlLibrary.dll file. Once you are brought back to the Choose Toolbox Items window, click OK to add it to the Toolbox. The new control should now show as SpreadRibbon in the Toolbox. To add it to the form, simply click and drag it from the Toolbox to the form.

The form with the added Spread Ribbon Control.

The form with the added Spread Ribbon Control.

Ribbon Layout and Spread Connection

Once the Spread Ribbon Control has been added to the form, it can be connected to a Spread component on that form (Note: the Ribbon can only be connected to one instance of the Spread component at a time). There are Smart Tags to make this process easy, which include specifying the Spread instance and docking it in the form. To open the Smart Tags for the control, select the instance of the Ribbon Control in the form and click on the arrow at the top right of the control:

The Smart Tags for the Spread Ribbon Control.

The Smart Tags for the Spread Ribbon Control.

To connect the ribbon to the FpSpread control, click the Spread Instance drop-down and select the name of the FpSpread control. To dock the control to the top of the form, click on Dock in parent container. Save the changes, and then Build and Run the project. If done correctly, the form should open up with the Spread control as well as the Ribbon control. You should be able to make changes to the FpSpread component from the ribbon toolbar, and see the properties of the cells reflected in the Ribbon.

The completed form.

The completed form.

Spread Windows Forms and Hierarchy Navigation

$
0
0

Spread for Windows Forms can display relational data, such as from a relational database, in hierarchical views.

The following image displays a typical hierarchical view with expanded child sheets.

SpreadWinHier

Hierarchy

The top-level hierarchical view is displayed in a parent sheet. Child records are displayed in separate, child sheets. This can make navigating with keyboard keys from one sheet to another difficult.

You can write code that allows you to navigate through the rows in the parent and child sheets.

The sample project included at the end of this blog allows you to use up or down arrow keys to navigate through the parent and child rows.

The following code from the sample creates custom action maps that move to the previous row (up arrow) or to the next row (down arrow).

fpSpread1.GetActionMap().Put("HierarchyMoveToPreviousRow", new HierarchyMoveToPreviousRowAction());
fpSpread1.GetActionMap().Put("HierarchyMoveToNextRow", new HierarchyMoveToNextRowAction());
InputMap inputMap = fpSpread1.GetInputMap(InputMapMode.WhenFocused);
inputMap.Put(new Keystroke(Keys.Up, Keys.None), "HierarchyMoveToPreviousRow");
inputMap.Put(new Keystroke(Keys.Down, Keys.None), "HierarchyMoveToNextRow");

This code from the example binds Spread to a datasource using a CreateDataSource function.

fpSpread1.DataSource = CreateDataSource();

This code from the example uses a function to expand all the child sheets so that navigation works properly.

ExpandChildrenRecursive(fpSpread1_Sheet1);

The input maps are set for the parent sheet and all the child sheets in this section of code.

SpreadView root = fpSpread1.GetRootWorkbook();
      foreach (SpreadView child in root.GetChildWorkbooks())
        SetInputMapRecursive(inputMap, root, child);

You can get the complete Visual Studio 2015 C# or VB sample project from this location:

C# SpreadCustomActionsSample VB SpreadCustomActionsSampleVB

Spread Windows Forms and Loading Data

$
0
0

An important part of a Spreadsheet is adding data. Spread for Windows Forms has many ways to add data. You can load files, bind to data sources, or use methods and properties to add data to cells.

The following table lists the different ways you can load files:

Method File Type Description
Open Spread XML files Spread can open data or data and formatting from a Spread-compatible XML file or a stream.
OpenExcel Excel-formatted files You can open an existing Excel-formatted file (BIFF8 format or xlsx) in Spread.
OpenSpreadFile Spread COM ss7 or ss8 files You can open an existing file from the COM version of Spread (Spread COM 7.0 or later).
LoadTextFile Text or comma-delimited files You can open existing text files that are delimited, either files saved from Spread or delimited text files from other sources.

You can use the DataSource property to bind Spread. You can bind the Spread component to a data set, such as data in a database, or to anything that the .NET framework allows, such as an IList object.

You can bind to a cell range with the MapperInfo class, the SpreadDataBindingAdapter class, and the FillSpreadDataByDataSource method.

This example binds the control to a data set.

SpreadWinBinding

Data Set

C#

DataSet ds = new DataSet();
DataTable emp = new DataTable("Product");
DataTable div = new DataTable("Total Cost");
emp.Columns.Add("Name");
emp.Columns.Add("Category");
emp.Rows.Add(new Object[] { "Apple", "Fruit" });
emp.Rows.Add(new Object[] { "Orange", "Fruit" });
emp.Rows.Add(new Object[] { "Plum", "Fruit" });
emp.Rows.Add(new Object[] { "Kiwi", "Fruit" });
emp.Rows.Add(new Object[] { "Strawberry", "Fruit" });
emp.Rows.Add(new Object[] { "Broccoli", "Vegetable" });
emp.Rows.Add(new Object[] { "Celery", "Vegetable" });
emp.Rows.Add(new Object[] { "Artichoke", "Vegetable" });
emp.Rows.Add(new Object[] { "Okra", "Vegetable" });
div.Columns.Add("Price");
div.Columns.Add("Quantity");
div.Rows.Add(new Object[] { "1.99 per pound", "100" });
div.Rows.Add(new Object[] { "2.00 per pound", "50" });
div.Rows.Add(new Object[] { "1.75 per pound", "150" });
div.Rows.Add(new Object[] { "2.50 per pound", "80" });
div.Rows.Add(new Object[] { "1.75 per pound", "150" });
div.Rows.Add(new Object[] { "2.50 per pound", "100" });
div.Rows.Add(new Object[] { "1.00 per pound", "250" });
div.Rows.Add(new Object[] { "4.75 per pound", "50" });
div.Rows.Add(new Object[] { "1.00 per pound", "150" });
ds.Tables.AddRange(new DataTable[] { emp, div });
fpSpread1.DataSource = ds;
fpSpread1.DataMember = "Product";

VB

Dim ds As New DataSet()
Dim emp As New DataTable("Product")
Dim div As New DataTable("Total Cost")
emp.Columns.Add("Name")
emp.Columns.Add("Category")
emp.Rows.Add(New Object() {"Apple", "Fruit"})
emp.Rows.Add(New Object() {"Orange", "Fruit"})
emp.Rows.Add(New Object() {"Plum", "Fruit"})
emp.Rows.Add(New Object() {"Kiwi", "Fruit"})
emp.Rows.Add(New Object() {"Strawberry", "Fruit"})
emp.Rows.Add(New Object() {"Broccoli", "Vegetable"})
emp.Rows.Add(New Object() {"Celery", "Vegetable"})
emp.Rows.Add(New Object() {"Artichoke", "Vegetable"})
emp.Rows.Add(New Object() {"Okra", "Vegetable"})
div.Columns.Add("Price")
div.Columns.Add("Quantity")
div.Rows.Add(New Object() {"1.99 per pound", "100"})
div.Rows.Add(New Object() {"2.00 per pound", "50"})
div.Rows.Add(New Object() {"1.75 per pound", "150"})
div.Rows.Add(New Object() {"2.50 per pound", "80"})
div.Rows.Add(New Object() {"1.75 per pound", "150"})
div.Rows.Add(New Object() {"2.50 per pound", "100"})
div.Rows.Add(New Object() {"1.00 per pound", "250"})
div.Rows.Add(New Object() {"4.75 per pound", "50"})
div.Rows.Add(New Object() {"1.00 per pound", "150"})
ds.Tables.AddRange(New DataTable() {emp, div})
FpSpread1.DataSource = ds
FpSpread1.DataMember = "Product"

You can place data in cells as formatted or unformatted strings or as data objects. The following table summarizes the ways you can add data using methods at the sheet level:

Data Description Method
As a string with formatting (for example “$1,234.56″) Individual cell SetText GetText
Range of cells SetClip GetClip
As a string without formatting (for example “1234.45″) Individual cell SetValue GetValue
Range of cells SetClipValue GetClipValue
As a data object with formatting Range of cells SetArray GetArray

When you work with formatted data, the data is parsed by the cell type formatted for that cell and placed in the data model. When you work with unformatted data, the data goes directly into the data model. If you add data to the sheet that is placed directly into the data model, you might want to parse the data because the component does not do so.

This example uses the SetArray method.

C#

fpSpread1.ActiveSheet.SetArray(1, 0, new String[,] { { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday" } });

VB

FpSpread1.ActiveSheet.SetArray(1, 0, New String(,) {{"Monday", "Tuesday", "Wednesday", "Thursday", "Friday"}})

This example uses the SetClip method.

C#

fpSpread1.ActiveSheet.SetClip(0, 0, 3, 4, "January\tFebruary\tMarch\tApril\r\nMay\tJune\tJuly\tAugust\r\nSeptember\tOctober\tNovember\tDecember");

VB

FpSpread1.ActiveSheet.SetClip(0, 0, 3, 4, "January" + Chr(9) + "February" + Chr(9) + "March" + Chr(9) + "April" + vbCrLf + "May" + Chr(9) +
 "June" + Chr(9) + "July" + Chr(9) + "August" + vbCrLf + "September" + Chr(9) + "October" + Chr(9) + "November" + Chr(9) + December")

The following table lists the ways you can get or set data in cells using properties of the cell:

Data Cell Property
As a string with formatting (for example “$1,234.56″) Text
As a string without formatting (for example “1234.45″) Value

Spread Windows Forms and Page Breaks

$
0
0

Some applications allow you to view page breaks for printing. You can use code to add visual indicators for page breaks in Spread for Windows Forms.

There are several ways to add visible page breaks in Spread Windows Forms. You can add a border to the row or column, a backcolor to the header, or an image to the header.

This example adds visual indicators for the row page breaks.

SpreadWinPageBreaks

Row Page Breaks

Use the following steps to create this example:

  1. Create a form.
  2. Add Spread and three buttons to the form.
  3. Add a list box to the form.
  4. Add the following code.

C#

private void Printing1_Load(object sender, EventArgs e)
        {
            fpSpread1.Open("C:\\Program Files (x86)\\GrapeCity\\Spread Studio 9\\Common\\CostOfGoodSold.xml");
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int[] i;
            i = fpSpread1.GetRowPageBreaks(0);
            foreach (object o in i)
            {
                listBox1.Items.Add(o);
                // Set a border for the row
                fpSpread1.Sheets[0].Cells[(int)o, 0, (int)o, fpSpread1.Sheets[0].Columns.Count - 1].Border = new FarPoint.Win.LineBorder(Color.Red, 2, false, true, false, false);
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            int[] i;
            i = fpSpread1.GetRowPageBreaks(0);
            foreach (object o in i)
            {
                listBox1.Items.Add(o);
                // Set the color for a header cell
                fpSpread1.Sheets[0].RowHeader.Cells[(int)o, 0].BackColor = Color.Red;
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            FarPoint.Win.Spread.CellType.ImageCellType imagecell = new FarPoint.Win.Spread.CellType.ImageCellType();
            System.Drawing.Image image = System.Drawing.Image.FromFile("C:\\Program Files (x86)\\GrapeCity\\Spread Studio 9\\Common\\SD.ico");

            int[] i;
            i = fpSpread1.GetRowPageBreaks(0);
            foreach (object o in i)
            {
                listBox1.Items.Add(o);
                // Add an image to the header cell
                fpSpread1.Sheets[0].RowHeader.Cells[(int)o, 0].CellType = imagecell;
                fpSpread1.Sheets[0].RowHeader.Cells[(int)o, 0].Value = image;
            }
        }

VB

Private Sub Printing1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        FpSpread1.Open("C:\Program Files (x86)\GrapeCity\Spread Studio 9\Common\CostOfGoodSold.xml")
    End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim i() As Integer        
        Dim o As Object
        i = FpSpread1.GetRowPageBreaks(0)
        For Each o In i
            ListBox1.Items.Add(o)         
            ‘ Set a border for the row   
            FpSpread1.Sheets(0).Cells(CInt(o), 0, CInt(o), FpSpread1.Sheets(0).Columns.Count - 1).Border = New FarPoint.Win.LineBorder(Color.Red, 2, False, True, False, False)
        Next
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Dim i() As Integer        
        Dim o As Object
        i = FpSpread1.GetRowPageBreaks(0)
        For Each o In i
            ListBox1.Items.Add(o)
            ‘ Set a color for the header cell
            FpSpread1.Sheets(0).RowHeader.Cells(CInt(o), 0).BackColor = Color.Red
        Next
    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        Dim imagecell As New FarPoint.Win.Spread.CellType.ImageCellType()
        Dim image As System.Drawing.Image
        image = System.Drawing.Image.FromFile("C:\Program Files (x86)\GrapeCity\Spread Studio 9\Common\SD.ico")

        Dim i() As Integer        
        Dim o As Object
        i = FpSpread1.GetRowPageBreaks(0)
        For Each o In i
            ListBox1.Items.Add(o)
            ‘ Add an image to the header cell
            FpSpread1.Sheets(0).RowHeader.Cells(CInt(o), 0).CellType = imagecell
            FpSpread1.Sheets(0).RowHeader.Cells(CInt(o), 0).Value = image
        Next
    End Sub

You can use the GetColumnPageBreaks method to get column page breaks.

Use the following steps to create an example that gets the column page breaks and sets a border, header color, or adds an image to the header:

  1. Create a form.
  2. Add Spread and three buttons to the form.
  3. Add a list box to the form.
  4. Add the following code.

C#

private void Printing1_Load(object sender, EventArgs e)
        {
            fpSpread1.Open("C:\\Program Files (x86)\\GrapeCity\\Spread Studio 9\\Common\\CostOfGoodSold.xml");   
        }       

        private void button1_Click(object sender, EventArgs e)
        {
            int[] i;
            i = fpSpread1.GetColumnPageBreaks(0);
            foreach (object o in i)
            {
                listBox1.Items.Add(o);
                fpSpread1.Sheets[0].Cells[0, (int)o, fpSpread1.Sheets[0].Rows.Count - 1, (int)o].Border = new FarPoint.Win.LineBorder(Color.Red, 2, true, false, false, false);               
            }
        }

private void button2_Click(object sender, EventArgs e)
        {
            int[] i;
            i = fpSpread1.GetColumnPageBreaks(0);
            foreach (object o in i)
            {
                listBox1.Items.Add(o);
                fpSpread1.Sheets[0].ColumnHeader.Cells[0, (int)o].BackColor = Color.Red;
            }
        }

private void button3_Click(object sender, EventArgs e)
        {
            FarPoint.Win.Spread.CellType.ImageCellType imagecell = new FarPoint.Win.Spread.CellType.ImageCellType();
            System.Drawing.Image image = System.Drawing.Image.FromFile("C:\\Program Files (x86)\\GrapeCity\\Spread Studio 9\\Common\\SD.ico");

            int[] i;
            i = fpSpread1.GetColumnPageBreaks(0);
            foreach (object o in i)
            {
                listBox1.Items.Add(o);
                fpSpread1.Sheets[0].ColumnHeader.Cells[0,(int)o].CellType = imagecell;
                fpSpread1.Sheets[0].ColumnHeader.Cells[0,(int)o].Value = image;
            }
        }

VB

Private Sub Printing1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        FpSpread1.Open("C:\Program Files (x86)\GrapeCity\Spread Studio 9\Common\CostOfGoodSold.xml")
End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim i() As Integer
        Dim o As Object
        i = FpSpread1.GetColumnPageBreaks(0)
        For Each o In i
            ListBox1.Items.Add(o)
            FpSpread1.Sheets(0).Cells(0, CInt(o), FpSpread1.Sheets(0).Rows.Count - 1, CInt(o)).Border = New FarPoint.Win.LineBorder(Color.Red, 2, True, False, False, False)
        Next
End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Dim i() As Integer
        Dim o As Object
        i = FpSpread1.GetColumnPageBreaks(0)
        For Each o In i
            ListBox1.Items.Add(o)
            FpSpread1.Sheets(0).ColumnHeader.Cells(0, CInt(o)).BackColor = Color.Red
        Next
End Sub

Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        Dim imagecell As New FarPoint.Win.Spread.CellType.ImageCellType()
        Dim image As System.Drawing.Image
        image = System.Drawing.Image.FromFile("C:\Program Files (x86)\GrapeCity\Spread Studio 9\Common\SD.ico")

        Dim i() As Integer
        Dim o As Object
        i = FpSpread1.GetColumnPageBreaks(0)
        For Each o In i
            ListBox1.Items.Add(o)
            FpSpread1.Sheets(0).ColumnHeader.Cells(0, CInt(o)).CellType = imagecell
            FpSpread1.Sheets(0).ColumnHeader.Cells(0, CInt(o)).Value = image
        Next
End Sub

Spread Windows Forms and the Spread Designer

$
0
0

You can quickly design a spreadsheet component using the Spread Designer. Whether you are prototyping a complete spreadsheet component or simply customizing some aspect of an existing spreadsheet component, the dedicated graphical interface offers many features to save time and effort.

There are several ways to use the designer. You can use the designer in Visual Studio, as a stand-alone application, or you can load designer dialogs using code.

You can start the Spread Designer from inside your Visual Studio .NET project by doing one of the following:

  • Right-click on the FpSpread component on your form and choose Spread Designer.
    SpreadWinSDrightclick

    Right-Click Option

  • Select the Spread Designer verb at the top right-edge of the Spread control.
    SpreadWinSDverb

    Spread Designer Verb

You can also run the Spread Designer outside of Visual Studio .NET as a stand-alone application. For many developers who want to create and share designs, this is a quick way to design FpSpread-based applications and save them as either XML or Excel-compatible files. Practically all of the functionality you expect from the Spread Designer is available in this stand-alone application except those features that involve applying to and reverting from the form in Visual Studio.

Run the FarPoint.SpreadDesigner.EXE from the product bin folder to use the Spread Designer as a stand-alone application.

You can use the Spread Designer in your project with code. Add the FarPoint.Win.Spread.Design dll to the list of references in your Visual Studio project. Then select the FpSpreadDesigner component from the Toolbox under the GrapeCity Spread section and drag it to the form.

SpreadWinSDCode

FpSpreadDesigner

You can use one of the following API methods to display the designer:

Method Description
Show Displays the Spread Designer for the specific FpSpread control.
ShowDialog Displays the Spread Designer as a modal dialog box for the specific FpSpread control.

This example displays the FpSpreadDesigner component at run time after it has been added to the form at design time.

C#

fpSpreadDesigner1.Show(fpSpread1);

VB

FpSpreadDesigner1.Show(FpSpread1)

This example displays the FpSpreadDesigner component at run time after it has been added to the form at design time.

C#

fpSpreadDesigner1.ShowDialog(fpSpread1);

VB

FpSpreadDesigner1.ShowDialog(FpSpread1)

This example loads the cell type editor.

SpreadWinSDCells

Cell Type Editor

C#

FarPoint.Win.Spread.Design.ExternalDialogs.CellTypeEditor(fpSpread1);

VB

FarPoint.Win.Spread.Design.ExternalDialogs.CellTypeEditor(FpSpread1)

This example uses the border editor.

SpreadWinSDBorder

Border Editor

C#

FarPoint.Win.Spread.Design.ExternalDialogs.BorderEditor(fpSpread1);

VB

FarPoint.Win.Spread.Design.ExternalDialogs.BorderEditor(FpSpread1)

This example uses ANNUAL_sample_csv.csv from https://www.ncdc.noaa.gov/cdo-web/datasets. Use the File tab and the Open menu to load the file. Use the default column delimiter and line feed for the row delimiter.

SpreadWinSDloadfile

Load File

The first row of text in this example uses bold formatting. You can set other formatting options using the designer.

SpreadWinSDboldtext

Spread Designer Example

Spread Windows Forms and Currency Cells

$
0
0

Currency cells are useful if you want to display numbers as monetary values.

You can display currency values in Spread Windows Forms with a currency cell. You can customize formatting in the currency cell such as the currency symbol, separator character, decimal separator, and so on.

By default, Spread uses the regional Windows settings (or options) of the machine on which it runs for the currency formatting. You can customize any of these currency formatting properties:

  • currency symbol (and whether to display it)
  • separator character (and whether to display it)
  • decimal symbol
  • whether to display a leading zero
  • positive value indicator (and whether to display it)
  • negative value indicator (and whether to display it)

Use the CurrencyCellType class to set the currency cell properties. The following table lists the properties for the currency cell:

ButtonAlign Gets or sets where the buttons are displayed in the cell. (Inherited from FarPoint.Win.Spread.CellType.EditBaseCellType)
CurrencySymbol Gets or sets the string for the currency symbol when displaying currency values.
DecimalPlaces Gets or sets the number of decimal places. The maximum number is 16.
DecimalSeparator Gets or sets the decimal character.
FixedPoint Gets or sets whether to display zeros as placeholders in the decimal portion of the number for a fixed-point numeric display.
FocusPosition Gets or sets the initial cursor position. (Inherited from FarPoint.Win.Spread.CellType.EditBaseCellType)
LeadingZero Gets or sets whether leading zeros are displayed.
MaximumValue Gets or sets the maximum value allowed for user entry.
MinimumValue Gets or sets the minimum value allowed for user entry.
NegativeFormat Gets or sets the format for displaying a negative value.
NegativeRed Gets or sets whether negative numeric values are displayed in red.
NullDisplay Gets or sets the text to display for null values. (Inherited from FarPoint.Win.Spread.CellType.EditBaseCellType)
OverflowCharacter Gets or sets the character for replacing the value if it does not fit the width of the display.
PositiveFormat Gets or sets the format for displaying a positive value.
ReadOnly Gets or sets whether the cell is read-only (and thus cannot be modified). (Inherited from FarPoint.Win.Spread.CellType.EditBaseCellType)
Separator Gets or sets the string used to separate thousands in a numeric value.
ShowCurrencySymbol Gets or sets whether to display the currency symbol.
ShowSeparator Gets or sets whether to display the thousands separator string.
ShrinkToFit Gets or sets whether to shrink the text to fit the cell. (Inherited from FarPoint.Win.Spread.CellType.EditBaseCellType)
SpinButton Gets or sets whether a spin button is displayed when editing.
SpinDecimalIncrement Gets or sets the amount by which the value increments when using the spin buttons and the cursor is in the decimal portion.
SpinIntegerIncrement Gets or sets the amount by which the value increments when using the spin buttons and the cursor is in the integer portion.
SpinWrap Gets or sets whether the value wraps when the minimum or maximum is reached.
Static Gets or sets whether the cell is static, which prohibits user interaction. (Inherited from FarPoint.Win.Spread.CellType.EditBaseCellType)
StringTrim Gets or sets how to trim characters that do not fit in the cell. (Inherited from FarPoint.Win.Spread.CellType.EditBaseCellType)
TextOrientation Gets or sets how text orients itself when painting the cell. (Inherited from FarPoint.Win.Spread.CellType.EditBaseCellType)
TextRotationAngle Gets or sets the rotation angle of the text for the cell. (Inherited from FarPoint.Win.Spread.CellType.EditBaseCellType)
WordWrap Gets or sets whether text that is too long to fit in the cell wraps to additional lines. (Inherited from FarPoint.Win.Spread.CellType.EditBaseCellType)

The MinimumValue and MaximumValue properties limit the value that the user enters when editing the cell. It does not affect the data model and does not the limit the cell getting a value by other means, for example, by means of a formula. The built-in operators and built-in functions for use in formulas return results as a Double (15 digits).

Use the MinimumValue and MaximumValue properties to place range restrictions on user entry. For example, the following code limits user input to values between 0 and 100.

C#

FarPoint.Win.Spread.CellType.CurrencyCellType currencycell = new FarPoint.Win.Spread.CellType.CurrencyCellType();
currencycell.DecimalPlaces = 2;
currencycell.ShowCurrencySymbol = true;
currencycell.MinimumValue = 0;
currencycell.MaximumValue = 100;
fpSpread1.Sheets[0].Cells[0, 0, 2, 2].CellType = currencycell;

VB

Dim currencycell As New FarPoint.Win.Spread.CellType.CurrencyCellType()
currencycell.DecimalPlaces = 2
currencycell.ShowCurrencySymbol = True
currencycell.MinimumValue = 0
currencycell.MaximumValue = 100
FpSpread1.Sheets(0).Cells(0, 0, 2, 2).CellType = currencycell

Use the MIN and MAX functions to place range restrictions on formula calculations. For example, the following code limits the summation calculation to values between 0 and 100. Type values in A1 and A2 to see the result.

C#

fpSpread1.Sheets[0].Cells[2, 4].Formula = "MAX(0,MIN(SUM(A1:A2), 100))";

VB

FpSpread1.Sheets(0).Cells(2, 4).Formula = "MAX(0,MIN(SUM(A1:A2), 100))"

This example loads data from a data source and creates a column of currency cells.

SpreadWinCurrency

Column of Currency Cells

C#

//Add sample data
string conStr = "Provider=Microsoft.JET.OLEDB.4.0;data source= C:\\Program Files (x86)\\GrapeCity\\Spread Studio 8\\Common\\nwind.mdb";
//string sqlStr = "Select CompanyName, ContactName, ContactTitle, Country from Customers";
string sqlStr = "Select OrderID, CustomerID, ShipName, Freight from Orders";
//string sqlStr = "Select * from Orders";
System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(conStr);
DataSet ds = new DataSet();
System.Data.OleDb.OleDbDataAdapter da = new System.Data.OleDb.OleDbDataAdapter(sqlStr, conn);
da.Fill(ds);
fpSpread1.ActiveSheet.DataAutoSizeColumns = true;            
fpSpread1.ActiveSheet.DataSource = ds;

FarPoint.Win.Spread.CellType.CurrencyCellType currencycell = new FarPoint.Win.Spread.CellType.CurrencyCellType();
currencycell.DecimalPlaces = 2;
currencycell.ShowCurrencySymbol = true;
fpSpread1.ActiveSheet.Columns[3].CellType = currencycell;
fpSpread1.ActiveSheet.Columns[3].BackColor = Color.Beige;
fpSpread1.Font = new Font("Calibri", 10);

VB

'Add sample data
Dim conStr As String = "Provider=Microsoft.JET.OLEDB.4.0;data source= C:\Program Files (x86)\GrapeCity\Spread Studio 8\Common\nwind.mdb"
Dim sqlStr As String = "Select OrderID, CustomerID, ShipName, Freight from Orders"
Dim conn As New System.Data.OleDb.OleDbConnection(conStr)
Dim ds As New DataSet()
Dim da As New System.Data.OleDb.OleDbDataAdapter(sqlStr, conn)
da.Fill(ds)
FpSpread1.ActiveSheet.DataAutoSizeColumns = True
FpSpread1.ActiveSheet.DataSource = ds

Dim currencycell As New FarPoint.Win.Spread.CellType.CurrencyCellType()
currencycell.DecimalPlaces = 2
currencycell.ShowCurrencySymbol = True
FpSpread1.ActiveSheet.Columns(3).CellType = currencycell
FpSpread1.ActiveSheet.Columns(3).BackColor = Color.Beige
FpSpread1.Font = New Font("Calibri", 10)

If you double-click on the currency cell in edit mode at run-time or press F4, a pop-up calculator appears by default. You can prevent the pop-up calculator by setting e.Cancel to True in the SubEditorOpening event. You can specify the text that displays on the OK and Cancel buttons with the SetCalculatorText method.

This example displays the pop-up calculator with custom button text.

SpreadWinSetCalc

Pop-up Calculator

C#

FarPoint.Win.Spread.CellType.CurrencyCellType currencycell = new FarPoint.Win.Spread.CellType.CurrencyCellType();
currencycell.DecimalPlaces = 2;
currencycell.ShowCurrencySymbol = true;
currencycell.SetCalculatorText("Accept", "Cancel");
fpSpread1.Sheets[0].Cells[0, 0, 2, 2].CellType = currencycell;

VB

Dim currencycell As New FarPoint.Win.Spread.CellType.CurrencyCellType()
currencycell.DecimalPlaces = 2
currencycell.ShowCurrencySymbol = True
currencycell.SetCalculatorText("Accept", "Cancel")
FpSpread1.Sheets(0).Cells(0, 0, 2, 2).CellType = currencycell

You can display spin buttons on the side of the cell when the cell is in edit mode.

This example displays spin buttons and sets the decimal and integer increments.

SpreadWinCurWrap

Spin Buttons in Cell

C#

FarPoint.Win.Spread.CellType.CurrencyCellType currencycell = new FarPoint.Win.Spread.CellType.CurrencyCellType();
currencycell.DecimalPlaces = 2;
currencycell.ShowCurrencySymbol = true;
currencycell.SpinButton = true;
currencycell.SpinDecimalIncrement = 0.5F;
currencycell.SpinIntegerIncrement = 5;
currencycell.SpinWrap = true;
fpSpread1.Sheets[0].Cells[1, 1].CellType = currencycell;
fpSpread1.Sheets[0].Rows[1].Height = 40;
fpSpread1.Sheets[0].Columns[1].Width = 100;

VB

Dim currencycell As New FarPoint.Win.Spread.CellType.CurrencyCellType()
currencycell.DecimalPlaces = 2
currencycell.ShowCurrencySymbol = True
currencycell.SpinButton = True
currencycell.SpinDecimalIncrement = 0.5F
currencycell.SpinIntegerIncrement = 5
currencycell.SpinWrap = True
FpSpread1.Sheets(0).Cells(1, 1).CellType = currencycell
FpSpread1.Sheets(0).Rows(1).Height = 40
FpSpread1.Sheets(0).Columns(1).Width = 100

This example sets a negative color and the positive and negative format for a currency cell.

C#

FarPoint.Win.Spread.CellType.CurrencyCellType currencycell = new FarPoint.Win.Spread.CellType.CurrencyCellType();
currencycell.DecimalPlaces = 2;
currencycell.ShowCurrencySymbol = true;
currencycell.NegativeRed = true;
currencycell.NegativeFormat = FarPoint.Win.Spread.CellType.CurrencyNegativeFormat.SignSymbolBefore;
currencycell.PositiveFormat = FarPoint.Win.Spread.CellType.CurrencyPositiveFormat.CurrencySymbolBefore;
fpSpread1.Sheets[0].Cells[1, 1].CellType = currencycell;

VB

Dim currencycell As New FarPoint.Win.Spread.CellType.CurrencyCellType()
currencycell.DecimalPlaces = 2
currencycell.ShowCurrencySymbol = True
currencycell.NegativeRed = True
currencycell.NegativeFormat = FarPoint.Win.Spread.CellType.CurrencyNegativeFormat.SignSymbolBefore
currencycell.PositiveFormat = FarPoint.Win.Spread.CellType.CurrencyPositiveFormat.CurrencySymbolBefore
FpSpread1.Sheets(0).Cells(1, 1).CellType = currencycell

You can also create currency cells in the Spread Designer. Select the cell or cells, right-click on the cells, and then select Cell Types. Another way to set the cell type in the designer is to use the Set CellType option in the Cell Type section of the Home menu.

SpreadWinDesCell

Cell Type Dialog in Designer

SpreadWinDesCell1

Currency Cell Menu


Spread Studio V9 Service Pack 1 Fixed Bugs

$
0
0

In this article, you will find all of the .NET bugs that were fixed in the first Service Pack release of Spread V9.

To download Spread V9 Service Pack 1, click here.

Spread for Winforms

  • The CheckboxCellType now works correctly with certain key characters.
  • Performance issues with adding rows were fixed.
  • Performance issues with loading XML files were fixed.
  • The AllArrowsIgnoreMultiline option now works correctly in Korean culture.
  • Certain XML files now load correctly.
  • Copy and paste now work correctly.
  • Performance issues with grouping were fixed.
  • The print header and footer now work correctly with French settings.
  • The print header and footer now export correctly to Excel.
  • Performance issues with RichTextCellType and cell spans were fixed.
  • BestFitCols now works correctly with spanned cells.

Spread for ASP.NET

  • Formulas that reference empty cells on other pages now work correctly.

Spread for Silverlight

  • Multiple conditional formats are now correctly imported from an Excel-formatted file.

Spread for WPF

  • Print settings are now imported correctly from Excel-formatted files.
  • Multiple conditional formats are now correctly imported from Excel-formatted files.
  • The Licenses.licx file now gets correctly updated when adding a component to a project.

Spread for WinRT

  • Multiple conditional formats are now correctly imported from Excel-formatted files.

Spread Windows Forms and Built-in Shapes

$
0
0

You can use built-in shapes in Spread for Windows Forms to draw attention to different areas of your spreadsheet. You can use shapes to show a process with flowchart-like graphics, use shapes to highlight a particular result, or use a shape for some other purpose.

Spread has the following built-in shape types:

  • Basic Shapes
  • Arrow Shapes
  • Balloon Shapes
  • Special Shapes
  • Star Shapes

For a complete list of built-in shapes, refer to http://sphelp.grapecity.com/WebHelp/SpreadNet9/WF/webframe.html#spwin-shape-types.html.

The shapes are available in code (each shape being a separate class in the DrawingSpace namespace) or from the Insert and Drawing Tools menus in the Spread Designer. Each shape can be rotated and resized, and their ability to be rotated and resized by the end user can be constrained. When selected, the shape has resize handles with which you can adjust the size and a rotate handle with which you can rotate the shape. Colors, shadows, and transparency can be adjusted.

Shapes are a form of graphics that are drawn on a separate layer from that of the spreadsheet. This drawing layer, or drawing space, is in front of the spreadsheet in the display. Shapes can be made all or partially transparent to reveal the spreadsheet behind. Because the shapes appear on this separate layer from the sheet and can be thought to float above the spreadsheet, they are sometimes called floating objects.

Hiding columns and rows that contain a shape hides the shape as well.

The API properties that can be set for shapes are listed in the following classes:

  • FarPoint.Win.Spread.DrawingSpace.PSObject
  • FarPoint.Win.Spread.DrawingSpace.PSShape

The DynamicSize and DynamicMove properties specify how shapes are moved and resized when hiding or showing, resizing, or moving rows or columns that intersect with the shape or that appear before the shape (for example, resizing a column to the left or a row above the shape). The following options are available:

  • Move and size with cells (DynamicMove = True and DynamicSize = True)
  • Move, but do not size with cells (DynamicMove = True and DynamicSize = False)
  • Do not move or size with cells (DynamicMove = False and DynamicSize = False)

You can use the FarPoint.Win.Spread.DrawingSpace.DrawingToolbar class to bring up the shape toolbar at run time.

You can use the following methods in the SheetView class to get, add, or remove shapes:

Method Description
AddShape Adds a shape.
RemoveShape Removes a shape.
ClearShapes Removes all the shapes.
GetShape Gets a shape.

The following example shows a simple way to add a built-in shape:

C#

fpSpread1.ActiveSheet.AddShape(new FarPoint.Win.Spread.DrawingSpace.RectangleShape());

VB

FpSpread1.ActiveSheet.AddShape(New FarPoint.Win.Spread.DrawingSpace.RectangleShape())

This example creates a basic rectangle shape, sets properties, and adds the shape to the active sheet.

C#

// Create a new shape.

FarPoint.Win.Spread.DrawingSpace.RectangleShape rShape = new FarPoint.Win.Spread.DrawingSpace.RectangleShape();

// Assign a name, overriding the unique default assigned name.

// All shape names within a sheet must be unique.

rShape.Name = "rShape1";

// Assign a location at which to start the display of the shape.

rShape.Top = 20;

rShape.Left = 60;

// Alternatively, you could set the Location property

// with a Point object as in:

//rShape.Location = new System.Drawing.Point(20, 60);

// Assign a custom fill color to the shape.

rShape.BackColor = System.Drawing.Color.Blue;

// Assign a size to the shape.

rShape.Width = 100;

rShape.Height = 100;

// Alternatively, you could set the Size property

// with a Size object as in:

//rShape.Size = new System.Drawing.Size(100, 100);

// Add the shape to the sheet so that it appears on that sheet.

fpSpread1.ActiveSheet.AddShape(rShape);

// This code will display the shape property dialog

FarPoint.Win.Spread.DrawingSpace.ShapeProps f = new FarPoint.Win.Spread.DrawingSpace.ShapeProps(fpSpread1);

f.Shape = fpSpread1.Sheets[0].DrawingContainer.GetShape("rShape1");

f.ShowDialog();

VB

' Create a shape.

Dim rShape As New FarPoint.Win.Spread.DrawingSpace.RectangleShape()

' Assign a name, overriding the unique default assigned name.

' All shape names within a sheet must be unique.

rShape.Name = "rShape1"

' Assign a location at which to start the display of the shape.

rShape.Top = 20

rShape.Left = 60

' Alternatively, you could set the Location property

' with a Point object as in:

'rShape.Location = New Point(20, 60)

' Assign a custom fill color to the shape.

rShape.BackColor = Color.Blue

' Assign a size to the shape.

rShape.Width = 100

rShape.Height = 100

' Alternatively, you could set the Size property

' with a Size object as in:

' rShape.Size = New Size(100, 100)

' Add the shape to the sheet so that it appears on that sheet.

FpSpread1.ActiveSheet.AddShape(rShape)

' This code will display the shape property dialog

Dim f As New FarPoint.Win.Spread.DrawingSpace.ShapeProps(FpSpread1)

f.Shape = FpSpread1.Sheets(0).DrawingContainer.GetShape("rShape1")

f.ShowDialog()

This example uses the drawing toolbar at run time.

SpreadWinDrawingToolbar

Drawing Toolbar

C#

public void ShowToolbar()
{
FarPoint.Win.Spread.DrawingSpace.DrawingToolbar draw = default(FarPoint.Win.Spread.DrawingSpace.DrawingToolbar);
if (fpSpread1.ActiveSheet != null)
{
draw = new FarPoint.Win.Spread.DrawingSpace.DrawingToolbar(fpSpread1, fpSpread1.ActiveSheet.DrawingContainer);
}
else
{
draw = new FarPoint.Win.Spread.DrawingSpace.DrawingToolbar(fpSpread1, null);
}
draw.Visible = true;
draw.Owner = this;
draw.Left = this.Left + this.Width - draw.Width / 2;
draw.Top = this.Top + this.Height / 2 - draw.Height / 2;
}

private void button1_Click(object sender, EventArgs e)
{
ShowToolbar();
}

VB

Sub ShowToolbar()
Dim draw As FarPoint.Win.Spread.DrawingSpace.DrawingToolbar
If Not (FpSpread1.ActiveSheet Is Nothing) Then
draw = New FarPoint.Win.Spread.DrawingSpace.DrawingToolbar(FpSpread1, FpSpread1.ActiveSheet.DrawingContainer)
Else
draw = New FarPoint.Win.Spread.DrawingSpace.DrawingToolbar(FpSpread1, Nothing)
End If
draw.Visible = True
draw.Owner = Me
draw.Left = Me.Left + Me.Width - draw.Width / 2
draw.Top = Me.Top + Me.Height / 2 - draw.Height / 2
End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
ShowToolbar()
End Sub

You can add a built-in shape using the Insert menu in the Designer.

SpreadWinDBuiltInS

Shapes

After you select a shape from the Shapes section, the Drawing Tools menu is displayed.

SpreadWinDBuiltInDT

Drawing Tools

The following options are available in the Drawing Tools menu:

Item Description
BackColor This allows you to set the backcolor for a built-in shape.
ForeColor This allows you to set the forecolor for a built-in shape.
OutLineColor This allows you to set the outline color of the shape.
Thickness This allows you to change the width of the shape outline.
OutlineStyle This allows you to set the outline border type.
DropShadow This allows you to specify whether to have a shadow around the edges of the shape.
Bring To Front This allows you to specify whether to place this shape over others.
Send To Back This allows you to specify whether to place this shape behind others.
Rotate This allows you to select typical amounts of rotation for a shape.
Flip This allows you to flip a shape either horizontally or vertically.
Scale This allows you to resize a shape proportionally by selecting a scaling factor.
Set Picture This allows you to select an image and the image properties for a built-in shape.
Clear Picture This allows you to remove an image from a built-in shape.
Nudge The arrows to the right side of the Drawing Tools menu allow you to move the shape.

Spread Windows Forms and Camera Shapes

$
0
0

Spread Windows Forms supports a unique feature known as a camera shape.

This allows you to create a snapshot of a range of cells and use that as a shape in the Spread control. The cell range can also contain other shapes.

You can use the following steps to create a camera shape.

  1. Create a camera shape object using the SpreadCameraShape class.
  2. Specify the range of cells that will become the shape with the Formula property.
  3. Set any other shape properties.
  4. Add the camera shape to the sheet.

The following properties are available in the SpreadCameraShape class.

Property Description
Formula Gets or sets a string formula that indicates the captured region.
Height Overridden. Gets or sets the height of the object.
Left Overridden. Gets or sets the x-coordinate of the object.
Location Overridden. Gets or sets the location of the object.
Top Overridden. Gets or sets the y-coordinate of the object.
ShadowColor Gets or sets the color of the shadow of the object. (Inherited from FarPoint.Win.Spread.DrawingSpace.PSShape)
ShadowDirection Gets or sets the direction of the shadow. Set this property to display a shadow. (Inherited fromFarPoint.Win.Spread.DrawingSpace.PSShape)
ShadowOffset Gets or sets the amount of offset of the shadow. (Inherited from FarPoint.Win.Spread.DrawingSpace.PSShape)
ShadowOffsetX Gets or sets the amount of horizontal offset of the shadow of the object. (Inherited from FarPoint.Win.Spread.DrawingSpace.PSShape)
ShadowOffsetY Gets or sets the amount of vertical offset of the shadow of the object. (Inherited from FarPoint.Win.Spread.DrawingSpace.PSShape)
ShapeOutlineColor Gets or sets the shape outline color for the object. (Inherited from FarPoint.Win.Spread.DrawingSpace.PSObject)
ShapeOutlineStyle Gets or sets the shape outline style for the object. (Inherited from FarPoint.Win.Spread.DrawingSpace.PSObject)
ShapeOutlineThickness Gets or sets the shape outline thickness for the object. (Inherited from FarPoint.Win.Spread.DrawingSpace.PSObject)
Size Overridden. Gets or sets the size of the object.
Width Overridden. Gets or sets the width of the object.

In general, properties that apply to the interior of the shape, do not apply to the camera shape.

For a complete API list, refer to the SpreadCameraShape class: http://sphelp.grapecity.com/WebHelp/SpreadNet9/WF/webframe.html#FarPoint.Win.Spread~FarPoint.Win.Spread.DrawingSpace.SpreadCameraShape.html.

For more information about built-in shapes, refer to: http://sphelp.grapecity.com/WebHelp/SpreadNet9/WF/webframe.html#spwin-shape-types.html.

The following example creates a custom shape and then uses the custom shape in a camera shape.

SpreadWinCameraShape

Camera Shape

C#

public class myShape : FarPoint.Win.Spread.DrawingSpace.CustomShape
{
public override void OnPaintBackground(System.Drawing.Graphics g, System.Drawing.Rectangle rectInput)
{
System.Drawing.Color myColor = System.Drawing.Color.FromArgb(128, 120, 20, 100);
System.Drawing.Drawing2D.HatchBrush myBrush = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.Trellis,
System.Drawing.Color.White, myColor);
g.FillPath(myBrush, (System.Drawing.Drawing2D.GraphicsPath)this.Shape);
}
}

System.Drawing.Point[] ptsRect = {
new System.Drawing.Point(1, 1),
new System.Drawing.Point(1, 160),
new System.Drawing.Point(160, 160),
new System.Drawing.Point(160, 1)
};

System.Drawing.Drawing2D.GraphicsPath gpath = new System.Drawing.Drawing2D.GraphicsPath();
gpath.AddPolygon(ptsRect);
myShape pso = new myShape();
pso.Shape = gpath;
fpSpread1.ActiveSheet.AddShape(pso, 10, 2);
fpSpread1.ActiveSheet.Cells[10, 1].Text = "Shape";
FarPoint.Win.Spread.DrawingSpace.SpreadCameraShape camera = new FarPoint.Win.Spread.DrawingSpace.SpreadCameraShape();
camera.Formula = "B10:D15";
camera.Location = new System.Drawing.Point(10, 40);
fpSpread1.ActiveSheet.AddShape(camera);

VB

Public Class myShape
Inherits FarPoint.Win.Spread.DrawingSpace.CustomShape
Public Overrides Sub OnPaintBackground(ByVal g As System.Drawing.Graphics, ByVal rectInput As System.Drawing.Rectangle)
Dim myColor As Color = Color.FromArgb(128, 120, 20, 100)
Dim myBrush As System.Drawing.Drawing2D.HatchBrush = New System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.Trellis,
Color.White, myColor)
g.FillPath(myBrush,
CType(Me.Shape, System.Drawing.Drawing2D.GraphicsPath))
End Sub
End Class

Dim ptsRect() As Point = {
New Point(1, 1),
New Point(1, 160),
New Point(160, 160),
New Point(160, 1)
}

Dim gpath As System.Drawing.Drawing2D.GraphicsPath = New System.Drawing.Drawing2D.GraphicsPath
gpath.AddPolygon(ptsRect)
Dim pso As New myShape
pso.Shape = gpath
FpSpread1.ActiveSheet.AddShape(pso, 10, 2)
FpSpread1.ActiveSheet.Cells(10, 1).Text = "Shape"
Dim camera As New FarPoint.Win.Spread.DrawingSpace.SpreadCameraShape()
camera.Formula = "B10:D15"
camera.Location = New System.Drawing.Point(10, 40)
FpSpread1.ActiveSheet.AddShape(camera)

This example uses a built-in shape in the camera shape.

C#

FarPoint.Win.Spread.DrawingSpace.LightningBoltShape ls = new FarPoint.Win.Spread.DrawingSpace.LightningBoltShape();
ls.BackColor = System.Drawing.Color.DarkTurquoise;
fpSpread1.ActiveSheet.AddShape(ls, 10, 2);
fpSpread1.ActiveSheet.Cells[10, 1].Text = "Shape";
FarPoint.Win.Spread.DrawingSpace.SpreadCameraShape camera = new FarPoint.Win.Spread.DrawingSpace.SpreadCameraShape();
camera.Formula = "B10:D18";
camera.ShadowColor = System.Drawing.Color.Red;
camera.ShadowDirection = FarPoint.Win.Spread.DrawingSpace.ShadowDirection.Right;
camera.ShapeOutlineStyle = System.Drawing.Drawing2D.DashStyle.Dot;
camera.ShapeOutlineThickness = 2;
camera.ShapeOutlineColor = System.Drawing.Color.Fuchsia;
camera.Location = new System.Drawing.Point(10, 40);
fpSpread1.ActiveSheet.AddShape(camera);

VB

Dim ls As New FarPoint.Win.Spread.DrawingSpace.LightningBoltShape()
ls.BackColor = System.Drawing.Color.DarkTurquoise
FpSpread1.ActiveSheet.AddShape(ls, 10, 2)
FpSpread1.ActiveSheet.Cells(10, 1).Text = "Shape"
Dim camera As New FarPoint.Win.Spread.DrawingSpace.SpreadCameraShape()
camera.Formula = "B10:D18"
camera.ShadowColor = System.Drawing.Color.Red
camera.ShadowDirection = FarPoint.Win.Spread.DrawingSpace.ShadowDirection.Right
camera.ShapeOutlineStyle = System.Drawing.Drawing2D.DashStyle.Dot
camera.ShapeOutlineThickness = 2
camera.ShapeOutlineColor = System.Drawing.Color.Fuchsia
camera.Location = New System.Drawing.Point(10, 40)
FpSpread1.ActiveSheet.AddShape(camera)

You can also use the designer to create a camera shape.

SpreadWinDesignCamera

Spread Designer

Select a block of cells. Then from the Insert menu, select the Camera Shape icon to create a camera shape. The camera shape can include other shapes. Use the Drawing Tools menu to customize the image. The BackColor and ForeColor options under the DrawingTools menu do not apply to the camera shape. In general, properties that apply to the interior of the shape, do not apply to the camera shape.

SpreadWinDesignDrawing

Drawing Tools

The following options are available in the DrawingTools menu:

Item Description
BackColor This allows you to set the backcolor for a built-in shape.
ForeColor This allows you to set the forecolor for a built-in shape.
OutLineColor This allows you to set the outline color of the shape.
Thickness This allows you to change the width of the shape outline.
OutlineStyle This allows you to set the outline border type.
DropShadow This allows you to specify whether to have a shadow around the edges of the shape.
Bring To Front This allows you to specify whether to place this shape over others.
Send To Back This allows you to specify whether to place this shape behind others.
Rotate This allows you to select typical amounts of rotation for a shape.
Flip This allows you to flip a shape either horizontally or vertically.
Scale This allows you to resize a shape proportionally by selecting a scaling factor.
Set Picture This allows you to select an image and the image properties for a built-in shape.
Clear Picture This allows you to remove an image from a built-in shape.
Nudge The arrows to the right side of the Drawing Tools menu allow you to move the shape.

Spread Windows Forms Designer and Sparklines

$
0
0

You can use the Spread Windows Forms designer to quickly design a sparkline.

Start the Spread Designer by selecting the FarPoint.SpreadDesigner.EXE from the product bin folder or by right-clicking on the FpSpread component on your form and then choosing Spread Designer.

You can create a sparkline using the following steps:

      1. Add data to the designer.
        SpreadWinDesignerSparkTest

        Data

      2. Select the Insert tab.
        SpreadWinDesignerInsert

        Insert Tab

      3. Select a sparkline type (Sparklines section). The Create Sparklines dialog is displayed.
        SpreadWinDesignerAddSpark

        Sparkline Type

      4. Specify the data range and the sparkline location.
        SpreadWinDesignerSparkRange

        Sparkline Range and Location

      5. The Sparklines tab is displayed once you select a type.
        SpreadWinDesignerSOptions

        Sparkline Options

      6. The following options are available:
        Item Description
        Edit Data This option allows you to change the sparkline data.
        Line, Column, or Win/Loss This option allows you to change the type of sparkline.
        High Point This option specifies whether to display the point for the largest value.
        Low Point This option specifies whether to display the point for the smallest value.
        Negative Point This option specifies whether to display points for negative values.
        First Point This option specifies whether to display the first point on the graph.
        Last Point This option specifies whether to display the last point on the graph.
        Markers This option specifies whether to add points for all the data (only applies to the line sparkline).
        Sparkline Color This option specifies the line color for the line sparkline or the data point color for the column or winloss sparkline.
        Marker Color This option specifies the color of the data points for the line sparkline or the color of the special data points for the column or winloss sparkline (for example, first point).
        Weight This option specifies the thickness of the line for the line sparkline.
        Axis This option specifies the axis type, how the data is plotted, whether to display an axis, and the minimum and maximum settings for the vertical axis. The horizontal axis is only displayed if the data contains negative values.
        Group This option allows you to group selected sparklines so they can share formatting and scaling options
        Ungroup This option removes the grouping from selected sparklines.
        Clear This option clears the selected sparklines.

        If the chart type is column or winloss, then selecting point options changes the color of the point indicator. Selecting point options with the line sparkline adds a data point to the line.

      7. Specify the sparkline options to complete your sparkline.
        SpreadWinDesignerSparkOptions

        Completed Sparklines

For more information about sparklines, refer to: http://sphelp.grapecity.com/WebHelp/SpreadNet9/WF/webframe.html#spwin-sparklines.html.

Spread Studio V10 Fixed Bugs

$
0
0

In this article, you will find all of the .NET bugs that were fixed in the first release of Spread Studio V10.

To view the release notes, see here: Version 10 Release Notes

To download Spread Studio V10, click here: Spread V10 Downloads

Spread for WinForms

  • Missing borders fixed when overflow text is too long.
  • Right-aligned text now overflows to adjacent cells.
  • SetColumnVisible now works in specific situations.
  • Ctrl-X no longer changes the formula reference style.
  • Selecting the corner of the sheet and copying no longer hangs the application.
  • Opening an Excel file from a stream with conditional formatting with formulas no longer throws an exception.
  • Memory usage no longer increases when searching in Spread.
  • TextTipPolicy no longer shows TextTips on Sheet tabs.
  • QR Code no longer disappears after clicking on any cell.
  • Print preview no longer produces an empty page when the frozen column size is greater than the page size.
  • DragFillDataOnly and AllowUndo now work together correctly.
  • INDEX formula now works correctly.
  • Issue with attaching an FpSpread instance to the NameBox control more than once is fixed.
  • The height of the NameBox control can now be resized.
  • The space character is no longer cleared when setting GcDateTimeCellType.PromptChar to a space in the Spread Designer.
  • PrintInfo with Header and Footer format is now fixed after Excel export.
  • The Horizontal and Vertical Scroll tooltip now appears close to the scroll bars.
  • Null reference exception fixed when showing another form during the formulaChanged event.

Spread for ASP.NET

  • Client performance in Internet Explorer 11 has been enhanced.
  • A problem with scrolling in Chrome with Frozen Rows/Columns has been fixed.
  • An issue with Spread working with C1 Tab has been fixed.
  • An issue with XML Serialization from previous versions of Spread has been fixed.

Spread Windows Forms and the Funnel Chart

$
0
0

Funnel charts can be a useful tool in your application. For example, since Funnel charts show values across multiple stages, they can be used to find out how many sales leads convert to purchases.

Spread for Windows Forms 10 now supports the Funnel chart. Creating a Funnel chart in Spread Win is simple.

The following steps show how to create a Funnel chart.

  1. Create a series and add data and category names.
    FarPoint.Win.Chart.FunnelSeries funnel = new FarPoint.Win.Chart.FunnelSeries();
    funnel.Values.Add(200);
    funnel.Values.Add(180);
    funnel.Values.Add(50);
    funnel.Values.Add(30);
    funnel.Values.Add(8);
    funnel.CategoryNames.Add("Leads");
    funnel.CategoryNames.Add("Emails Sent");
    funnel.CategoryNames.Add("Replies");
    funnel.CategoryNames.Add("Quotes");
    funnel.CategoryNames.Add("Purchases");
  2. Add any formatting.
    funnel.BarFills.AddRange(new FarPoint.Win.Chart.GradientFill[] { new FarPoint.Win.Chart.GradientFill(Color.LightGreen, Color.Yellow), new FarPoint.Win.Chart.GradientFill(Color.LightBlue, Color.Thistle), new FarPoint.Win.Chart.GradientFill(Color.LightGray, Color.LightPink), new FarPoint.Win.Chart.GradientFill(Color.Beige, Color.Orange), new FarPoint.Win.Chart.GradientFill(Color.LightSalmon, Color.RosyBrown) });
    funnel.BarBorders.AddRange(new FarPoint.Win.Chart.Line[] { new FarPoint.Win.Chart.SolidLine(Color.DarkOliveGreen), new FarPoint.Win.Chart.SolidLine(Color.DarkBlue), new FarPoint.Win.Chart.SolidLine(Color.Black), new FarPoint.Win.Chart.SolidLine(Color.DarkOrange), new FarPoint.Win.Chart.SolidLine(Color.Firebrick) });
  3. Create the plot area and add the series to the plot area.
    FarPoint.Win.Chart.YPlotArea plotArea = new FarPoint.Win.Chart.YPlotArea();
    plotArea.Location = new PointF(0.2f, 0.2f);
    plotArea.Size = new SizeF(0.6f, 0.6f);
    plotArea.Series.Add(funnel);
  4. Create a chart model and add the plot area to the chart model.
    FarPoint.Win.Chart.ChartModel model = new FarPoint.Win.Chart.ChartModel();
    model.PlotAreas.Add(plotArea);
  5. Create a chart object and add the model and set any size or position properties.
    FarPoint.Win.Spread.Chart.SpreadChart chart = new FarPoint.Win.Spread.Chart.SpreadChart();
    chart.Model = model;
    chart.Left = 0;
    chart.Top = 150;
    chart.Size = new Size(600, 400);
  6. Add the chart.
    fpSpread1.ActiveSheet.Charts.Add(chart);
winfunnelblog

Funnel Chart

The following is the complete code sample in C#:

FarPoint.Win.Chart.FunnelSeries funnel = new FarPoint.Win.Chart.FunnelSeries();
funnel.Values.Add(200);
funnel.Values.Add(180);
funnel.Values.Add(50);
funnel.Values.Add(30);
funnel.Values.Add(8);
funnel.CategoryNames.Add("Leads");
funnel.CategoryNames.Add("Emails Sent");
funnel.CategoryNames.Add("Replies");
funnel.CategoryNames.Add("Quotes");
funnel.CategoryNames.Add("Purchases");
funnel.BarFills.AddRange(new FarPoint.Win.Chart.GradientFill[] { new FarPoint.Win.Chart.GradientFill(Color.LightGreen, Color.Yellow), new FarPoint.Win.Chart.GradientFill(Color.LightBlue, Color.Thistle), new FarPoint.Win.Chart.GradientFill(Color.LightGray, Color.LightPink), new FarPoint.Win.Chart.GradientFill(Color.Beige, Color.Orange), new FarPoint.Win.Chart.GradientFill(Color.LightSalmon, Color.RosyBrown) });
funnel.BarBorders.AddRange(new FarPoint.Win.Chart.Line[] { new FarPoint.Win.Chart.SolidLine(Color.DarkOliveGreen), new FarPoint.Win.Chart.SolidLine(Color.DarkBlue), new FarPoint.Win.Chart.SolidLine(Color.Black), new FarPoint.Win.Chart.SolidLine(Color.DarkOrange), new FarPoint.Win.Chart.SolidLine(Color.Firebrick) });
FarPoint.Win.Chart.YPlotArea plotArea = new FarPoint.Win.Chart.YPlotArea();
plotArea.Location = new PointF(0.2f, 0.2f);
plotArea.Size = new SizeF(0.6f, 0.6f);
plotArea.Series.Add(funnel);
FarPoint.Win.Chart.ChartModel model = new FarPoint.Win.Chart.ChartModel();
model.PlotAreas.Add(plotArea);
FarPoint.Win.Spread.Chart.SpreadChart chart = new FarPoint.Win.Spread.Chart.SpreadChart();
chart.Model = model;
chart.Left = 0;
chart.Top = 150;
chart.Size = new Size(600, 400);
fpSpread1.ActiveSheet.Charts.Add(chart);
fpSpread1.Font = new System.Drawing.Font("Calibri", 11);

The following is the complete code sample in VB:

Dim funnel As New FarPoint.Win.Chart.FunnelSeries()
funnel.Values.Add(200)
funnel.Values.Add(180)
funnel.Values.Add(50)
funnel.Values.Add(30)
funnel.Values.Add(8)
funnel.CategoryNames.Add("Leads")
funnel.CategoryNames.Add("Emails Sent")
funnel.CategoryNames.Add("Replies")
funnel.CategoryNames.Add("Quotes")
funnel.CategoryNames.Add("Purchases")
funnel.BarFills.AddRange(New FarPoint.Win.Chart.GradientFill() {New FarPoint.Win.Chart.GradientFill(Color.LightGreen, Color.Yellow), New FarPoint.Win.Chart.GradientFill(Color.LightBlue, Color.Thistle), New FarPoint.Win.Chart.GradientFill(Color.LightGray, Color.LightPink), New FarPoint.Win.Chart.GradientFill(Color.Beige, Color.Orange), New FarPoint.Win.Chart.GradientFill(Color.LightSalmon, Color.RosyBrown)})
funnel.BarBorders.AddRange(New FarPoint.Win.Chart.Line() {New FarPoint.Win.Chart.SolidLine(Color.DarkOliveGreen), New FarPoint.Win.Chart.SolidLine(Color.DarkBlue), New FarPoint.Win.Chart.SolidLine(Color.Black), New FarPoint.Win.Chart.SolidLine(Color.DarkOrange), New FarPoint.Win.Chart.SolidLine(Color.Firebrick)})
Dim plotArea As New FarPoint.Win.Chart.YPlotArea()
plotArea.Location = New PointF(0.2F, 0.2F)
plotArea.Size = New SizeF(0.6F, 0.6F)
plotArea.Series.Add(funnel)
Dim model As New FarPoint.Win.Chart.ChartModel()
model.PlotAreas.Add(plotArea)
Dim chart As New FarPoint.Win.Spread.Chart.SpreadChart()
chart.Model = model
chart.Left = 0
chart.Top = 150
chart.Size = New Size(600, 400)
FpSpread1.ActiveSheet.Charts.Add(chart)
FpSpread1.Font = New System.Drawing.Font("Calibri", 11)

You can also add charts in the Spread Designer. Simply add the data to the designer, select the data, and then select the chart type (Insert, Create Chart dialog, and Funnel).

winfunneldesign1

Add Data

winfunneldesign2

Select Data and Chart Type

winfunneldesign3

Funnel Chart

Spread Windows Forms and the Sunburst Chart

$
0
0

Sunburst charts are effective for showing hierarchical data visually. For example, you can use a Sunburst chart to find out what store and product have the most sales.

Spread for Windows Forms and Spread for ASP.NET 10 now have the Sunburst chart.

The following image displays a Sunburst chart. You can quickly spot the store with the most sales and the best-selling products.

WinSunburst

Sunburst Chart

Use the following steps to create a Sunburst chart.

  1. Create a Sunburst series.
    FarPoint.Win.Chart.SunburstSeries series = new FarPoint.Win.Chart.SunburstSeries();
  2. Add data.
    series.Values.AddRange(new double[] { 350, 100, 80, 85, 90, 200, 350, 450, 500, 650, 220 });
  3. Set any colors.
    series.Fills.AddRange(new FarPoint.Win.Chart.Fill[] { new FarPoint.Win.Chart.SolidFill(Color.Blue), new FarPoint.Win.Chart.SolidFill(Color.Teal), new FarPoint.Win.Chart.SolidFill(Color.DarkGoldenrod), new
    FarPoint.Win.Chart.SolidFill(Color.DarkSalmon), new FarPoint.Win.Chart.SolidFill(Color.DarkGreen), new FarPoint.Win.Chart.SolidFill(Color.Chocolate), new FarPoint.Win.Chart.SolidFill(Color.Navy), new
    FarPoint.Win.Chart.SolidFill(Color.DarkOrange), new FarPoint.Win.Chart.SolidFill(Color.OrangeRed), new FarPoint.Win.Chart.SolidFill(Color.Tomato), new FarPoint.Win.Chart.SolidFill(Color.Firebrick), new
    FarPoint.Win.Chart.SolidFill(Color.Gray), new FarPoint.Win.Chart.SolidFill(Color.Olive), new FarPoint.Win.Chart.SolidFill(Color.Teal) });
  4. Add text strings for the data.
    FarPoint.Win.Chart.StringCollectionItem collection1 = new FarPoint.Win.Chart.StringCollectionItem();
    collection1.AddRange(new String[] { "Store 1", "", "", "", "", "", "Store 2", "", "", "Store 3" });
    FarPoint.Win.Chart.StringCollectionItem collection2 = new FarPoint.Win.Chart.StringCollectionItem();
    collection2.AddRange(new String[] { "Asagio", "Swiss", "Muenster", "Blue", "Cabot", "Gouda", "Feta", "Brie", "Stilton", "American", "Asagio" });
    FarPoint.Win.Chart.StringCollectionItem collection3 = new FarPoint.Win.Chart.StringCollectionItem();
    collection3.AddRange(new String[] { "", "", "", "", "", "", "", "", "", "", "Week1" });
    series.CategoryNames.AddRange(new FarPoint.Win.Chart.StringCollectionItem[] { collection1, collection2, collection3 });
  5. Add any legends or labels.
    FarPoint.Win.Chart.LegendArea label = new FarPoint.Win.Chart.LegendArea();
    label.TextFont = new System.Drawing.Font("Calibri", 10);
    label.TextFill = new FarPoint.Win.Chart.SolidFill(System.Drawing.Color.Black);
  6. Create a plot area and add the series to the plot area.
    FarPoint.Win.Chart.SunburstPlotArea plotArea = new FarPoint.Win.Chart.SunburstPlotArea();
    plotArea.Location = new PointF(0.2f, 0.2f);
    plotArea.Size = new SizeF(0.6f, 0.6f);
    plotArea.Series.Add(series);
  7. Create a chart model and add the plot area and legend.
    FarPoint.Win.Chart.ChartModel model = new FarPoint.Win.Chart.ChartModel();
    model.PlotAreas.Add(plotArea);
    model.LegendAreas.Add(label);
  8. Create a chart object, set the size and location, and assign the model.
    FarPoint.Win.Spread.Chart.SpreadChart chart = new FarPoint.Win.Spread.Chart.SpreadChart();
    chart.Size = new Size(600, 700);
    chart.Location = new System.Drawing.Point(50, 50);
    chart.Model = model;
  9. Add the chart to Spread.
    fpSpread1.Sheets[0].Charts.Add(chart);

Here is the complete Spread for Windows Forms C# code:

FarPoint.Win.Chart.SunburstSeries series = new FarPoint.Win.Chart.SunburstSeries();
series.Values.AddRange(new double[] { 350, 100, 80, 85, 90, 200, 350, 450, 500, 650, 220 });
series.Fills.AddRange(new FarPoint.Win.Chart.Fill[] { new FarPoint.Win.Chart.SolidFill(Color.Blue), new FarPoint.Win.Chart.SolidFill(Color.Teal), new FarPoint.Win.Chart.SolidFill(Color.DarkGoldenrod), new
FarPoint.Win.Chart.SolidFill(Color.DarkSalmon), new FarPoint.Win.Chart.SolidFill(Color.DarkGreen), new FarPoint.Win.Chart.SolidFill(Color.Chocolate), new FarPoint.Win.Chart.SolidFill(Color.Navy), new
FarPoint.Win.Chart.SolidFill(Color.DarkOrange), new FarPoint.Win.Chart.SolidFill(Color.OrangeRed), new FarPoint.Win.Chart.SolidFill(Color.Tomato), new FarPoint.Win.Chart.SolidFill(Color.Firebrick), new
FarPoint.Win.Chart.SolidFill(Color.Gray), new FarPoint.Win.Chart.SolidFill(Color.Olive), new FarPoint.Win.Chart.SolidFill(Color.Teal) });
FarPoint.Win.Chart.StringCollectionItem collection1 = new FarPoint.Win.Chart.StringCollectionItem();
collection1.AddRange(new String[] { "Store 1", "", "", "", "", "", "Store 2", "", "", "Store 3" });
FarPoint.Win.Chart.StringCollectionItem collection2 = new FarPoint.Win.Chart.StringCollectionItem();
collection2.AddRange(new String[] { "Asagio", "Swiss", "Muenster", "Blue", "Cabot", "Gouda", "Feta", "Brie", "Stilton", "American", "Asagio" });
FarPoint.Win.Chart.StringCollectionItem collection3 = new FarPoint.Win.Chart.StringCollectionItem();
collection3.AddRange(new String[] { "", "", "", "", "", "", "", "", "", "", "Week1" });
series.CategoryNames.AddRange(new FarPoint.Win.Chart.StringCollectionItem[] { collection1, collection2, collection3 });
FarPoint.Win.Chart.LegendArea label = new FarPoint.Win.Chart.LegendArea();
label.TextFont = new System.Drawing.Font("Calibri", 10);
label.TextFill = new FarPoint.Win.Chart.SolidFill(System.Drawing.Color.Black);
FarPoint.Win.Chart.SunburstPlotArea plotArea = new FarPoint.Win.Chart.SunburstPlotArea();
plotArea.Location = new PointF(0.2f, 0.2f);
plotArea.Size = new SizeF(0.6f, 0.6f);
plotArea.Series.Add(series);
FarPoint.Win.Chart.ChartModel model = new FarPoint.Win.Chart.ChartModel();
model.PlotAreas.Add(plotArea);
model.LegendAreas.Add(label);
FarPoint.Win.Spread.Chart.SpreadChart chart = new FarPoint.Win.Spread.Chart.SpreadChart();
chart.Size = new Size(600, 700);
chart.Location = new System.Drawing.Point(50, 50);
chart.Model = model;
fpSpread1.Sheets[0].Charts.Add(chart);

Here is the complete Spread for Windows Forms VB code:

Dim series As New FarPoint.Win.Chart.SunburstSeries()
series.Values.AddRange(New Double() {350, 100, 80, 85, 90, 200, 350, 450, 500, 650, 220})
series.Fills.AddRange(New FarPoint.Win.Chart.Fill() {New FarPoint.Win.Chart.SolidFill(Color.Blue), New FarPoint.Win.Chart.SolidFill(Color.Teal), New FarPoint.Win.Chart.SolidFill(Color.DarkGoldenrod), New FarPoint.Win.Chart.SolidFill(Color.DarkSalmon), New FarPoint.Win.Chart.SolidFill(Color.DarkGreen), New FarPoint.Win.Chart.SolidFill(Color.Chocolate), New FarPoint.Win.Chart.SolidFill(Color.Navy), New FarPoint.Win.Chart.SolidFill(Color.DarkOrange), New FarPoint.Win.Chart.SolidFill(Color.OrangeRed), New FarPoint.Win.Chart.SolidFill(Color.Tomato), New FarPoint.Win.Chart.SolidFill(Color.Firebrick), New FarPoint.Win.Chart.SolidFill(Color.Gray), New FarPoint.Win.Chart.SolidFill(Color.Olive), New FarPoint.Win.Chart.SolidFill(Color.Teal)})
Dim collection1 As New FarPoint.Win.Chart.StringCollectionItem()
collection1.AddRange(New String() {"Store 1", "", "", "", "", "", "Store 2", "", "", "Store 3"})
Dim collection2 As New FarPoint.Win.Chart.StringCollectionItem()
collection2.AddRange(New String() {"Asagio", "Swiss", "Muenster", "Blue", "Cabot", "Gouda", "Feta", "Brie", "Stilton", "American", "Asagio"})
Dim collection3 As New FarPoint.Win.Chart.StringCollectionItem()
collection3.AddRange(New String() {"", "", "", "", "", "", "", "", "", "", "Week1"})
series.CategoryNames.AddRange(New FarPoint.Win.Chart.StringCollectionItem() {collection1, collection2, collection3})
Dim Label As New FarPoint.Win.Chart.LegendArea()
Label.TextFont = New System.Drawing.Font("Calibri", 10)
Label.TextFill = New FarPoint.Win.Chart.SolidFill(System.Drawing.Color.Black)
Dim plotArea As New FarPoint.Win.Chart.SunburstPlotArea()
plotArea.Location = New PointF(0.2F, 0.2F)
plotArea.Size = New SizeF(0.6F, 0.6F)
plotArea.Series.Add(series)
Dim model As New FarPoint.Win.Chart.ChartModel()
model.PlotAreas.Add(plotArea)
model.LegendAreas.Add(Label)
Dim chart As New FarPoint.Win.Spread.Chart.SpreadChart()
chart.Size = New Size(600, 700)
chart.Location = New System.Drawing.Point(50, 50)
chart.Model = model
FpSpread1.Sheets(0).Charts.Add(chart)

Here is the complete Spread for ASP.NET C# code:

FarPoint.Web.Chart.SunburstSeries series = new FarPoint.Web.Chart.SunburstSeries();
series.Values.AddRange(new double[] { 350, 100, 80, 85, 90, 200, 350, 450, 500, 650, 220 });
series.Fills.AddRange(new FarPoint.Web.Chart.Fill[] { new FarPoint.Web.Chart.SolidFill(Color.Blue), new FarPoint.Web.Chart.SolidFill(Color.Teal), new FarPoint.Web.Chart.SolidFill(Color.DarkGoldenrod), new
FarPoint.Web.Chart.SolidFill(Color.DarkSalmon), new FarPoint.Web.Chart.SolidFill(Color.DarkGreen), new FarPoint.Web.Chart.SolidFill(Color.Chocolate), new FarPoint.Web.Chart.SolidFill(Color.Navy), new
FarPoint.Web.Chart.SolidFill(Color.DarkOrange), new FarPoint.Web.Chart.SolidFill(Color.OrangeRed), new FarPoint.Web.Chart.SolidFill(Color.Tomato), new FarPoint.Web.Chart.SolidFill(Color.Firebrick), new
FarPoint.Web.Chart.SolidFill(Color.Gray), new FarPoint.Web.Chart.SolidFill(Color.Olive), new FarPoint.Web.Chart.SolidFill(Color.Teal) });
FarPoint.Web.Chart.StringCollectionItem collection1 = new FarPoint.Web.Chart.StringCollectionItem();
collection1.AddRange(new String[] { "Store 1", "", "", "", "", "", "Store 2", "", "", "Store 3" });
FarPoint.Web.Chart.StringCollectionItem collection2 = new FarPoint.Web.Chart.StringCollectionItem();
collection2.AddRange(new String[] { "Asagio", "Swiss", "Muenster", "Blue", "Cabot", "Gouda", "Feta", "Brie", "Stilton", "American", "Asagio" });
FarPoint.Web.Chart.StringCollectionItem collection3 = new FarPoint.Web.Chart.StringCollectionItem();
collection3.AddRange(new String[] { "", "", "", "", "", "", "", "", "", "", "Week1" });
series.CategoryNames.AddRange(new FarPoint.Web.Chart.StringCollectionItem[] { collection1, collection2, collection3 });
FarPoint.Web.Chart.LegendArea label = new FarPoint.Web.Chart.LegendArea();
label.TextFont = new System.Drawing.Font("Calibri", 10);
label.TextFill = new FarPoint.Web.Chart.SolidFill(System.Drawing.Color.Black);
FarPoint.Web.Chart.SunburstPlotArea plotArea = new FarPoint.Web.Chart.SunburstPlotArea();
plotArea.Location = new PointF(0.2f, 0.2f);
plotArea.Size = new SizeF(0.6f, 0.6f);
plotArea.Series.Add(series);
FarPoint.Web.Chart.ChartModel model = new FarPoint.Web.Chart.ChartModel();
model.PlotAreas.Add(plotArea);
model.LegendAreas.Add(label);
FarPoint.Web.Spread.Chart.SpreadChart chart = new FarPoint.Web.Spread.Chart.SpreadChart();
chart.Width = 600;
chart.Height = 700;
chart.Model = model;
FpSpread1.Sheets[0].Charts.Add(chart);

Here is the complete Spread for ASP.NET VB code:

Dim series As New FarPoint.Web.Chart.SunburstSeries()
series.Values.AddRange(New Double() {350, 100, 80, 85, 90, 200, 350, 450, 500, 650, 220})
series.Fills.AddRange(New FarPoint.Web.Chart.Fill() {New FarPoint.Web.Chart.SolidFill(Color.Blue), New FarPoint.Web.Chart.SolidFill(Color.Teal), New FarPoint.Web.Chart.SolidFill(Color.DarkGoldenrod), New FarPoint.Web.Chart.SolidFill(Color.DarkSalmon), New FarPoint.Web.Chart.SolidFill(Color.DarkGreen), New FarPoint.Web.Chart.SolidFill(Color.Chocolate), New FarPoint.Web.Chart.SolidFill(Color.Navy), New FarPoint.Web.Chart.SolidFill(Color.DarkOrange), New FarPoint.Web.Chart.SolidFill(Color.OrangeRed), New FarPoint.Web.Chart.SolidFill(Color.Tomato), New FarPoint.Web.Chart.SolidFill(Color.Firebrick), New FarPoint.Web.Chart.SolidFill(Color.Gray), New FarPoint.Web.Chart.SolidFill(Color.Olive), New FarPoint.Web.Chart.SolidFill(Color.Teal)})
Dim collection1 As New FarPoint.Web.Chart.StringCollectionItem()
collection1.AddRange(New String() {"Store 1", "", "", "", "", "", "Store 2", "", "", "Store 3"})
Dim collection2 As New FarPoint.Web.Chart.StringCollectionItem()
collection2.AddRange(New String() {"Asagio", "Swiss", "Muenster", "Blue", "Cabot", "Gouda", "Feta", "Brie", "Stilton", "American", "Asagio"})
Dim collection3 As New FarPoint.Web.Chart.StringCollectionItem()
collection3.AddRange(New String() {"", "", "", "", "", "", "", "", "", "", "Week1"})
series.CategoryNames.AddRange(New FarPoint.Web.Chart.StringCollectionItem() {collection1, collection2, collection3})
Dim Label As New FarPoint.Web.Chart.LegendArea()
Label.TextFont = New System.Drawing.Font("Calibri", 10)
Label.TextFill = New FarPoint.Web.Chart.SolidFill(System.Drawing.Color.Black)
Dim plotArea As New FarPoint.Web.Chart.SunburstPlotArea()
plotArea.Location = New PointF(0.2F, 0.2F)
plotArea.Size = New SizeF(0.6F, 0.6F)
plotArea.Series.Add(series)
Dim model As New FarPoint.Web.Chart.ChartModel()
model.PlotAreas.Add(plotArea)
model.LegendAreas.Add(Label)
Dim chart As New FarPoint.Web.Spread.Chart.SpreadChart()
chart.Width = 600
chart.Height = 700
chart.Model = model
FpSpread1.Sheets(0).Charts.Add(chart)

You can also add charts in the Spread Designer. Simply add the data to the designer, select the data, and then select the chart type (Insert, Create Chart dialog, and Sunburst).

winsundesign1

Add and Select Data

winsundesign2

Insert Sunburst Chart

winsundesign3

Sunburst Chart


Spread for Windows Forms and the GcComboBox Cell

$
0
0

A combo box can be useful when creating a form for users such as an on-line order form.

The new GcComboBox cell in Spread for Windows Forms allows you to set different backcolors for each list item. The GcComboBox also has a resize icon that allows you to resize the drop-down list. Both the GcComboBox cell and the original Spread combo box cell allow you to add images to the drop-down list. The GcComboBox cell can display the image in the edit area with the TextBoxStyle property.

The following example creates a simple form that displays a price when you select from a list of dessert flavors.

gccombo

GcComboBox Cell

selected

Selected Item

Use the following steps to create this example:

  1. Add images to an image list.
    ImageList img = new ImageList();
    img.Images.Add(Image.FromFile("C:\\Program Files (x86)\\GrapeCity\\rasp.png"));
    img.Images.Add(Image.FromFile("C:\\Program Files (x86)\\GrapeCity\\vanilla.png"));
    img.Images.Add(Image.FromFile("C:\\Program Files (x86)\\GrapeCity\\choco.png"));
    img.Images.Add(Image.FromFile("C:\\Program Files (x86)\\GrapeCity\\banana.png"));
  2. Create the GcComboBox cell.
    GrapeCity.Win.Spread.InputMan.CellType.GcComboBoxCellType gccombo = new GrapeCity.Win.Spread.InputMan.CellType.GcComboBoxCellType();
  3. Set cell properties and add the list items.
    gccombo.DropDownStyle = ComboBoxStyle.DropDownList;
    gccombo.Items.AddRange(new String[] { "Raspberry", "Vanilla", "Chocolate", "Banana" });
  4. Set colors and images for the list items. Assign the image list to the cell.
    gccombo.Items[0].BackColor = Color.Fuchsia;
    gccombo.Items[1].BackColor = Color.Ivory;
    gccombo.Items[2].BackColor = Color.Chocolate;
    gccombo.Items[3].BackColor = Color.LightYellow;
    gccombo.ImageList = img;
    gccombo.Items[0].Image = 0;
    gccombo.Items[1].Image = 1;
    gccombo.Items[2].Image = 2;
    gccombo.Items[3].Image = 3;
    gccombo.ShowListBoxImage = true;
  5. Set any cell formatting properties.
    gccombo.ImageAlign = HorizontalAlignment.Right;
    gccombo.ListSelectedItemStyle.BackColor = Color.Bisque;
    gccombo.ListSelectedItemStyle.ForeColor = Color.Black;
  6. Assign the cell type to the cell location.
    fpSpread1.Sheets[0].Cells[1, 1].CellType = gccombo;
  7. Add the currency cell.
    FarPoint.Win.Spread.CellType.CurrencyCellType currencycell = new FarPoint.Win.Spread.CellType.CurrencyCellType();
    fpSpread1.Sheets[0].Cells[1, 2].CellType = currencycell;
  8. Add text information and set the font and alignment.
    fpSpread1.Sheets[0].Cells[0, 1].Text = "Select a flavor";
    fpSpread1.Sheets[0].Cells[0, 2].Text = "Total";
    fpSpread1.Sheets[0].Columns[1, 2].Font = new Font("Calibri", 10, FontStyle.Bold);
    fpSpread1.Sheets[0].Columns[1, 2].HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center;
    fpSpread1.Sheets[0].Rows[1].VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center;
  9. Use the ComboSelChange event to get the selection and set the price.
    private void fpSpread1_ComboSelChange(object sender, FarPoint.Win.Spread.EditorNotifyEventArgs e)
    {
    string caseSwitch;
    caseSwitch = fpSpread1.Sheets[0].Cells[1, 1].Text;
    switch (caseSwitch)
    {
    case "Raspberry":
    fpSpread1.Sheets[0].Cells[1, 2].Value = 5.00;
    break;
    case "Vanilla":
    fpSpread1.Sheets[0].Cells[1, 2].Value = 4.00;
    break;
    case "Chocolate":
    fpSpread1.Sheets[0].Cells[1, 2].Value = 4.25;
    break;
    case "Banana":
    fpSpread1.Sheets[0].Cells[1, 2].Value = 4.75;
    break;
    }
    }

Here is the complete example in C#:

// Select dessert flavor.
ImageList img = new ImageList();
img.Images.Add(Image.FromFile("C:\\Program Files (x86)\\GrapeCity\\rasp.png"));
img.Images.Add(Image.FromFile("C:\\Program Files (x86)\\GrapeCity\\vanilla.png"));
img.Images.Add(Image.FromFile("C:\\Program Files (x86)\\GrapeCity\\choco.png"));
img.Images.Add(Image.FromFile("C:\\Program Files (x86)\\GrapeCity\\banana.png"));
GrapeCity.Win.Spread.InputMan.CellType.GcComboBoxCellType gccombo = new GrapeCity.Win.Spread.InputMan.CellType.GcComboBoxCellType();
gccombo.DropDownStyle = ComboBoxStyle.DropDownList;
gccombo.Items.AddRange(new String[] { "Raspberry", "Vanilla", "Chocolate", "Banana" });
gccombo.Items[0].BackColor = Color.Fuchsia;
gccombo.Items[1].BackColor = Color.Ivory;
gccombo.Items[2].BackColor = Color.Chocolate;
gccombo.Items[3].BackColor = Color.LightYellow;

gccombo.ImageList = img;
gccombo.Items[0].Image = 0;
gccombo.Items[1].Image = 1;
gccombo.Items[2].Image = 2;
gccombo.Items[3].Image = 3;
gccombo.ShowListBoxImage = true;
gccombo.ImageAlign = HorizontalAlignment.Right;
gccombo.ListSelectedItemStyle.BackColor = Color.Bisque;
gccombo.ListSelectedItemStyle.ForeColor = Color.Black;
fpSpread1.Sheets[0].Cells[1, 1].CellType = gccombo;
fpSpread1.Sheets[0].Columns[1].Width = 200;
fpSpread1.Sheets[0].Rows[1].Height = 40;
FarPoint.Win.Spread.CellType.CurrencyCellType currencycell = new FarPoint.Win.Spread.CellType.CurrencyCellType();
fpSpread1.Sheets[0].Cells[1, 2].CellType = currencycell;
fpSpread1.Sheets[0].Cells[0, 1].Text = "Select a flavor";
fpSpread1.Sheets[0].Cells[0, 2].Text = "Total";
fpSpread1.Sheets[0].Columns[1, 2].Font = new Font("Calibri", 10, FontStyle.Bold);
fpSpread1.Sheets[0].Columns[1, 2].HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center;
fpSpread1.Sheets[0].Rows[1].VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center;

private void fpSpread1_ComboSelChange(object sender, FarPoint.Win.Spread.EditorNotifyEventArgs e)
{
string caseSwitch;
caseSwitch = fpSpread1.Sheets[0].Cells[1, 1].Text;
switch (caseSwitch)
{
case "Raspberry":
fpSpread1.Sheets[0].Cells[1, 2].Value = 5.00;
break;
case "Vanilla":
fpSpread1.Sheets[0].Cells[1, 2].Value = 4.00;
break;
case "Chocolate":
fpSpread1.Sheets[0].Cells[1, 2].Value = 4.25;
break;
case "Banana":
fpSpread1.Sheets[0].Cells[1, 2].Value = 4.75;
break;
}
}

Here is the complete example in VB:

Dim img As New ImageList()
img.Images.Add(Image.FromFile("C:\Program Files (x86)\GrapeCity\rasp.png"))
img.Images.Add(Image.FromFile("C:\Program Files (x86)\GrapeCity\vanilla.png"))
img.Images.Add(Image.FromFile("C:\Program Files (x86)\GrapeCity\choco.png"))
img.Images.Add(Image.FromFile("C:\Program Files (x86)\GrapeCity\banana.png"))
Dim gccombo As New GrapeCity.Win.Spread.InputMan.CellType.GcComboBoxCellType()
gccombo.DropDownStyle = ComboBoxStyle.DropDownList
gccombo.Items.AddRange(New String() {"Raspberry", "Vanilla", "Chocolate", "Banana"})
gccombo.Items(0).BackColor = Color.Fuchsia
gccombo.Items(1).BackColor = Color.Ivory
gccombo.Items(2).BackColor = Color.Chocolate
gccombo.Items(3).BackColor = Color.LightYellow
gccombo.ImageList = img
gccombo.Items(0).Image = 0
gccombo.Items(1).Image = 1
gccombo.Items(2).Image = 2
gccombo.Items(3).Image = 3
gccombo.ShowListBoxImage = True
gccombo.ImageAlign = HorizontalAlignment.Right
gccombo.ListSelectedItemStyle.BackColor = Color.Bisque
gccombo.ListSelectedItemStyle.ForeColor = Color.Black
FpSpread1.Sheets(0).Cells(1, 1).CellType = gccombo
FpSpread1.Sheets(0).Columns(1).Width = 200
FpSpread1.Sheets(0).Rows(1).Height = 40
Dim currencycell As New FarPoint.Win.Spread.CellType.CurrencyCellType()
FpSpread1.Sheets(0).Cells(1, 2).CellType = currencycell
FpSpread1.Sheets(0).Cells(0, 1).Text = "Select a flavor"
FpSpread1.Sheets(0).Cells(0, 2).Text = "Total"
FpSpread1.Sheets(0).Columns(1, 2).Font = New Font("Calibri", 10, FontStyle.Bold)
FpSpread1.Sheets(0).Columns(1, 2).HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center
FpSpread1.Sheets(0).Rows(1).VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center
Private Sub FpSpread1_ComboSelChange(sender As Object, e As FarPoint.Win.Spread.EditorNotifyEventArgs) Handles FpSpread1.ComboSelChange
Dim caseSwitch As String
caseSwitch = FpSpread1.Sheets(0).Cells(1, 1).Text
Select Case caseSwitch
Case "Raspberry"
FpSpread1.Sheets(0).Cells(1, 2).Value = 5.0
Exit Select
Case "Vanilla"
FpSpread1.Sheets(0).Cells(1, 2).Value = 4.0
Exit Select
Case "Chocolate"
FpSpread1.Sheets(0).Cells(1, 2).Value = 4.25
Exit Select
Case "Banana"
FpSpread1.Sheets(0).Cells(1, 2).Value = 4.75
Exit Select
End Select
End Sub

The following help topic has information about adding the Spread component to a Visual Studio project: http://sphelp.grapecity.com/WebHelp/SpreadNet10/WF/webframe.html#spwin-vs2015add.html.

For more information about the GcComboBox cell, refer to http://sphelp.grapecity.com/WebHelp/SpreadNet10/WF/webframe.html#spwin-gccombo.html.

Spread Windows Forms and the Waterfall Chart

$
0
0

A Waterfall chart is a popular visualization tool that you can now use in Spread for Windows Forms, a Visual Studio .NET control. Spread for Windows Forms also supports many other chart types. You can see a list of the many product features on our web site at http://spread.grapecity.com/spread-studio/.

Row after row of sales information can be time consuming to review. The Waterfall chart allows you to quickly see key items such as net profit when displaying company profits and expenses.

waterfallchart

Waterfall Chart

You can easily create a Waterfall chart using the Spread Designer or code.

Use the following steps to create a Waterfall chart with sales data in the Spread Designer. Refer to the following help topic for information about starting the Spread Designer: http://sphelp.grapecity.com/WebHelp/SpreadNet10/WF/webframe.html#spwin-spd-launch.html.

  1. Add your data to the designer.
  2. Select the Insert tab.
    waterfalldesign1

    Chart Data

  3. Select the Waterfall chart in the Insert Chart dialog from the Other Charts option.
    waterfalldesign2

    Add Chart

  4. Select OK.
    waterfalldesign3

    Format Chart

  5. Double-click on the data point to select the data point you want to apply colors to.
  6. Right-click on the selected data point and choose the Format Data Point option.
    waterfalldesign4

    Format Data Point

  7. Set the gradient color and then select Close.
    waterfalldesign5

    Set Color

You have now created the sample using the Spread Windows Forms designer.

Use the following steps to create the same Waterfall chart using code.

  1. Create a series object.
    FarPoint.Win.Chart.WaterfallSeries wseries = new FarPoint.Win.Chart.WaterfallSeries();
  2. Create a series name.
    wseries.SeriesName = "Series0";
  3. Add category names for your sales data.
    wseries.CategoryNames.Add("Sales Revenue");
    wseries.CategoryNames.Add("Rent");
    wseries.CategoryNames.Add("Payroll");
    wseries.CategoryNames.Add("Other Expenses");
    wseries.CategoryNames.Add("Net Profit");
  4. Add your sales values to the series.
    wseries.Values.Add(200000);
    wseries.Values.Add(-12000);
    wseries.Values.Add(-80000);
    wseries.Values.Add(-30000);
    wseries.Values.Add(78000);
  5. Add any borders or fills to improve the appearance of your chart.
    wseries.Border = new FarPoint.Win.Chart.SolidLine(Color.Black);
    wseries.Fills.AddRange(new FarPoint.Win.Chart.Fill[] { null, new FarPoint.Win.Chart.GradientFill(Color.Red, Color.Orange), new FarPoint.Win.Chart.GradientFill(Color.Red, Color.Orange), new FarPoint.Win.Chart.GradientFill(Color.Red, Color.Orange) , null});
  6. Create the plot area, set properties such as location, and add the series.
    FarPoint.Win.Chart.YPlotArea plotArea = new FarPoint.Win.Chart.YPlotArea();
    plotArea.Location = new System.Drawing.PointF(0.2f, 0.2f);
    plotArea.Size = new System.Drawing.SizeF(0.6f, 0.6f);
    plotArea.Series.Add(wseries);
    plotArea.XAxis.Title = "Company Profit";
    plotArea.XAxis.TitleOffset = 30;
  7. Create a chart model object and add the plot area.
    FarPoint.Win.Chart.ChartModel model = new FarPoint.Win.Chart.ChartModel();
    model.PlotAreas.Add(plotArea);
  8. Create a SpreadChart object, add the model, set additional properties such as the chart location, and then add the chart to the sheet.
    FarPoint.Win.Spread.Chart.SpreadChart chart = new FarPoint.Win.Spread.Chart.SpreadChart();
    chart.Model = model;
    chart.Size = new Size(800, 400);
    chart.Location = new Point(100, 100);
    fpSpread1.Sheets[0].Charts.Add(chart);

waterfallchart

These are all the steps you need to create a Waterfall chart in Spread for Windows Forms.

Here is the complete example in C#:

FarPoint.Win.Chart.WaterfallSeries wseries = new FarPoint.Win.Chart.WaterfallSeries();
wseries.SeriesName = "Series0";
wseries.CategoryNames.Add("Sales Revenue");
wseries.CategoryNames.Add("Rent");
wseries.CategoryNames.Add("Payroll");
wseries.CategoryNames.Add("Other Expenses");
wseries.CategoryNames.Add("Net Profit");
wseries.Values.Add(200000);
wseries.Values.Add(-12000);
wseries.Values.Add(-80000);
wseries.Values.Add(-30000);
wseries.Values.Add(78000);
wseries.Border = new FarPoint.Win.Chart.SolidLine(Color.Black);
wseries.Fills.AddRange(new FarPoint.Win.Chart.Fill[] { null, new FarPoint.Win.Chart.GradientFill(Color.Red, Color.Orange), new FarPoint.Win.Chart.GradientFill(Color.Red, Color.Orange), new FarPoint.Win.Chart.GradientFill(Color.Red, Color.Orange) , null});
FarPoint.Win.Chart.YPlotArea plotArea = new FarPoint.Win.Chart.YPlotArea();
plotArea.Location = new System.Drawing.PointF(0.2f, 0.2f);
plotArea.Size = new System.Drawing.SizeF(0.6f, 0.6f);
plotArea.Series.Add(wseries);
plotArea.XAxis.Title = "Company Profit";
plotArea.XAxis.TitleOffset = 30;
FarPoint.Win.Chart.ChartModel model = new FarPoint.Win.Chart.ChartModel();
model.PlotAreas.Add(plotArea);
FarPoint.Win.Spread.Chart.SpreadChart chart = new FarPoint.Win.Spread.Chart.SpreadChart();
chart.Model = model;
chart.Size = new Size(800, 400);
chart.Location = new Point(100, 100);
fpSpread1.Sheets[0].Charts.Add(chart);

Here is the complete example in Visual Basic:

Dim wseries As New FarPoint.Win.Chart.WaterfallSeries()
wseries.SeriesName = "Series0"
wseries.CategoryNames.Add("Sales Revenue")
wseries.CategoryNames.Add("Rent")
wseries.CategoryNames.Add("Payroll")
wseries.CategoryNames.Add("Other Expenses")
wseries.CategoryNames.Add("Net Profit")
wseries.Values.Add(200000)
wseries.Values.Add(-12000)
wseries.Values.Add(-80000)
wseries.Values.Add(-30000)
wseries.Values.Add(78000)
wseries.Border = New FarPoint.Win.Chart.SolidLine(Color.Black)
wseries.Fills.AddRange(New FarPoint.Win.Chart.Fill() {Nothing, New FarPoint.Win.Chart.GradientFill(Color.Red, Color.Orange), New FarPoint.Win.Chart.GradientFill(Color.Red, Color.Orange),
New FarPoint.Win.Chart.GradientFill(Color.Red, Color.Orange), Nothing})
Dim plotArea As New FarPoint.Win.Chart.YPlotArea()
plotArea.Location = New System.Drawing.PointF(0.2F, 0.2F)
plotArea.Size = New System.Drawing.SizeF(0.6F, 0.6F)
plotArea.Series.Add(wseries)
plotArea.XAxis.Title = "Company Profit"
plotArea.XAxis.TitleOffset = 30
Dim model As New FarPoint.Win.Chart.ChartModel()
model.PlotAreas.Add(plotArea)
Dim chart As New FarPoint.Win.Spread.Chart.SpreadChart()
chart.Model = model
chart.Size = New Size(800, 400)
chart.Location = New Point(100, 100)
FpSpread1.Sheets(0).Charts.Add(chart)

You can also use a data source for the chart. For example:

C#

object[] values = new object[] { 200000, -12000, -80000, -30000, 78000 };
string[] names = new string[] { "Sales Revenue", "Rent", "Payroll", "Other Expenses", "Net Profit" };
FarPoint.Win.Chart.WaterfallSeries wseries = new FarPoint.Win.Chart.WaterfallSeries();
wseries.Values.DataSource = values;
wseries.SeriesName = "Series0";
wseries.CategoryNames.DataSource = names;
wseries.Border = new FarPoint.Win.Chart.SolidLine(Color.Black);
wseries.Fills.AddRange(new FarPoint.Win.Chart.Fill[] { null, new FarPoint.Win.Chart.GradientFill(Color.Red, Color.Orange), new FarPoint.Win.Chart.GradientFill(Color.Red, Color.Orange), new
FarPoint.Win.Chart.GradientFill(Color.Red, Color.Orange), null });
FarPoint.Win.Chart.YPlotArea plotArea = new FarPoint.Win.Chart.YPlotArea();
plotArea.Location = new System.Drawing.PointF(0.2f, 0.2f);
plotArea.Size = new System.Drawing.SizeF(0.6f, 0.6f);
plotArea.Series.Add(wseries);
plotArea.XAxis.Title = "Company Profit";
plotArea.XAxis.TitleOffset = 30;
FarPoint.Win.Chart.ChartModel model = new FarPoint.Win.Chart.ChartModel();
model.PlotAreas.Add(plotArea);
FarPoint.Win.Spread.Chart.SpreadChart chart = new FarPoint.Win.Spread.Chart.SpreadChart();
chart.Model = model;
chart.Size = new Size(800, 400);
chart.Location = new Point(100, 100);
fpSpread1.Sheets[0].Charts.Add(chart);

Visual Basic

Dim values As Object() = {200000, -12000, -80000, -30000, 78000}
Dim names As String() = {"Sales Revenue", "Rent", "Payroll", "Other Expenses", "Net Profit"}
Dim wseries As New FarPoint.Win.Chart.WaterfallSeries()
wseries.Values.DataSource = values
wseries.SeriesName = "Series0"
wseries.CategoryNames.DataSource = names
wseries.Border = New FarPoint.Win.Chart.SolidLine(Color.Black)
wseries.Fills.AddRange(New FarPoint.Win.Chart.Fill() {Nothing, New FarPoint.Win.Chart.GradientFill(Color.Red, Color.Orange), New FarPoint.Win.Chart.GradientFill(Color.Red, Color.Orange),
New FarPoint.Win.Chart.GradientFill(Color.Red, Color.Orange), Nothing})
Dim plotArea As New FarPoint.Win.Chart.YPlotArea()
plotArea.Location = New System.Drawing.PointF(0.2F, 0.2F)
plotArea.Size = New System.Drawing.SizeF(0.6F, 0.6F)
plotArea.Series.Add(wseries)
plotArea.XAxis.Title = "Company Profit"
plotArea.XAxis.TitleOffset = 30
Dim model As New FarPoint.Win.Chart.ChartModel()
model.PlotAreas.Add(plotArea)
Dim chart As New FarPoint.Win.Spread.Chart.SpreadChart()
chart.Model = model
chart.Size = New Size(800, 400)
chart.Location = New Point(100, 100)
FpSpread1.Sheets(0).Charts.Add(chart)

You can download a trial of Spread for Windows Forms here: http://spread.grapecity.com/downloads/.

You can find more information about Spread Studio .NET here: http://spread.grapecity.com/spread-studio/.

Spread Studio V10 SP1 Release

$
0
0

Spread Studio V10 SP1 has now been released. This release adds support for Microsoft Visual Studio 2017 and fixes many reported issues. Here is a list of the resolved issues:

Spread Windows Forms:

  • X-axis labels are now correctly imported or exported. [227346]
  • Clearing the focus indicator now works correctly. [226341]

Spread ASP.NET:

  • Getting the font now works correctly. [230439]
  • Spread no longer loads duplicate script files with MVC. [228660]
  • Performance has been enhanced when editing cells. [224979]
  • Hyperlink cells now work correctly in the last visible column. [224704]
  • Spread now works correctly when the column header contains an ampersand. [224149]
  • The SaveHTML method now works correctly. [220869]

Spread WPF:

  • Formulas are now updated correctly when adding columns. [230048]

You can get more information in the ReadMe: http://sphelp.grapecity.com/WebHelp/SpreadStudio10ReadMe/webframe.html#ReadMe.html.

You can get the download here: http://spread.grapecity.com/downloads/.

Viewing all 38 articles
Browse latest View live