How to display the Excel Cell content along with its styling in XHTML page?

后端 未结 2 757
时光说笑
时光说笑 2020-12-18 13:58

I am developing a Java Web Application using JSF, Primefaces and XHTML.

In which, I am trying to read the Cell con

2条回答
  •  执笔经年
    2020-12-18 14:53

    Thanks to @Axel, as his answer didn't include color so I decided to add it. But unfortunately in my case, font.getColor() always returned '0'. I went through another way as this:

    static StringBuffer getHTMLFormatted(String textpart, Font font) {
    
        StringBuffer htmlstring = new StringBuffer();
        ...
        boolean hasColor = false;
        ...
        if(font.toString().contains("") ;
                  hasColor = true ;
            }
    
       }
    
        htmlstring.append(textpart);
        ...
        if (hasColor) {
            htmlstring.append("");
        }
        return htmlstring;
    }
    
    public static String getColor(Font font){
            String colorStr ;
            Pattern pattern = Pattern.compile("");
            Matcher matcher = pattern.matcher(font.toString());
            if (matcher.find())
            {
                Log.i(TAG , "font color = : " + matcher.group(1));
                colorStr = matcher.group(1);
                colorStr = colorStr.substring(2);
            }else {
                colorStr = "616A6B" ; // my defualt color
            }
    
            return colorStr;
    }
    

提交回复
热议问题