Quantcast
Channel: NPOI
Viewing all articles
Browse latest Browse all 1621

New Post: Setting the font color for XSSFWorkbook?

$
0
0
I've been trying to get npoi to set the color on rich text using the xssf library and haven't been having any luck. What am I doing wrong? Thanks.
static void Main(string[] args)
{
    XSSFWorkbook wb = new XSSFWorkbook();

    ISheet sheet = wb.CreateSheet();

    IRow row = sheet.CreateRow(0);

    XSSFFont font = wb.CreateFont() as XSSFFont;
    font.SetColor(new XSSFColor(System.Drawing.Color.Aquamarine));

    XSSFRichTextString text = new XSSFRichTextString("some text");
    text.ApplyFont(0, 3, font);

    XSSFCell cell = row.CreateCell(0) as XSSFCell;
    cell.SetCellValue(text);

    using (FileStream fs = new FileStream("test.xlsx", FileMode.Create, FileAccess.Write))
        wb.Write(fs);

    Process.Start("test.xlsx");            
}

Viewing all articles
Browse latest Browse all 1621

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>