翻譯|使用教程|編輯:胡濤|2022-07-04 09:41:33.743|閱讀 181 次
概述:本文將向您展示如何在word文檔的一側(cè)創(chuàng)建一個(gè)垂直表格,歡迎查閱!
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
Spire.Doc 可以幫助開發(fā)人員輕松創(chuàng)建包含數(shù)據(jù)和格式單元格的單詞表,它還支持在 Word 文檔中添加文本水印。本文將向您展示如何在word文檔的一側(cè)創(chuàng)建一個(gè)垂直表格,該表格看起來像word文檔中的垂直水印。
首先,請查看Spire.Doc添加的word文檔右側(cè)垂直表格的有效截圖:
下面介紹如何在C#中創(chuàng)建垂直表格的步驟。
第 1 步:創(chuàng)建一個(gè)新文檔并在文檔中添加一個(gè)部分。
Document document = new Document(); Section section=document.AddSection();
第 2 步:添加一個(gè)包含行和列的表格并設(shè)置表格的文本。
Table table = section.AddTable(); table.ResetCells(1, 1); TableCell cell = table.Rows[0].Cells[0]; table.Rows[0].Height = 150; cell.AddParagraph().AppendText("Draft copy in vertical style");
第 3 步:將表格的 TextDirection 設(shè)置為 RightToLeftRotated。
cell.CellFormat.TextDirection = TextDirection.RightToLeftRotated;
第 4 步:設(shè)置表格格式。
table.TableFormat.WrapTextAround = true; table.TableFormat.Positioning.VertRelationTo = VerticalRelation.Page; table.TableFormat.Positioning.HorizRelationTo = HorizontalRelation.Page; table.TableFormat.Positioning.HorizPosition = section.PageSetup.PageSize.Width- table.Width; table.TableFormat.Positioning.VertPosition = 200;
第 5 步:將文檔保存到文件中。
document.SaveToFile("result.docx",FileFormat.docx2013);
C# 中的完整代碼:
using Spire.Doc; using Spire.Doc.Documents; namespace CreateVerticalTable { class Program { static void Main(string[] args) { Document document = new Document(); Section section=document.AddSection(); Table table = section.AddTable(); table.ResetCells(1, 1); TableCell cell = table.Rows[0].Cells[0]; table.Rows[0].Height = 150; cell.AddParagraph().AppendText("Draft copy in vertical style"); cell.CellFormat.TextDirection = TextDirection.RightToLeftRotated; table.TableFormat.WrapTextAround = true; table.TableFormat.Positioning.VertRelationTo = VerticalRelation.Page; table.TableFormat.Positioning.HorizRelationTo = HorizontalRelation.Page; table.TableFormat.Positioning.HorizPosition = section.PageSetup.PageSize.Width- table.Width; table.TableFormat.Positioning.VertPosition = 200; document.SaveToFile("result.docx",FileFormat.docx2013); } } }
歡迎下載|體驗(yàn)更多E-iceblue產(chǎn)品
獲取更多信息請咨詢 ;技術(shù)交流Q群(767755948)
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn