惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Spread Privacy
Spread Privacy
P
Palo Alto Networks Blog
P
Proofpoint News Feed
AI
AI
Help Net Security
Help Net Security
S
Securelist
T
Troy Hunt's Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
C
Cisco Blogs
Scott Helme
Scott Helme
Hacker News - Newest:
Hacker News - Newest: "LLM"
Vercel News
Vercel News
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
B
Blog
GbyAI
GbyAI
Recent Commits to openclaw:main
Recent Commits to openclaw:main
D
Darknet – Hacking Tools, Hacker News & Cyber Security
P
Proofpoint News Feed
S
Security Affairs
Cisco Talos Blog
Cisco Talos Blog
AWS News Blog
AWS News Blog
T
Tenable Blog
H
Help Net Security
NISL@THU
NISL@THU
F
Fortinet All Blogs
博客园_首页
G
GRAHAM CLULEY
L
LINUX DO - 最新话题
P
Privacy International News Feed
G
Google Developers Blog
博客园 - Franky
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Security Archives - TechRepublic
Security Archives - TechRepublic
The Register - Security
The Register - Security
L
LangChain Blog
aimingoo的专栏
aimingoo的专栏
T
Tor Project blog
P
Privacy & Cybersecurity Law Blog
量子位
C
Cyber Attacks, Cyber Crime and Cyber Security
Forbes - Security
Forbes - Security
S
Secure Thoughts
Simon Willison's Weblog
Simon Willison's Weblog
D
Docker
Recorded Future
Recorded Future
博客园 - 三生石上(FineUI控件)
L
Lohrmann on Cybersecurity
T
Tailwind CSS Blog

博客园 - soulsjie

一种在winfrom窗体中显示计算公式的解决方案 winform窗体DataGridView合并单元格处理 C#GDI+阴影笔刷样式HatchStyle探讨 C#代码混淆工具ConfuserEx的使用 Aspose.Words在指定位置插入图片、调整图片大小 C#获取对象实体的键值对信息 C#将Winform上的TextBox和ComBox的值导入和导出 C# Aspose.Words将word中自定义的标签进行替换 Python文件操作基础方法 C# 将项目资源文件保存到磁盘上 SqlSugar数据库辅助类 使用存储过程备份MS SQLServer数据库 案例3:JAVA GUI 随机点名程序 案例2:JAVA GUI 简易计算器 ArcGIS JS API 添加要素图层 点击时获取图层属性 ArcGIS JS API 将天地图设置为底图 HTML5PLUS实现类似右侧弹出菜单 SqlSugar各数据库连接串 案例1:JAVAGUI用户管理
C#使用Aspose.Words将Spread表格插入到Word中
soulsjie · 2023-02-23 · via 博客园 - soulsjie

注:Word中每个表格只有一行,固定第一行为表头,先复制表头N行追加到表格后,保证每行的格式与表头一致。
封装方法:

        private void SheetToTable(FarPoint.Win.Spread.SheetView sheet, Document doc, Table table, int beginRow)
        {
            //先复制出所有行,保证每行的格式都是一致的
            for (int i = beginRow; i < sheet.RowCount; i++)
            {
                Row oneRow = (Row)table.Rows[table.Rows.Count - 1].Clone(true);
                table.Rows.Insert(table.Rows.Count, oneRow);
            }
            //从第二行开始进行数据填充
            for (int i = beginRow; i < table.Rows.Count; i++)
            {
                //先统一设置一下行高,后续给单元格赋值时会自动撑开
                table.Rows[i].RowFormat.Height = 20;
                for (int j = 0; j < sheet.ColumnCount; j++)
                {
                    table.Rows[i].Cells[j].ChildNodes.Clear();
                    Paragraph p = new Paragraph(doc);
                    p.AppendChild(new Run(doc, sheet.Cells[i, j].Text));
                    table.Rows[i].Cells[j].AppendChild(p);
                }
            }
        }
        /// <summary>
        /// 设置指定单元格的文本
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="cell"></param>
        /// <param name="text"></param>
        public static void SetCellText(Document doc,Cell cell,string text) 
        {
            cell.RemoveAllChildren();
            cell.Paragraphs.Add(new Paragraph(doc));
            Run run = new Run(doc, text);
            run.Font.Name = "宋体";
            run.Font.Size = 8;
            cell.LastParagraph.Runs.Add(run);
        }