Word里的表格是这样的
xxx 为需要修改的内容
[C#] 纯文本查看 复制代码 public NPOI.XWPF.UserModel.XWPFParagraph SetCellText(NPOI.XWPF.UserModel.Document docx, NPOI.XWPF.UserModel.XWPFTable table, dynamic str)
{
NPOI.OpenXmlFormats.Wordprocessing.CT_P para = new NPOI.OpenXmlFormats.Wordprocessing.CT_P();
NPOI.XWPF.UserModel.XWPFParagraph pCell = new NPOI.XWPF.UserModel.XWPFParagraph(para,table.Body);
pCell.Alignment = NPOI.XWPF.UserModel.ParagraphAlignment.CENTER;
pCell.VerticalAlignment = NPOI.XWPF.UserModel.TextAlignment.CENTER;
NPOI.XWPF.UserModel.XWPFRun ric1 = pCell.CreateRun();
if (str is string)
{
ric1.SetText(str);
}
else
{
ric1.SetText(Convert.ToString(str));
}
return pCell;
}
这是网上修改单元格内容的,不知道为什么我这边无效
大佬们帮帮我吧 |