Barcode Generation

How to Create Barcodes in Excel: Font and CSV Methods

Learn to create a Code 39 barcode in Excel or prepare a CSV for a barcode generator, preserve leading zeros, and check each scan against its source.

Share
Table of contents

To create barcodes from Excel data, either apply a compatible barcode font to correctly prepared cells or export the data as a CSV file for a separate barcode generator. The font method can display a barcode in the worksheet; a CSV carries the values, not the barcode artwork. Whichever method you choose, scan the finished barcode and compare its decoded value with the original cell before using it.

Choose a method before you start

If you need to… Try Check first
Display a simple internal inventory code in a worksheet A compatible Code 39 font Your characters, font, scanner, and receiving system must all support the intended use.
Make barcode images or labels from a list Export a CSV to a compatible generator Confirm its accepted columns, barcode types, file formats, limits, and how it reports errors.
Label a product for a retailer Follow the retailer’s barcode and identifier requirements A spreadsheet or font does not issue a GTIN or establish permission to use one.

This guide uses a plain Code 39 font example for internal identifiers. It does not turn a SKU into a retail UPC. If a retailer requires UPC-A or another specified symbol, use the appropriate assigned identifier and a generator that supports that symbol; confirm the final label with the receiving partner.

Prepare your Excel data

Start with a source column that contains exactly what you intend the barcode to encode. Format that column as Text before entering the data. Excel can remove leading zeros and stores only 15 significant digits for numbers; changing the format afterward does not restore data already lost. Recover damaged values from the original trusted source. [1]

For a small practice sheet, type these invented internal codes as text:

Cell Source value Expected value after scanning
A2 00123 00123
A3 AB-12 AB-12

Keep a separate description or row ID if you need to match each barcode to a product. Check for blank cells, unintended spaces, duplicates, and values that the chosen barcode type cannot encode. For imported CSV data, use Excel’s text/CSV import workflow and set the identifier column to Text before a conversion removes leading zeros; inspect the imported values against the original file. Microsoft documents a Power Query route under Data > From Text/CSV; labels and availability may vary by Excel version. [1]

Method 1: Use a Code 39 barcode font in Excel

Use this method when a plain Code 39 symbol is accepted by your scanner and workflow. The example uses Libre Barcode 39, a separately installed font. Its plain variant supports uppercase A–Z, digits 0–9, spaces, and - . $ / + %; its documentation specifies an asterisk at each end as a start and stop marker. The markers are not part of the intended source value. [2]

  1. Obtain Libre Barcode 39 from Google Fonts or its project and install it using your operating system’s font installation process. Reopen desktop Excel if the font is not shown. Use the plain variant for the example below. [2] [3]

  2. In a worksheet, put Source in A1 and Barcode in B1. Format column A as Text, then enter 00123 in A2 and AB-12 in A3.

  3. In B2 enter the formula below and fill it down to B3. If your Excel uses a different formula argument separator, replace the comma with the separator used by your installation.

    =IF(A2="","","*"&A2&"*")

    For A2 the underlying result should be *00123*; for A3 it should be *AB-12*. The IF leaves an empty source row empty instead of creating a marker-only string. Check the formula bar before applying the font.

  4. Select B2:B3, not the source column, and choose Libre Barcode 39 from Excel’s font menu. The cells should now display bars. Adjust the column width and row height so the complete symbol and clear space at its ends are visible; don’t stretch or crop the bars to fit a small label.

  5. Print a sample at the intended size and scan it with the scanner and application that will be used. Compare each decoded value with column A, including the leading zeros. A scan of the first row should return 00123, not 123 or the literal markers. Check the scanner’s Code 39 settings if its output differs.

The formula adds markers; it does not validate every character. Correct unsupported or unintended characters in the source and repeat the test. Don’t silently change the value to make it fit. If the value needs lowercase or other extended characters, confirm that both the font’s extended mode and the scanner’s interpretation match before using it; otherwise the scanner may return character pairs instead of the intended text. [2]

Can the same formula create Code 128 or UPC?

No. Selecting a different font does not automatically supply the encoding each format needs. For example, Libre Barcode 128 requires an encoder that selects code sets and calculates a check character. Use an encoder or generator designed for the required format and test its output; don’t apply the Code 39 asterisk formula to it. [4]

Method 2: Export Excel data as CSV for a barcode generator

This route starts in Excel but creates the barcode in another tool. Choose a generator that accepts your data and the required barcode type. Review its file handling and privacy terms before submitting sensitive values.

  1. Keep the original workbook as .xlsx. Put the values to encode in one clearly named column, such as code, with one record per row. Include an identifier or description column only if the receiving tool accepts it.
  2. Check the source values as text, especially leading zeros and long numbers. Remove unintended blanks and check duplicates according to your use case.
  3. Select the intended worksheet and choose File > Save As or Save a Copy. Select a CSV format accepted by the generator and save a separate file. CSV saves the active worksheet as text data; it does not retain worksheet formatting or barcode-font artwork. [5]
  4. Inspect the saved CSV in a plain-text editor, or import it back as text through Excel’s import workflow. Compare 00123 and the other values to the original workbook. Opening a CSV directly in a spreadsheet can trigger type conversion, so a changed display is not by itself proof that the file bytes changed. [1] [5]
  5. In the chosen generator, follow its documented CSV import process. Select the correct column and barcode type, then inspect the preview, row count, and any rejected rows. If the tool does not offer a clear row-to-output mapping, resolve that before printing.
  6. Download the generated output in a format your label workflow accepts. Match each file or label back to its source row; don’t assume file order is sufficient if the tool doesn’t document it. Scan each distinct output and compare the complete result to its source value. Correct rejected or mismatched rows, regenerate them, and test again.

CSV is a handoff format, not a barcode. A successful import or download also does not prove that every label contains the right value.

Troubleshoot the result

What happened? Next action
You see ordinary text instead of bars Confirm that the barcode font is installed and selected for the output cells, then reopen Excel if needed. Check that you did not apply it to the source column alone.
Bars appear but the scanner cannot read them Check that the scanner supports the chosen symbology and that the start/stop markers, complete symbol, clear margins, size, contrast, and print quality are suitable. Reprint and retest.
The scan drops zeros or returns the wrong characters Compare the actual source value, formula result or imported CSV value, and decoded value in order. Restore corrupted data from the trusted source; check font and scanner settings, then regenerate.
A row is missing or assigned to the wrong item Check rejected rows, selected data column, row mapping, output names, and label placement. Correct the mapping and rescan the affected output.
A retail partner rejects an otherwise readable code Confirm its identifier, symbology, label, and print-quality requirements. A successful scan on one device does not establish partner acceptance or a formal print-quality grade.

Final check

Keep the original workbook, the data handed to the generator, and a record of which output belongs to each row. Before a full print run, verify that every distinct barcode decodes to its exact source value and that the receiving system associates it with the intended record. Test representative printed labels under the intended conditions and follow any additional verification process required by the recipient.

References

[1] Microsoft Support. Keeping leading zeros and large numbers. https://support.microsoft.com/en-us/excel/keeping-leading-zeros-and-large-numbers

[2] Libre Barcode Project. Code 39. https://graphicore.github.io/librebarcode/documentation/code39.html

[3] Google Fonts. Libre Barcode 39. https://fonts.google.com/specimen/Libre+Barcode+39/about

[4] Libre Barcode Project. Code 128. https://graphicore.github.io/librebarcode/documentation/code128.html

[5] Microsoft Support. Import or export text (.txt or .csv) files. https://support.microsoft.com/en-us/excel/get-started/import-or-export-text-txt-or-csv-files