# Code39

DsExcel supports Code39 Barcode which uses nine bars to represent different symbols. Learn more in DsExcel docs.

## Content

Code 39 is a linear barcode that uses a total of nine bars to represent each symbol which includes numeric characters, upper case characters and some special characters ("%" , "\*", "$", "/", "." , "-", "+").
The below image displays Code39 barcode in a PDF document.
![Code39](https://cdn.mescius.io/document-site-files/images/dd59ea42-cd61-4fa6-a018-6231c2a9c598/images/code39.png)

## Formula definition

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

## Parameter

| Name | Description |
| ---- | ----------- |
| value | A string that represents encode on the symbol of QRCode. |
| 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. |
| labelWithStartAndStopCharacter | Specifies whether to show the start and stop character in the label. The default value is 'false'. |
| 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 |
| fullASCII | Specifies whether to support full ASCII for Code39. The default value is 'false'. |
| 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 Code39 in the worksheet.

```Java
// Create a new workbook
Workbook workbook = new Workbook();
// Set worksheet layout and data
IWorksheet worksheet = workbook.getWorksheets().get(0);
worksheet.getRange("B:C").setColumnWidth(15);
worksheet.getRange("D:H").setColumnWidth(25);
worksheet.getRange("4:6").setRowHeight(60);
worksheet.getRange("A:A").setColumnWidth(5);
worksheet.getRange("B2").setValue("Code39");
worksheet.getRange("B2:F2").setMergeCells(true);
worksheet.getRange("B3:H3")
        .setValue(new Object[][] { { "Name", "Number", "Default", "Change labelWithStartAndStopCharacter",
                "Change checkDigit", "Change checkDigit", "Change nwRatio", "Change fullASCII" } });
worksheet.getRange("B4:C7").setHorizontalAlignment(HorizontalAlignment.Center);
worksheet.getRange("B4:C7").setVerticalAlignment(VerticalAlignment.Center);
worksheet.getRange("B2:F3").setHorizontalAlignment(HorizontalAlignment.Center);
worksheet.getRange("B2:F3").setVerticalAlignment(VerticalAlignment.Center);
worksheet.getRange("B4:C6").setValue(new Object[][] { { "Paper", "6922266446146" }, { "Book", "9787560044231" },
        { "Value can contain some symbol", "1234+-#*" } });
worksheet.getRange("B4:C6").setWrapText(true);
worksheet.getRange("G6").setWrapText(true);
worksheet.getPageSetup().setPrintTitleColumns("$A:$C");
worksheet.getPageSetup().setOrientation(PageOrientation.Landscape);
worksheet.getPageSetup().setPrintGridlines(true);

// Set formula
for (int i = 4; i < 7; i++) {
    worksheet.getRange("D" + i).setFormula("=BC_CODE39" + "(C" + i + ")");
    worksheet.getRange("E" + i).setFormula("=BC_CODE39" + "(C" + i + ",,,,,\"true\")");
    worksheet.getRange("F" + i).setFormula("=BC_CODE39" + "(C" + i + ",,,,,,\"true\")");
    worksheet.getRange("G" + i).setFormula("=BC_CODE39" + "(C" + i + ",,,,,,,2)");
    worksheet.getRange("H" + i).setFormula("=BC_CODE39" + "(C" + i + ",,,,,,,,\"true\")");
}

// Save to an pdf file
workbook.save("Code39.pdf");
```