0
我想在rdlc報告上顯示條形碼圖像。如何在RDLC報告c#上顯示圖像(存儲流格式)?
我使用以下代碼獲取該條形碼圖像的內存流。
安裝的NuGet從https://www.nuget.org/packages/Aspose.BarCode/
/// This function generates the QR code image using given string and returns the ImageByteArray
/// </summary>
/// <param name="QRCodeString">string from which the QR code Image will generate</param>
/// <param name="ImageWidth">Image Height</param>
/// <param name="ImageHeight">Image Width</param>
/// <param name="GetImageOnly">Set to true if you need only QR code image. Set to false if you need QR code image with code text below the image</param>
/// <returns></returns>
private MemoryStream GetQRCodeImage(string QRCodeString, int ImageWidth, int ImageHeight, bool GetImageOnly)
{
//Creating memory stream
System.IO.MemoryStream ms = new System.IO.MemoryStream();
try
{
Aspose.BarCode.BarCodeBuilder builder = new BarCodeBuilder();
//Set the Code text for the barcode
builder.CodeText = QRCodeString;
if (GetImageOnly)
{
// Set the code text location
builder.CodeLocation = CodeLocation.None;
//Get Only Imge
builder.GetOnlyBarCodeImage();
}
//Set the symbology type to
builder.SymbologyType = Symbology.QR;
builder.ImageHeight = ImageHeight;
builder.ImageWidth = ImageWidth;
//Saving barcode image to memory stream
builder.BarCodeImage.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
return ms;
}
catch (Exception ex)
{
throw;
}
finally
{
//Dont dispose here
// ms.Dispose();
}
}
,稍後我用這個存儲器流併發送至數據集,其我用越位RDLC文件。
在我的.cs文件代碼
DatasetName = "DemoDataset";
DataTable table1 = new DataTable("Details");
table1.Columns.Add("Number");
table1.Columns.Add("BarcodeImage");
MemoryStream barcode = new MemoryStream();
barcode = GetQRCodeImage("34526172", 600, 300, false);
table1.Rows.Add(12222, barcode.ToArray());
在我RDLC代碼
在表中使用簡單表達式來訪問這些值
=Fields!Number.Value
=Fields!BarcodeImage.Value
我能得到正確的號碼
But for BarcodeImage i'm getting value as
System.ToArray()
w帽子出問題了?
我安裝無法評估代碼' https://開頭www.nuget.org /包/ Aspose.BarCode /' – Neo