There are two common methods to process bar codes in excle:
1. Use the barcode font
2. Use the Excel control "Microsoft barcode control"
For the use of bar code fonts, many people on the Internet say that the size of the problem, after the experiment, 20 ~ 36.
Common codes include 39 codes and code128. Therefore, the two fonts are installed first, and the formats are adjusted and then displayed. However, scanning devices cannot be identified.
Later, I searched for the reason. The explanation on the Internet was that "*" was added before and after the raw data to be recognized as the start and end character. Later, it was verified that this was the case. However, the problem is that the data scanned by a common device will not be automatically cleared "*", which is unfriendly to the customer. If it is a professional scanner, you can try to set the start and end characters with 39 yards omitted.
Therefore, code128 is used instead. If the original data is directly placed in excle and the bar code font cannot be set, the original data must be processed. Someone on csdn used macro commands for an example. The experiment is indeed feasible. However, we encountered a problem: how to process the original data in a suitable way (macros are not familiar with it ). Originally, the program written in C # was used to export the excle. Therefore, the function in the macro was transferred to the VB project to encapsulate a DLL, which was directly called using C, put the processed data into excle.
Attach the elder brother's VB source code:
1 public class barcodehelper 2 Public Function getcode128b (byval STR as string) as string 3 dim result as string 4 dim checksum as integer, I _tmp as integer 5 Dim checkcode as string 'generate Verification Code 6 checksum = 104 7 for I = 1 to Len (STR) Step 1 8 I _tmp = ASCW (mid (STR, I, 1) 9 If I _tmp> = 32 then10 checksum = checksum + (I _tmp-32) * i11 else12 checksum = checksum + (I _tmp + 64) * I13 end if14 next15 checksum = checksum mod 10316 if checksum <95 then17 checksum = checksum + 3218 else19 checksum = checksum + 10020 end if21 checkcode = chrw (checksum) 22 result = chrw (204) + STR + checkcode + chrw (206) 23 getcode128b = result24 end function25 26 end class
(In fact there are code128c and ean128 conversion, specific resources: http://download.csdn.net/download/liqingle/6880253)
Solve the problem -- the code128 code printed in the bar code font in Excel cannot be identified