dhatim / fastexcel

Generate and read big Excel files quickly
Other
669 stars 121 forks source link

Default a portion of cell #222

Closed longngo11 closed 1 year ago

longngo11 commented 1 year ago

Hello @ochedru i am working with fastExcel fews day ago, i wonder is there any way i can color a portion of cell. For example: i have a cell data: Customer Now i want to change the color of this cell but only for character . But as i know i just can color whole the cell not only a portion of cell can you give me some solution for that, i also use the way modify character * and then concat with customer but unfortunately i will make my cell font color with default color

ochedru commented 1 year ago

Hi! This is not supported. As far as I could see, this requires <rPr> tags inside strings. To achieve this, we would have to introduce styling inside cell text (something similar to Apache POI's XSSFRichTextString) and an evolution of StringCache to transform styling info into XML elements.

In your specific case, the xl/sharedStrings.xml file looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<sst xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" count="1" uniqueCount="1">
   <si>
      <r>
         <t>Customer</t>
      </r>
      <r>
         <rPr>
            <sz val="12" />
            <color rgb="FFFF0000" />
            <rFont val="Calibri (Body)" />
         </rPr>
         <t>*</t>
      </r>
   </si>
</sst>

If this applies only to a small subset of the cells generated by fastexcel, your best option at this stage is to use Apache POI to add styling effects to the fastexcel-generated workbook.