# Codabar

DsExcel supports Codabar Barcode which is mainly used where serial numbers are required. Learn more in DsExcel docs.

## Content

Codabar is a barcode that uses alphanumeric characters including, A B C D + - : . / $ and all numbers. This is widely used in sectors where serial numbers are required, such as blood Banks, door-to-door delivery service orders, and membership card management.
The below image displays Codabar barcode in a PDF document.
![Codabar](https://cdn.mescius.io/document-site-files/images/e333ad47-35da-43f9-a389-25433765f491/images/codabar.png)

## Formula definition

You can set codabar in a worksheet using the following formula:
=BC\_CODABAR(value, color, backgroudColor, showLabel, labelPosition, checkDigit, nwRatio, fontFamily, fontStyle, fontWeight, fontTextDecoration, fontTextAlign, fontSize, quietZoneLeft, quietZoneRight, quietZoneTop, quietZoneBottom)

## Parameter

| Name | Description |
| ---- | ----------- |
| value | A string that represents encode on the symbol of Codabar. |
| color | A color that represents the barcode color. The default value is 'rgb(0,0,0)'. |
| backgroundColor | A color that represents the barcode backgroundcolor. The default value is 'rgb(255, 255, 255)' |
| showLabel | Specifies whether to show label text when the barcode has label. |
| labelPosition | ​A value that represents the label position when the label is shown. |
| checkDigit | Specifies whether the symbol needs a check digit. The default value is 'false'. |
| nwRatio | A value that represents the wide and narrow bar ratio\. It has values 2\|3\. The default value is '3'\. |
| fontFamily | A string that represents the label text fontFamily. The default value is 'sans-serif'. |
| fontStyle | A string that represents the label text fontStyle. The default value is 'normal'. |
| fontWeight | A string that represents the label text fontWeight. The default value is 'normal'. |
| fontTextDecoration | A string that represents the label text fontTextDecoration. The default value is 'none'. |
| fontTextAlign | A string that represents the label text fontTextAlign. The default value is 'center'. |
| fontSize | A string that represents the label text fontSize. The default value is '12px'. |
| quietZoneLeft | A value that represents the size of left quiet zone. |
| quietZoneRight | A value that represents the size of right quiet zone. |
| quietZoneTop | A value that represents the size of top quiet zone. |
| quietZoneBottom | A value that represents the size of bottom quiet zone. |

## Using Code

This example code sets Codabar in the worksheet.

```csharp
// Create a new workbook
var workbook = new GrapeCity.Documents.Excel.Workbook();

// Set worksheet layout and data
IWorksheet worksheet = workbook.Worksheets[0];
worksheet.Range["B:F"].ColumnWidth = 20;
worksheet.Range["4:7"].RowHeight = 60;
worksheet.Range["A:A"].ColumnWidth = 5;
worksheet.Range["B2"].Value = "Codabar";
worksheet.Range["B2:F2"].Merge(true);
worksheet.Range["B3:G3"].Value = new object[,]{
{"Name", "Number", "Defult", "Change checkDigit", "Change nwRatio"}
};

worksheet.Range["B4:C7"].HorizontalAlignment = HorizontalAlignment.Center;
worksheet.Range["B4:C7"].VerticalAlignment = VerticalAlignment.Center;
worksheet.Range["B2:F3"].HorizontalAlignment = HorizontalAlignment.Center;
worksheet.Range["B2:F3"].VerticalAlignment = VerticalAlignment.Center;
worksheet.Range["B4:C6"].Value = new object[,]
   {
    {"Notebook", "6935205311092"},
    {"Paper", "6922266446146"},
    {"Value can contain letters and some symbol", "A1234+-/.$A"}
   };
worksheet.Range["B4:C6"].WrapText = true;
worksheet.Range["G6"].WrapText = true;
worksheet.PageSetup.Orientation = PageOrientation.Landscape;
worksheet.PageSetup.PrintGridlines = true;

// Set formula
for (var i = 4; i < 7; i++)
{
   worksheet.Range["D" + i].Formula = "=BC_CODABAR" + "(C" + i + ")";
   worksheet.Range["E" + i].Formula = "=BC_CODABAR" + "(C" + i + ",,,,,\"true\")";
   worksheet.Range["F" + i].Formula = "=BC_CODABAR" + "(C" + i + ",,,,,,\"2\")";
}

// Save to a pdf file
workbook.Save("codabar.pdf");
```

## Limitation

* The "checkDigit" parameter takes effect only when the 'value' parameter's length is 13 and the barcode's label text does not change.