Delete or catch html style in POI

1

I have the following:

String cadena="<ul><li>test &nbsp;</li><li>test 2</li></ul>"

HSSFCell cell = row.createCell((short)0);
cell.setCellValue(cadena)

I would like the cell to take the html format or in the worst case to eliminate the html

    
asked by sirdaiz 03.05.2017 в 10:19
source

2 answers

1
  • To format the excel:

    • This is a question similar to yours, whose answer is to go interpreting the labels to put the format in excel adequate.

      I made a very alpha demo of processing the string with regex so that it takes the labels and then depending on the ones that you read, apply the necessary style so that excel recognizes it:

  • To remove the HTML

  • Use Jsoup

    public static String quitarHTML(String html) {
        return Jsoup.parse(html).text();
    }
    
  • If you do not want to use external libraries, you can use

  • answered by 03.05.2017 / 10:27
    source
    1

    To remove the tags HTML of String you can use the library Jsoup :

    public static String htmlATexto(String html) {
        return Jsoup.parse(html).text();
    }
    

    If you are programming in Android simply use this:

    android.text.Html.fromHtml(instruction).toString()
    
        
    answered by 03.05.2017 в 10:26