Document document = new Document();
document.LoadFromFile("示例.docx");
//获取第一个section并为其设置文本方向 Section section = document.Sections[0]; section.TextDirection = TextDirection.RightToLeftRotated;
//添加一个新的section到文档
Section sec = document.AddSection();
//添加一个table到该section
Table table = sec.AddTable();
//添加一行和一列到table
table.ResetCells(1, 1);
//获取单元格
TableCell cell = table.Rows[0].Cells[0];
table.Rows[0].Height = 50;
table.Rows[0].Cells[0].Width = 5;
//设置单元格的文本方向并添加文本到该单元格
cell.CellFormat.TextDirection = TextDirection.RightToLeftRotated;
cell.AddParagraph().AppendText("你好");
sec.AddParagraph().AppendText("新段落");
using Spire.Doc;
using Spire.Doc.Documents;
namespace Set_text_direction_in_Word
{
class Program
{
static void Main(string[] args)
{
Document document = new Document();
document.LoadFromFile("示例.docx");
//设置一个section内的所有文本的文本方向
Section section = document.Sections[0];
section.TextDirection = TextDirection.RightToLeftRotated;
//设置部分文本的文本方向
Section sec = document.AddSection();
Table table = sec.AddTable();
table.ResetCells(1, 1);
TableCell cell = table.Rows[0].Cells[0];
table.Rows[0].Height = 50;
table.Rows[0].Cells[0].Width = 5;
cell.CellFormat.TextDirection = TextDirection.RightToLeftRotated;
cell.AddParagraph().AppendText("你好");
sec.AddParagraph().AppendText("新段落");
//保存文档
document.SaveToFile("文本方向.docx", FileFormat.Docx);
}
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有