https://issues.apache.org/bugzilla/show_bug.cgi?id=50665

           Summary: [Need info]  formattingruns in HSSFRichTextString
           Product: POI
           Version: unspecified
          Platform: Macintosh
            Status: NEW
          Severity: minor
          Priority: P2
         Component: HSSF
        AssignedTo: [email protected]
        ReportedBy: [email protected]


Created an attachment (id=26558)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=26558)
POI test

I wanted to extract cell's text value and its format (bold, italic, etc) by
using org.apache.poi.hssf.usermodel.HSSFRichTextString

The function numFormattingRuns() and getIndexOfFormattingRun() can help me to
identify different style available in the text. 

However, it seems that numFormattingRuns() will always return 0 unless 2
different formats are used.

For example:
Example 1: (Text with no format)
Apache POI is rock

Result: 
HSSFRichTextString.numFormattingRuns() = 0

=================================

Example 2: (Whole text is bold)
Apache POI is rock

Result: 
HSSFRichTextString.numFormattingRuns() = 0

================================= 

Example 3: (word "POI" is bold)
Apache POI is rock
HSSFRichTextString.numFormattingRuns() = 2
HSSFRichTextString.getIndexOfFormattingRun(0) = 7
HSSFRichTextString.getIndexOfFormattingRun(1) = 10

=================================

Example 4: (word "Apache" is bold)
Apache POI is rock
HSSFRichTextString.numFormattingRuns() = 1
HSSFRichTextString.getIndexOfFormattingRun(0) = 6


=====================================================

It appears that getIndexOfFormattingRun() will first only returns the character
index if it encounters a different format from the initial format. Is this a
correct behavior? It seems very different from the way getCharacterRuns works
in HWPF model.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to