
Barcode GenerationBarcode Generation
Keep Leading Zeros in Excel and CSV Barcode Data
Preserve barcode identifiers as text in Excel, check what your CSV actually contains, and prevent leading zeros from disappearing on import.
Learn how barcode fonts and encoders work, compare Code 39 and Code 128 examples, and check a printed symbol against its original data.

A barcode font can turn correctly prepared text into bars, but installing a font alone does not guarantee a valid or readable barcode. You must choose a symbology your system accepts, prepare the data according to that particular font’s instructions, render it at a suitable size, and scan the result back to the original value. Some fonts need an encoder to add the information required by the symbology.
The path is source data → font-specific preparation or encoder → barcode font → printed or rendered symbol → scan and compare. A barcode-looking pattern is only an intermediate result.
A barcode font maps characters to visual patterns. An encoder prepares data for a particular font and symbology; depending on the combination, it may add start and stop information, select a code set, and calculate a check character. The receiving scanner must support the symbology and send data in a form your application expects.
A font does not issue a registered product identifier, create an inventory record, or prove a label meets a retailer’s requirements. If your task requires a UPC, an assigned GTIN and the correct UPC encoding rules matter separately from the choice of font.
| Question | Libre Barcode 39 plain variant | Libre Barcode 128 |
|---|---|---|
| Input | Supports uppercase letters, digits, certain punctuation and space. | The author’s encoder prepares the input for the font. |
| Preparation | The author instructs users to wrap the input in asterisks. | The encoder selects code sets as needed and calculates a checksum character before the stop symbol. |
| Important limitation | Extended characters require the extended variant and compatible scanner interpretation. | Typing ordinary text and merely changing the font does not perform the documented encoding step. |
These are instructions for the named Libre Barcode fonts, not a universal recipe for every font. Other implementations can use different character mappings, optional checks or encoders. Follow the documentation that accompanies the exact font and the receiving application’s requirements. [1][2]
Suppose your original internal value is AB-12. The Libre Barcode 39 plain-font input would be *AB-12*: the asterisks supply the start and stop characters for that font. Apply the specified font to the prepared text, then scan the rendered or printed result and compare the decoded data with AB-12. [1]
This is an illustrative input, not a barcode we generated or tested. Asterisks are not an instruction to alter the source record or to add them to Code 128 data. Keep the original value in a separate field so you can compare it with the scan.
The Libre Barcode project also warns that some scanners interpret extended Code 39 as ordinary Code 39 and may return the underlying character pairs rather than the intended lowercase or special character. Test the exact input and scanner configuration if you need extended characters. [1]
For Libre Barcode 128, enter the intended value into a compatible encoder first. The project describes an encoder that selects among Code Sets A, B and C and calculates the checksum; copy the encoded output and render it with the matching font. [2] The encoded text may look unlike the original value in an ordinary font. Do not edit that intermediate string by hand or use an encoder made for an unrelated font without checking compatibility.
A successful scan is evidence for that sample and setup. If a trading partner requires a formal quality grade, arrange the appropriate verification; a phone scan alone does not establish that grade. [4]
[1] Libre Barcode Project. Code 39. https://graphicore.github.io/librebarcode/documentation/code39.html
[2] Libre Barcode Project. Code 128. https://graphicore.github.io/librebarcode/documentation/code128.html
[3] Microsoft Support. Keeping leading zeros and large numbers. https://support.microsoft.com/en-us/excel/keeping-leading-zeros-and-large-numbers
[4] GS1. 1D Barcode Verification Process Implementation Guideline. https://www.gs1.org/docs/barcodes/GS1_Bar_Code_Verification.pdf