[]
        
(Showing Draft Content)

Setting a Barcode Cell

You can display a barcode graphic in a barcode cell. Various barcode types are available such as barcodes that are used in retail, for shipping, and so on. You can set height and width properties for the barcode display.

Spread WinForms renders a numeric value as a barcode graphic inside a worksheet cell using BarCodeCellType.

You use the BarCodeCellType class to set the barcode cell and its properties.

Customizing the Appearance

You can customize the barcode cell by using these properties:

Property

Description

AcceptsCheckDigit

Sets whether to accept the check digit in the input.

AdjustSize

Sets whether the barcode adjusts its size based on the barcode size.

AutoStretch

Sets whether the size is based on the cell size.

BarAdjust

Sets whether to fine tune the width of the barcode.

BarCodePadding

Sets the left side and right side padding of the barcode.

BarSize

Sets the height and width of the barcode.

DisplayCheckDigit

Sets whether the check digit is available for the barcode.

DisplayMode

Sets whether the barcode draws a barcode image.

FixedLength

Sets the number of the fixed digits of the value of the barcode.

IsFormulaValue

Determines whether the editor contains a formula.

Message

Sets whether to display the custom message string below the barcode image (if the barcode type allows it).

MessagePosition

Sets the alignment of the custom message below the barcode image.

MessageValue

Sets a custom message to display below the barcode image.

MinimumHeight

Sets the minimum height of entire barcode.

ModuleSize

Sets the size of the barcode module.

Resolution

Sets the resolution of the barcode.

Rotation

Sets the rotation angle of the barcode.

Type

Sets the bar type of the barcode.

Unit

Sets the unit of measure of the barcode.

The FixedLength property only works with PostNet, ITF, or Code39 barcode types. The PostNet barcode option allows one less digit for the value than the setting for the FixedLength property.

Only the bar code types that have a line at the bottom to display the value can display a message (as set by the Message, MessagePosition, and MessageValue properties).

Barcode Types

Here is a sample image of each of the supported barcode types that can be set with the Type property. The Jan8 type is similar to the EAN8 type. For more information about barcode types, refer to this article: https://www.gs1.org/standards/barcodes.

Barcode Type

Sample Barcode Image

Code128

Spread WinForms renders sample value 72894736 as a Code128 barcode after configuring the BarCodeCellType Type property.

Code39

Spread WinForms renders sample value 72894736 as a Code39 barcode after configuring the BarCodeCellType Type property.

Code49

Spread WinForms renders sample value 72894736 as a stacked Code49 barcode using the BarCodeCellType Type property.

Code93

Spread WinForms renders sample value 72894736 as a Code93 barcode after configuring the BarCodeCellType Type property.

EAN128

Spread WinForms renders sample value 72894736 as an EAN128 barcode after configuring the BarCodeCellType Type property.

ITF

Spread WinForms renders the spaced value 72 89473 6 as an ITF barcode using the BarCodeCellType Type property.

Jan13

Spread WinForms renders the displayed numeric value as a JAN13 retail barcode using the BarCodeCellType Type property.

Jan8

Spread WinForms renders sample value 72894736 as a JAN8 retail barcode using the BarCodeCellType Type property.

JapanesePostal

Spread WinForms renders a JapanesePostal barcode with aligned vertical bars using the BarCodeCellType Type property.

NW7

Spread WinForms renders the displayed alphanumeric value as an NW7 barcode using the BarCodeCellType Type property.

PDF417

Spread WinForms renders a stacked two-dimensional PDF417 barcode using the configured BarCodeCellType Type property.

PostNet

Spread WinForms renders a PostNet barcode with tall and short vertical bars using the BarCodeCellType Type property.

QRCode

Spread WinForms renders a square QRCode matrix within the barcode cell using the BarCodeCellType Type property.

UPC

Spread WinForms renders the displayed numeric value as a UPC retail barcode using the BarCodeCellType Type property.

Customizing the Message

You can display a customizable text message at the bottom of the barcode cell for several barcode types. This is supported for those barcode types that display the number value below the barcode image. (For example, PostNet, PDF417, JapanesePostal, and QRCode do not display a message.) In the example here, the value has been replaced with a text message. The code that generated this barcode image is shown below. The message is set using these properties: Message, MessagePosition, and MessageValue.

Spread WinForms uses the BarCodeCellType MessageValue property to display custom text beneath the barcode instead of its value.

FarPoint.Win.Spread.CellType.BarCodeCellType barc = new FarPoint.Win.Spread.CellType.BarCodeCellType();
barc.DisplayMode = FarPoint.Win.Spread.CellType.BarCodeDisplayMode.Image;
barc.Message = true;
barc.MessagePosition = FarPoint.Win.Spread.CellType.BarCode.MessagePosition.Left;
barc.MessageValue = "Display This Instead of Value";
barc.Type = new FarPoint.Win.Spread.CellType.BarCode.UPC();
fpSpread1.ActiveSheet.Columns[0].Width = 220;
fpSpread1.ActiveSheet.Rows[0].Height = 100;
fpSpread1.ActiveSheet.Cells[0, 0].CellType = barc;
fpSpread1.ActiveSheet.Cells[0, 0].Value = 36000280753;
Dim barc As New FarPoint.Win.Spread.CellType.BarCodeCellType
barc.DisplayMode = FarPoint.Win.Spread.CellType.BarCodeDisplayMode.Image
barc.Message = True
barc.MessagePosition = FarPoint.Win.Spread.CellType.BarCode.MessagePosition.Left
barc.MessageValue = "Display This Instead of Value"
barc.Type = New FarPoint.Win.Spread.CellType.BarCode.UPC
fpSpread1.ActiveSheet.Columns(0).Width = 220
fpSpread1.ActiveSheet.Rows(0).Height = 100
fpSpread1.ActiveSheet.Cells(0, 0).CellType = barc
fpSpread1.ActiveSheet.Cells(0, 0).Value = 36000280753

Note that some graphical elements in certain cell types are affected by XP themes (visual styles). Setting the VisualStyles property of the Spread component to "off" can allow visual customizations of those graphical cell types to work as expected. For more information, refer to Using XP Themes with the Component.

For more information on the properties and methods of this cell type, refer to the BarCodeCellType class.

Using the Properties Window

  1. At design time, in the Properties window, select the Spread component.

  2. Select the Sheets property.

  3. Click the button to display the SheetView Collection Editor.

  4. In the Members list, select the sheet in which the cells appear.

  5. In the property list, select the Cells property and then click the button to display the Cell, Column, and Row Editor.

  6. Select the cells for which you want to set the cell type.

  7. In the property list, select the CellType property and choose the BarCode cell type.

  8. Expand the list of properties under the CellType property. Select and set these specific properties as needed.

  9. Click OK to close the Cell, Column, and Row Editor.

  10. Click OK to close the SheetView Collection Editor.

Using Code

  1. Define the barcode cell by creating an instance of the BarCodeCellType class.

  2. Specify the properties of the barcode cell.

  3. Assign the barcode cell to a cell or range of cells by setting the CellType property for a cell, column, row, or style to the BarCodeCellType object.

Example

This example creates a bar code cell.

FarPoint.Win.Spread.CellType.BarCodeCellType brcdcell = new FarPoint.Win.Spread.CellType.BarCodeCellType();
FpSpread1.Sheets[0].Cells[0, 0].CellType = brcdcell;
FpSpread1.Sheets[0].Cells[0, 0].Value = "12345";
Dim brcdcell As New FarPoint.Win.Spread.CellType.BarCodeCellType
FpSpread1.Sheets(0).Cells(0, 0).CellType = brcdcell
FpSpread1.Sheets(0).Cells(0, 0).Value = "12345"

Using the Spread Designer

  1. Select the cell or cells in the work area.

  2. In the property list, in the Misc category, select CellType. From the drop-down list, choose the BarCode cell type. Now expand the CellType property and various properties are available that are specific to this cell type. Select and set those properties as needed.

    Or right-click on the cell or cells and select Cell Type. From the list, select Barcode. In the CellType editor, set the properties you need. Click Apply.

  3. From the File menu choose Apply and Exit to apply your changes to the component and exit Spread Designer.