水晶报告图像连续

时间:2017-09-18 12:35:47

标签: vb.net pdf crystal-reports

寻找一种方法,在我选择打印QR码以便像这样订购并保存到.pdf文件

这是我做Crystal报告的唯一选择吗?我正在找人告诉我走哪条路然后得到类似的东西。

enter image description here

而不喜欢这个

enter image description here

1 个答案:

答案 0 :(得分:1)

使用以下SQL查询:

WITH CTE
AS
(
    SELECT CodeQ, ROW_NUMBER() OVER(ORDER BY NEWID()) AS RN
    FROM QRCodes
), Parsed
AS
(
    SELECT 
      RN5,
      MAX(Image1) AS Image1, MAX(Image2) AS Image2, MAX(Image3) AS Image3, 
      MAX(Image4) AS Image4, MAX(Image5) AS Image5
    FROM
    (
        SELECT
          ceiling(RN/5.0) AS RN5,
          CASE WHEN RN%5 = 1 THEN CodeQ END AS Image1, 
          CASE WHEN RN%5 = 2 THEN CodeQ END AS Image2, 
          CASE WHEN RN%5 = 3 THEN CodeQ END AS Image3, 
          CASE WHEN RN%5 = 4 THEN CodeQ END AS Image4, 
          CASE WHEN RN%5 = 0 THEN CodeQ END AS Image5 
        FROM CTE
    ) AS t
    GROUP BY RN5
)
SELECT Image1, Image2, Image3, Image4, Image5
FROM Parsed;

这将为您提供5列图像。然后构建报告以显示这5列。

<强>更新

要将其设为4列而不是5列,请尝试以下操作:

WITH CTE
AS
(
    SELECT CodeQ, ROW_NUMBER() OVER(ORDER BY NEWID()) AS RN
    FROM QRCodes
), Parsed
AS
(
    SELECT 
      RN4,
      MAX(Image1) AS Image1, MAX(Image2) AS Image2, MAX(Image3) AS Image3, 
      MAX(Image4) AS Image4
    FROM
    (
        SELECT
          ceiling(RN/4.0) AS RN4,
          CASE WHEN RN%4 = 1 THEN CodeQ END AS Image1, 
          CASE WHEN RN%4 = 2 THEN CodeQ END AS Image2, 
          CASE WHEN RN%4 = 3 THEN CodeQ END AS Image3, 
          CASE WHEN RN%4 = 0 THEN CodeQ END AS Image4
        FROM CTE
    ) AS t
    GROUP BY RN4
)
SELECT Image1, Image2, Image3, Image4
FROM Parsed;