2017-04-14 179 views

回答

1

我无法找到在水晶报表或VB中生成QR码的原生方式,但我确实找到了将图像链接到生成QR码的Google API的方法。

要使用:

  1. 插入图形报告。
  2. 右键点击图片并点击“格式化图片”。
  3. 点击“图片标签”。
  4. 单击图形位置旁边的公式编辑按钮。
  5. 添加此代码或使用此代码引用一个公式。
  6. 根据需要编辑变量。

    //-------------------------- 
    // QR Code Gererator 
    // 
    // Uses Google's Chart API. 
    // 
    // To Use: 
    // Insert a graphic to the 
    // report. Right click 
    // on it and click "Format 
    // graphic". Click on the 
    // "Picture Tab". Click 
    // on the formula edit 
    // button next to graphic 
    // location. Add this code 
    // or reference a formula 
    // with this code in it. 
    // 
    // You can update the width 
    // height and encoding below. 
    // 
    // For more info see 
    // https://developers.google.com/chart/infographics/docs/qr_codes?csw=1 
    // 
    // Feel free to redistribute. 
    // 
    // @Author Daniel Havens 
    // @Created 2018-02-01 
    stringVar QRFormat; 
    stringVar QRwidth; 
    stringVar QRheight; 
    stringVar QRText; 
    stringVar QRURI; 
    
    // Encoding format see google's api 
    QRFormat := 'UTF-8'; 
    
    // Width in Pixels 
    QRwidth := '325'; 
    
    // Height in Pixels 
    QRheight := '325'; 
    
    // Text for the QR Code. 
    // 
    // 
    QRText := 'http://stackoverflow.com/'; 
    
    // To Do: 
    // StringReplace for URI 
    
    // Combine the result 
    // 
    // Base URI must be http:// 
    // or Crystal cannot fetch 
    // the image 
    QRURI := 'http://chart.googleapis.com/chart?cht=qr&choe='+QRFormat+'&chs='+QRWidth+'x'+QRHeight+'&chl='+QRText; 
    
    QRURI;