Bug 60163 - Text coloring in Excel cell is not working
Summary: Text coloring in Excel cell is not working
Status: RESOLVED INVALID
Alias: None
Product: POI
Classification: Unclassified
Component: SXSSF (show other bugs)
Version: 3.13-FINAL
Hardware: PC All
: P2 enhancement (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-09-22 06:02 UTC by Ratna
Modified: 2016-09-27 12:32 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ratna 2016-09-22 06:02:56 UTC
Hi Team,

We are using Apache Poi 3.13 final jars.

We used SXSSF workbook for an export of records using MS Xcel.

Records are exporting but,Workbook's apply font method is not working and beacuse of this coloring of text in the excel columns is not at all working.

Being low memory adaption technique in SXSSF work book,apply font wont work,i know this.
But can u please suggest a working solution,without changing the SXSSF workbook?
If any jar change may work,please suggest.

Thanks a lot
Ratna
Comment 1 Javen O'Neal 2016-09-22 06:43:54 UTC
This works for me. Adapted from https://poi.apache.org/spreadsheet/quick-guide.html#Hyperlinks

CellStyle style = wb.createCellStyle();
Font font = wb.createFont();
font.setUnderline(Font.U_SINGLE);
font.setColor(IndexedColors.BLUE.getIndex());
style.setFont(font);

Sheet sheet = wb.createSheet();
Cell cell = sheet.createRow(0).createCell(0);
cell.setCellValue("Underlined Blue Text");
cell.setCellStyle(style);

In the future, please ask usage questions on the user or dev mailing lists rather than opening a bug. https://poi.apache.org/mailinglists.html
Comment 2 Ratna 2016-09-23 04:41:52 UTC
for the particular TEXT in Cell,i want coloring.
Not the entire cell,if you have example provide me please.
Comment 3 Ratna 2016-09-23 04:43:54 UTC
Also U r saying example for XSSF workbook,i want to work it for SXSSF workbook,not XSSF work book
Comment 4 Nick Burch 2016-09-23 04:49:20 UTC
(In reply to Ratna from comment #2)
> for the particular TEXT in Cell,i want coloring.
> Not the entire cell,if you have example provide me please.

Bugzilla is only for bug reports and patches. Please ask usage questions on the mailing list
Comment 5 Javen O'Neal 2016-09-23 05:32:14 UTC
The code from comment 1 was tested on a SXSSFWorkbook and colors the text (not background fill). Coloring part of the text in a cell requires RichTextStrings, which SXSSF does not currently support. Supporting this would require maintaining a shared strings table, negating some of the memory benefits of SXSSF.

We will happily review submitted patches and unit tests for optionally allowing a shared strings table and rich text strings in SXSSF if they meet the needs of the community.
Comment 6 Ratna 2016-09-27 11:30:52 UTC
how Coloring of specific text in a particular cell is achieved in SXSSF work book?
For example "I love you" in this string i want "you" to color with blue,how it is possible?
is there any alternative for applyfont method?
Please explain me if partial text coloring is possible with shared strings table,how it is achieved in the above example with a sample code bit.

Thanks in advance
Comment 7 Javen O'Neal 2016-09-27 12:32:13 UTC
As Nick said in comment 4, bugzilla is not the place for usage questions. SXSSF does not currently support RichTextStrings, so it is not possible tohave multiple font colors in one cell in SXSSF.

If you need RichTextStrings, you must use XSSF.
Please read https://poi.apache.org/spreadsheet/quick-guide.html#RichText
If you have further questions, please ask the user list https://poi.apache.org/mailinglists.html