RDLC how can I make text justify?

杀马特。学长 韩版系。学妹 提交于 2020-07-20 10:17:06

问题


I'm working in a windows application and I want that in my RDLC reports text to be justified.


回答1:


I made a function to convert text in a list of strings. You can use a table without header to show it like a justifyed paraghaph.

        public static List<string> GetText(string text, int width)
    {
        string[] palabras = text.Split(' ');
        StringBuilder sb1 = new StringBuilder();
        StringBuilder sb2 = new StringBuilder();
        int length = palabras.Length;
        List<string> resultado = new List<string>();
        for (int i = 0; i < length; i++)
        {
            sb1.AppendFormat("{0} ", palabras[i]);
            if (sb1.ToString().Length > width)
            {
                resultado.Add(sb2.ToString());
                sb1 = new StringBuilder();
                sb2 = new StringBuilder();
                i--;
            }
            else
            {
                sb2.AppendFormat("{0} ", palabras[i]);
            }
        }
        resultado.Add(sb2.ToString());

        List<string> resultado2 = new List<string>();
        string temp;

        int index1, index2, salto;
        string target;
        int limite = resultado.Count;
        foreach (var item in resultado)
        {
            target = " ";
            temp = item.ToString().Trim();
            index1 = 0; index2 = 0; salto = 2;

            if (limite <= 1)
            {
                resultado2.Add(temp);
                break;
            }
            while (temp.Length <= width)
            {
                if (temp.IndexOf(target, index2) < 0)
                {
                    index1 = 0; index2 = 0;
                    target = target + " ";
                    salto++;
                }
                index1 = temp.IndexOf(target, index2);
                temp = temp.Insert(temp.IndexOf(target, index2), " ");
                index2 = index1 + salto;

            }
            limite--;
            resultado2.Add(temp);
        }
        return resultado2;
    }

Hope it helps!




回答2:


Unfortunately NO. Refer to below discussions.

http://social.msdn.microsoft.com/Forums/en-US/sqlreportingservices/thread/28edb302-da0c-4097-a100-8f74dfbd7366

http://social.msdn.microsoft.com/Forums/is/sqlreportingservices/thread/ecf375d1-7991-4e07-9180-ddbcc2bffd55



来源:https://stackoverflow.com/questions/10316713/rdlc-how-can-i-make-text-justify

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!