Introduction

https://freenetexcel.codeplex.com/), we can fulfill the job easily. Please check the code in the next part.
Sample Code
In this part, I will introduce you to the sample code in the attachment.
Step 1: Load the Excel file.
- Workbook workbook = new Workbook();
- workbook.LoadFromFile("SourceFile.xlsx");
- Worksheet sheet = workbook.Worksheets[0];
Step 2: Get the data from the Excel file using a for loop.
- int i;
- string barcodeType,barcodeData;
- for (i = 2; i<=sheet.AllocatedRange.Rows.Count(); i++)
- {
- barcodeType = sheet.Range[i, 1].Text;
- barcodeData = sheet.Range[i, 2].Text;
- }
Step 3: Generate barcode images.
- BarcodeSettings barsetting = new BarcodeSettings();
- barsetting.HasBorder = true;
- barsetting.BorderWidth = 0.5F;
- barsetting.ShowTextOnBottom = true;
- barsetting.Data = barcodeData;
- barsetting.Data2D = barcodeData;
- barsetting.Type = (BarCodeType)Enum.Parse(typeof(BarCodeType), barcodeType);
- BarCodeGenerator bargenerator = new BarCodeGenerator(barsetting);
- Image barcodeimage = bargenerator.GenerateImage();
- String fileName = String.Format("Image-{0}.png", i);
- barcodeimage.Save(fileName);
Step 4: Add the barcode images to the Excel file.
- sheet.Pictures.Add(i, 3, fileName);
This is the screenshot of the final Excel file.

Join the conversation! Your thoughts help the community grow.