在 RDLC 中证明 [英] Justify in RDLC

查看:42
本文介绍了在 RDLC 中证明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 rdlc 中使用 justify 功能,但它不支持.这个问题已经有算法作者了,但是当我得到输出时,我又得到了结果(不是justify).

我希望我能得到这个问题的解决方案.非常感谢..

解决方案

试试这个:

  1. 在标签代码中添加此函数以报告属性:

    函数 GetText(text As String, width As Integer) As StringDim palabras As String() = text.Split(" "c)Dim sb1 作为新 System.Text.StringBuilder()Dim sb2 作为新 System.Text.StringBuilder()Dim length As Integer = palabras.LengthDim resultado As New System.Collections.Generic.List(Of String)()Dim i As Integer = 0当我 <长度sb1.AppendFormat({0}", palabras(i))如果 sb1.ToString().Length >宽度 然后resultado.Add(sb2.ToString())sb1 = 新 System.Text.StringBuilder()sb2 = 新 System.Text.StringBuilder()System.Math.Max(System.Threading.Interlocked.Decrement(i), i + 1)别的sb2.AppendFormat({0}", palabras(i))万一System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1)结束时间resultado.Add(sb2.ToString())Dim resultado2 As New System.Collections.Generic.List(Of String)()Dim temp As StringDim index1 As Integer, index2 As Integer, salto As Integer将目标变暗为字符串Dim limite As Integer = resultado.CountFor Each item As String In resultado目标 = ""temp = item.ToString().Trim()索引 1 = 0索引 2 = 0盐 = 2如果 limite <= 1 那么resultado2.Add(temp)退出万一而 temp.Length <= 宽度如果 temp.IndexOf(target, index2) <0 那么索引 1 = 0索引 2 = 0目标 = 目标 + ""System.Math.Max(System.Threading.Interlocked.Increment(salto),salto - 1)万一index1 = temp.IndexOf(target, index2)temp = temp.Insert(temp.IndexOf(target, index2), " ")index2 = index1 + salto结束时间System.Math.Max(System.Threading.Interlocked.Decrement(limite), limite + 1)resultado2.Add(temp)下一个Dim builder 作为新 System.Text.StringBuilder()For each item As String In resultado2builder.Append(item).Append(chr(10))下一个返回 builder.ToString()结束函数

  2. 在文本框中调用自定义代码:

<块引用>

=Code.GetText("longtext...",77)

我知道您使用的是 C#,但在 rdlc 中您只能编写 vb 代码.

在这个原始答案中从 C# 转换的 VB 代码:https://stackoverflow.com/a/38235745/2713855

您也可以使用带有 C# 代码的自定义 dll 引用,然后您只需要在文本框中调用该函数 添加自定义程序集

I want to use justify feature in rdlc but it doesn't support. There have been algorithm writers in this problem, but when I get the output, I get results again (not justify).

I hope I can get a solution to this problem. Thanks a lot ..

解决方案

try this:

  1. add this function to report propertise in tab Code:

    Function GetText(text As String, width As Integer) As String
         Dim palabras As String() = text.Split(" "c)
         Dim sb1 As New System.Text.StringBuilder()
         Dim sb2 As New System.Text.StringBuilder()
         Dim length As Integer = palabras.Length
         Dim resultado As New System.Collections.Generic.List(Of String)()
         Dim i As Integer = 0
         While i < length
             sb1.AppendFormat("{0} ", palabras(i))
             If sb1.ToString().Length > width Then
                 resultado.Add(sb2.ToString())
                 sb1 = New System.Text.StringBuilder()
                 sb2 = New System.Text.StringBuilder()
                 System.Math.Max(System.Threading.Interlocked.Decrement(i), i + 1)
             Else
                 sb2.AppendFormat("{0} ", palabras(i))
             End If
             System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1)
         End While
         resultado.Add(sb2.ToString())
    
         Dim resultado2 As New System.Collections.Generic.List(Of String)()
         Dim temp As String
    
         Dim index1 As Integer, index2 As Integer, salto As Integer
         Dim target As String
         Dim limite As Integer = resultado.Count     
         For Each item As String In resultado        
             target = " "
             temp = item.ToString().Trim()
             index1 = 0
             index2 = 0
             salto = 2
    
             If limite <= 1 Then
                 resultado2.Add(temp)
                 Exit For
             End If
             While temp.Length <= width
                 If temp.IndexOf(target, index2) < 0 Then
                     index1 = 0
                     index2 = 0
                     target = target + " "
                     System.Math.Max(System.Threading.Interlocked.Increment(salto), salto - 1)
                 End If
                 index1 = temp.IndexOf(target, index2)
                 temp = temp.Insert(temp.IndexOf(target, index2), " ")
    
                 index2 = index1 + salto
             End While
             System.Math.Max(System.Threading.Interlocked.Decrement(limite), limite + 1)
             resultado2.Add(temp)
         Next
    
         Dim builder As New System.Text.StringBuilder()
         For Each item As String In resultado2
             builder.Append(item).Append(chr(10))
        Next
         Return builder.ToString()
     End Function
    

  2. Call custom code in yout textbox:

=Code.GetText("longtext…",77)

i know you are using C# , but in rdlc you can write vb code only.

the VB code converted from C# in this original answer: https://stackoverflow.com/a/38235745/2713855

also you can use custom dll reference with C# code and then you need only to call the function in you textbox Adding Custom Assemblies

这篇关于在 RDLC 中证明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆