Results 1 to 7 of 7
Like Tree1Likes
  • 1 Post By Tolls

Thread: How to Highlight color of text in word document through java

  1. #1
    Sarah61 is offline Member
    Join Date
    Oct 2013
    Posts
    4
    Rep Power
    0

    Lightbulb How to Highlight color of text in word document through java

    Hi,

    I want to highlight color of substring in word document through java. I amusing Apache poi 3.9. Can anyone tell me how to highlight a portion of text in word document using apache poi?

    Regards
    Sarah

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,014
    Rep Power
    20

    Default Re: How to Highlight color of text in word document through java

    The Word part of POI has never left the scratchpad stage of development, and hasn't had a lead dev for quite some time.
    It is quite possible that there is nothing that will let you do what you need.
    gimbal2 likes this.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    Sarah61 is offline Member
    Join Date
    Oct 2013
    Posts
    4
    Rep Power
    0

    Question Re: How to Highlight color of text in word document through java

    Then what do you suggest I shall do? I want to highlight a certain portion of string in the text.]

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,014
    Rep Power
    20

    Default Re: How to Highlight color of text in word document through java

    There are possibly other docx frameworks.
    You might need to do some Googling.

    Note, I'm not saying it's not possible with POI, but you need to be aware that the word part is nowhere near as solid as the excel part.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  5. #5
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,030
    Rep Power
    6

    Default Re: How to Highlight color of text in word document through java

    Perhaps OpenOffice is a solution here. I have no idea how it works because I don't see Java as the tool for the job to do operations on Office documents, but apparently you can run the software as a server and you can interface with it to do operations on documents; and since OpenOffice has full Word support, it should be able to do anything you might desire.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  6. #6
    Sarah61 is offline Member
    Join Date
    Oct 2013
    Posts
    4
    Rep Power
    0

    Default Re: How to Highlight color of text in word document through java

    I am working with strings. My program is matching a pattern in the string and then it gives the results in the form of highlighted text in the string to let the user know this pattern is found on this location in the string. The result file will be word document containing the string along with the highlighted portion. I have matched the patterns in the string and stored them in the array. But I am still at lost as to how shall I highlight the text. And there is problem also that matched patterns are in the array and each still be highlighted with different color which I do not know how to do.
    Java Code:
    for(int j=0;j<numRows;j++)
            {
    
       Pattern p = Pattern.compile( strArray[j] );
       m=p.matcher(str);
       while(m.find())//finding pattern in the sequence
    
       {
        patArray[inpat]=m.group();// stored match pattern in another array
        inpat++;
        System.out.println(m.group());
    
    }
       }
    This is my code for identifying pattern in the string.

  7. #7
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,030
    Rep Power
    6

    Default Re: How to Highlight color of text in word document through java

    You're not going to get any less lost if you don't read the responses and do further personal research.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. How to Convert Excel document to word document?
    By sudheer.v47 in forum Advanced Java
    Replies: 3
    Last Post: 05-09-2014, 09:26 AM
  2. Replace Text Word Document
    By mapleleafs89 in forum Apache POI
    Replies: 0
    Last Post: 06-15-2013, 11:01 PM
  3. Replies: 0
    Last Post: 07-24-2012, 08:07 AM
  4. Convert Word document(.doc) to XML through JAVA
    By priya2184 in forum Advanced Java
    Replies: 6
    Last Post: 05-10-2011, 03:33 PM
  5. Importing text into a word document
    By Frys82 in forum AWT / Swing
    Replies: 5
    Last Post: 08-24-2009, 08:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •