- Nuget添加引用:ZXing.Net生成条形码,ZXing.Net.Bindings.ImageSharp生成图片
- 将图片流插入单元格
举个栗子:
BarcodeWriter writer = new BarcodeWriter();
writer.Format = BarcodeFormat.CODE_128;
writer.Options = new ZXing.Common.EncodingOptions
{
Height = 40,
Width = 200,
PureBarcode = true
};
MemoryStream stream = new MemoryStream();
using (var image = writer.Write("条码字符"))
{
image.Save(stream, System.Drawing.Imaging.ImageFormat.Bmp);
}
Aspose.Cells.Drawing.PictureCollection pictures = sheet.Pictures;
pictures.Add(0, 12, stream);