翻譯|使用教程|編輯:胡濤|2022-12-22 10:09:18.750|閱讀 352 次
概述:本文將向您展示如何設(shè)置 Word 表格列寬。歡迎查閱~
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
Spire.Doc for .NET是一款專門對 Word 文檔進行操作的 .NET 類庫。在于幫助開發(fā)人員無需安裝 Microsoft Word情況下,輕松快捷高效地創(chuàng)建、編輯、轉(zhuǎn)換和打印 Microsoft Word 文檔。擁有近10年專業(yè)開發(fā)經(jīng)驗Spire系列辦公文檔開發(fā)工具,專注于創(chuàng)建、編輯、轉(zhuǎn)換和打印Word/PDF/Excel等格式文件處理,小巧便捷。
通過使用Spire.Doc,開發(fā)人員可以創(chuàng)建帶有表格的 Word 文檔(點擊了解如何在 Word 文檔中創(chuàng)建表格)。但是當(dāng)用戶在 Word 文檔中創(chuàng)建表格時,他們不會只創(chuàng)建帶有空白單元格的表格。他們需要設(shè)置格式或有時設(shè)置表格大小,如列寬。本文將向您展示如何設(shè)置 Word 表格列寬。
確保系統(tǒng)上正確安裝了Spire.Doc和 Visual Studio。按照以下簡單步驟設(shè)置 Word 表格列寬。
添加 Spire.Doc.dll 作為參考。Spire.Doc.dll 的默認(rèn)設(shè)置位于“C:\Program Files\e-iceblue\Spire.Doc\Bin”下。選擇程序集 Spire.Doc.dll 并單擊確定將其添加到項目中。
[C#]
using System; using Spire.Doc; using Spire.Doc.Fields; using Spire.Doc.Documents; namespace TableWidth { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { } } }
[VB.NET]
Imports Spire.Doc Imports Spire.Doc.Fields Imports Spire.Doc.Documents Namespace TableWidth Public Partial Class Form1 Inherits Form Public Sub New() InitializeComponent() End Sub Private Sub button1_Click(sender As Object, e As EventArgs) End Sub End Class End Namespace
[C#]
Document doc = new Document(); doc.LoadFromFile(@"..\..\Table.docx",FileFormat.Docx);
[VB.NET]
Dim doc As New Document() doc.LoadFromFile("..\..\Table.docx", FileFormat.Docx)
[C#]
for (int i = 0; i < document.Sections[0].Tables[0].Rows.Count; i++) { document.Sections[0].Tables[0].Rows[i].Cells[0].Width = 20; }
[VB.NET]
For i As Integer = 0 To document.Sections(0).Tables(0).Rows.Count - 1 document.Sections(0).Tables(0).Rows(i).Cells(0).Width = 20 Next
[C#]
document.SaveToFile(@"..\..\Sample.docx",FileFormat.Docx);
[VB.NET]
document.SaveToFile("..\..\Sample.docx", FileFormat.Docx) System.Diagnostics.Process.Start("..\..\Test.pdf")
現(xiàn)在,整個過程結(jié)束了。按 F5 并單擊按鈕以運行項目。生成的 docx 文件可以在項目調(diào)試文件夾中找到。檢查效果。
設(shè)置寬度前:
設(shè)置寬度后:
Spire.Doc作為一個專業(yè)而強大的Word組件,不需要Microsoft Office Word Automation,還允許用戶直接操作Word文檔、格式化和樣式以及向Word文檔插入內(nèi)容。點擊了解Spire.Doc更多特色功能
以上便在C#/VB.NET:在 Word 中創(chuàng)建表格,如果您有其他問題也可以繼續(xù)瀏覽本系列文章,獲取相關(guān)教程,你還可以給我留言或者加入我們的官方技術(shù)交流群。
歡迎下載|體驗更多E-iceblue產(chǎn)品
獲取更多信息請咨詢 ;技術(shù)交流Q群(767755948)
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn