Skip to content
This repository has been archived by the owner on Nov 24, 2020. It is now read-only.

[Word/*.docx] Can't set the correct font size #168

Open
CodingOctocat opened this issue Mar 18, 2020 · 0 comments
Open

[Word/*.docx] Can't set the correct font size #168

CodingOctocat opened this issue Mar 18, 2020 · 0 comments

Comments

@CodingOctocat
Copy link

CodingOctocat commented Mar 18, 2020

I want to modify a docx file.
I try code:

public static XWPFParagraph AppendCellParagraph(XWPFTableCell cell, string text, Color fg = default, Color bg = default)
{
    var p = cell.AddParagraph();
    XWPFRun run = p.CreateRun();
    run.SetText(text);
    run.FontFamily = "宋体";
    run.FontSize = 9; 👀
    run.SetColor(ColorTranslator.ToHtml(fg));
    p.AddRun(run);
    p.FillBackgroundColor = ColorTranslator.ToHtml(bg == default ? Color.Transparent : bg);
    p.Alignment = ParagraphAlignment.CENTER;
    p.VerticalAlignment = TextAlignment.CENTER;

    return p;
}

Test found that the actual font size is 10.5.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant