c#生成word文档表格

IaoapBicfisH 2006-04-26 08:31:00
各位有没有什么能使用c#生成word文档表格的技术阿~~
或者在什么地方有帮助查询???
...全文
207 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
ylj718 2006-08-02
  • 打赏
  • 举报
回复
这位朋友说的是不是在printdocument中创建表格啊,这个问题是挺麻烦的。
20011521 2006-04-26
  • 打赏
  • 举报
回复
public void CreateTable(int Row ,int Col)
{
// Move to start of document.
Object start = 0;
Object end = 0;
Word.Range rng = oDoc.Range(ref start, ref end);

// Insert some text and paragraph marks.
rng.InsertBefore("Document Statistics");
rng.Font.Name = "Verdana";
rng.Font.Size = 16;
rng.InsertParagraphAfter();
rng.InsertParagraphAfter();
rng.SetRange(rng.End, rng.End);

// Add the table.
Object defaultTableBehavior = Type.Missing;
Object autoFitBehavior = Type.Missing;
Word.Table tbl = rng.Tables.Add(
rng, Row, Col,
ref defaultTableBehavior, ref autoFitBehavior);

// Format the table and apply a style.
tbl.Range.Font.Size = 12;
tbl.Columns.DistributeWidth();
// Object style = "Table Colorful 2";
// tbl.set_Style(ref style);

// Insert text in cells.
tbl.Cell(1,1).Range.Text = "Document Property";
tbl.Cell(1, 2).Range.Text = "value";
tbl.Cell(2, 1).Range.Text = "Number of Words";
tbl.Cell(2, 2).Range.Text =
oDoc.Words.Count.ToString();
tbl.Cell(3, 1).Range.Text = "Number of Characters";
//tbl.Cell(1,1).Range .Paragraphs[1].Range .Text
tbl.Cell(3, 2).Range.Text =
oDoc.Characters.Count.ToString();
tbl.Select();
object oMissing = System.Reflection.Missing.Value;
object a=true;
object b=true;
//定义位置

}

111,117

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧