当前位置: 首页 > news >正文

.NET驾驭Word之力:玩转文本与格式

在前面的文章中,我们已经了解了Word对象模型的核心组件,包括Application、Document和Range对象。掌握了这些基础知识后,我们现在可以进一步深入到文档内容的处理,特别是文本的插入和格式化操作。

本文将详细介绍如何使用MudTools.OfficeInterop.Word库来操作Word文档中的文本内容,包括多种插入文本的方法、字体格式设置和段落格式设置。最后,我们将通过一个实战示例,创建一个格式规范的商业信函模板,来综合运用所学知识。

3.1 插入文本的多种方式

在Word文档自动化处理中,插入文本是最基本也是最重要的操作之一。MudTools.OfficeInterop.Word提供了多种方式来插入文本,每种方式都有其适用场景。

使用 Range.Text 属性

Range对象是Word对象模型中最核心的组件之一,它代表文档中的一个连续区域。通过设置Range.Text属性,我们可以轻松地在指定位置插入或替换文本。

// 获取文档的整个内容范围
var range = document.Content;// 在文档末尾插入文本
range.Collapse(WdCollapseDirection.wdCollapseEnd);
range.Text = "这是通过Range.Text属性插入的文本。\n";// 替换文档中的所有内容
range.Text = "这是替换后的全新内容。";

Range.Text属性是最直接的文本操作方式,适合于需要精确控制文本位置的场景。

应用场景:动态报告生成

在企业环境中,经常需要根据数据动态生成报告。例如,财务部门需要每月生成财务报告,其中包含关键指标数据。

using MudTools.OfficeInterop;
using MudTools.OfficeInterop.Word;
using System;
using System.Collections.Generic;// 财务数据模型
public class FinancialData
{public string Department { get; set; }public decimal Revenue { get; set; }public decimal Expenses { get; set; }public decimal Profit => Revenue - Expenses;public double GrowthRate { get; set; }
}// 财务报告生成器
public class FinancialReportGenerator
{/// <summary>/// 生成财务报告/// </summary>/// <param name="data">财务数据列表</param>/// <param name="reportMonth">报告月份</param>public void GenerateFinancialReport(List<FinancialData> data, DateTime reportMonth){try{// 使用模板创建报告文档using var wordApp = WordFactory.CreateFrom(@"C:\Templates\FinancialReportTemplate.dotx");var document = wordApp.ActiveDocument;// 隐藏Word应用程序以提高性能wordApp.Visibility = WordAppVisibility.Hidden;wordApp.DisplayAlerts = WdAlertLevel.wdAlertsNone;// 替换报告标题中的月份信息document.FindAndReplace("[MONTH]", reportMonth.ToString("yyyy年MM月"));// 定位到数据表格位置var tableBookmark = document.Bookmarks["FinancialDataTable"];if (tableBookmark != null){var tableRange = tableBookmark.Range;// 创建表格(标题行+数据行)var table = document.Tables.Add(tableRange, data.Count + 1, 5);// 设置表头table.Cell(1, 1).Range.Text = "部门";table.Cell(1, 2).Range.Text = "收入";table.Cell(1, 3).Range.Text = "支出";table.Cell(1, 4).Range.Text = "利润";table.Cell(1, 5).Range.Text = "增长率";// 填充数据for (int i = 0; i < data.Count; i++){var item = data[i];table.Cell(i + 2, 1).Range.Text = item.Department;table.Cell(i + 2, 2).Range.Text = item.Revenue.ToString("C");table.Cell(i + 2, 3).Range.Text = item.Expenses.ToString("C");table.Cell(i + 2, 4).Range.Text = item.Profit.ToString("C");table.Cell(i + 2, 5).Range.Text = $"{item.GrowthRate:P2}";}// 格式化表格table.Borders.Enable = 1;for (int i = 1; i <= table.Rows.Count; i++){for (int j = 1; j <= table.Columns.Count; j++){table.Cell(i, j).Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;}}}// 保存报告string outputPath = $@"C:\Reports\FinancialReport_{reportMonth:yyyyMM}.docx";document.SaveAs(outputPath, WdSaveFormat.wdFormatXMLDocument);document.Close();Console.WriteLine($"财务报告已生成: {outputPath}");}catch (Exception ex){Console.WriteLine($"生成财务报告时发生错误: {ex.Message}");}}
}

使用 Selection 对象

Selection对象代表文档中当前选中的区域。通过Selection对象,我们可以像在Word界面中操作一样插入文本。

// 获取当前选择区域
var selection = document.Selection;// 插入文本
selection.InsertText("这是通过Selection对象插入的文本。");// 插入段落
selection.InsertParagraph();// 插入换行符
selection.InsertLineBreak();

虽然Selection对象使用起来很直观,但在自动化处理中,我们通常不推荐将其作为主要方式,因为它依赖于当前光标位置,可能导致不可预期的结果。

应用场景:交互式文档编辑器

在某些场景中,可能需要开发一个交互式文档编辑器,允许用户通过界面操作文档。

// 交互式文档编辑器
public class InteractiveDocumentEditor
{private IWordApplication _wordApp;private IWordDocument _document;/// <summary>/// 初始化编辑器/// </summary>public void InitializeEditor(){try{// 创建可见的Word应用程序实例_wordApp = WordFactory.BlankWorkbook();_wordApp.Visibility = WordAppVisibility.Visible;_document = _wordApp.ActiveDocument;// 显示欢迎信息var selection = _document.Selection;selection.Font.Name = "微软雅黑";selection.Font.Size = 14;selection.Font.Bold = true;selection.Text = "欢迎使用交互式文档编辑器\n\n";selection.Font.Bold = false;selection.Font.Size = 12;selection.Text = "请开始编辑您的文档...\n";}catch (Exception ex){Console.WriteLine($"初始化编辑器时发生错误: {ex.Message}");}}/// <summary>/// 在光标位置插入文本/// </summary>/// <param name="text">要插入的文本</param>public void InsertTextAtCursor(string text){try{if (_document != null){var selection = _document.Selection;selection.InsertText(text);}}catch (Exception ex){Console.WriteLine($"插入文本时发生错误: {ex.Message}");}}/// <summary>/// 在光标位置插入日期/// </summary>public void InsertCurrentDate(){try{if (_document != null){var selection = _document.Selection;selection.InsertText(DateTime.Now.ToString("yyyy年MM月dd日"));}}catch (Exception ex){Console.WriteLine($"插入日期时发生错误: {ex.Message}");}}/// <summary>/// 清理资源/// </summary>public void Cleanup(){try{_document?.Close(false); // 不保存更改_wordApp?.Quit();}catch (Exception ex){Console.WriteLine($"清理资源时发生错误: {ex.Message}");}}
}

使用 Document.Content 和 Document.Paragraphs 等集合

通过文档的集合属性,我们可以更结构化地操作文档内容。

// 使用Document.Content获取整个文档内容
var contentRange = document.Content;
contentRange.Text += "添加到文档末尾的内容。\n";// 使用Paragraphs集合添加新段落
var newParagraph = document.Paragraphs.Add();
newParagraph.Range.Text = "这是一个新段落。";

这种方式适合于需要按结构化方式处理文档内容的场景。

应用场景:批量文档处理

在企业环境中,经常需要批量处理大量文档,例如为多份合同添加相同的条款。

// 批量文档处理器
public class BatchDocumentProcessor
{/// <summary>/// 为多个文档添加通用条款/// </summary>/// <param name="documentPaths">文档路径列表</param>/// <param name="termsText">通用条款文本</param>public void AddTermsToDocuments(List<string> documentPaths, string termsText){foreach (var documentPath in documentPaths){try{// 打开文档using var wordApp = WordFactory.Open(documentPath);var document = wordApp.ActiveDocument;// 隐藏Word应用程序以提高性能wordApp.Visibility = WordAppVisibility.Hidden;wordApp.DisplayAlerts = WdAlertLevel.wdAlertsNone;// 在文档末尾添加通用条款var contentRange = document.Content;contentRange.Collapse(WdCollapseDirection.wdCollapseEnd);// 添加分页符contentRange.InsertBreak(WdBreakType.wdPageBreak);// 添加条款标题contentRange.Text += "\n通用条款\n\n";contentRange.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;contentRange.Font.Bold = true;contentRange.Font.Size = 14;// 重置格式contentRange.Collapse(WdCollapseDirection.wdCollapseEnd);contentRange.Font.Bold = false;contentRange.Font.Size = 12;contentRange.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphLeft;// 添加条款内容contentRange.Text += termsText;// 保存文档document.Save();document.Close();Console.WriteLine($"已为文档添加通用条款: {documentPath}");}catch (Exception ex){Console.WriteLine($"处理文档 {documentPath} 时发生错误: {ex.Message}");}}}/// <summary>/// 为多个文档添加页眉和页脚/// </summary>/// <param name="documentPaths">文档路径列表</param>/// <param name="headerText">页眉文本</param>/// <param name="footerText">页脚文本</param>public void AddHeaderFooterToDocuments(List<string> documentPaths, string headerText, string footerText){foreach (var documentPath in documentPaths){try{// 打开文档using var wordApp = WordFactory.Open(documentPath);var document = wordApp.ActiveDocument;// 隐藏Word应用程序以提高性能wordApp.Visibility = WordAppVisibility.Hidden;wordApp.DisplayAlerts = WdAlertLevel.wdAlertsNone;// 设置页眉foreach (Section section in document.Sections){var headerRange = section.Headers[WdHeaderFooterIndex.wdHeaderFooterPrimary].Range;headerRange.Text = headerText;headerRange.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;}// 设置页脚foreach (Section section in document.Sections){var footerRange = section.Footers[WdHeaderFooterIndex.wdHeaderFooterPrimary].Range;footerRange.Text = footerText;footerRange.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;}// 保存文档document.Save();document.Close();Console.WriteLine($"已为文档添加页眉页脚: {documentPath}");}catch (Exception ex){Console.WriteLine($"处理文档 {documentPath} 时发生错误: {ex.Message}");}}}
}

3.2 字体格式设置 (Font Object)

在文档处理中,字体格式设置是提升文档可读性和美观度的重要手段。MudTools.OfficeInterop.Word通过IWordFont接口提供了丰富的字体格式设置功能。

基本字体属性设置

IWordFont接口提供了设置字体名称、大小、颜色、加粗、斜体、下划线等基本属性的方法。

// 获取文档内容范围
var range = document.Content;// 设置字体名称
range.Font.Name = "微软雅黑";// 设置字体大小(单位:磅)
range.Font.Size = 12;// 设置字体颜色
range.Font.Color = WdColor.wdColorBlue;// 设置加粗
range.Font.Bold = true;// 设置斜体
range.Font.Italic = true;// 设置下划线
range.Font.Underline = true;

高级字体属性设置

除了基本属性外,IWordFont还支持更多高级属性设置:

// 设置上标
range.Font.Superscript = true;// 设置下标
range.Font.Subscript = true;// 设置字符间距
range.Font.Spacing = 2; // 增加2磅间距// 设置字符缩放比例
range.Font.Scaling = 150; // 150%大小// 设置字符位置偏移
range.Font.Position = 3; // 上移3磅

应用场景:科学文档格式化

在学术或科研环境中,经常需要处理包含数学公式、化学方程式等特殊格式的文档。

// 科学文档格式化器
public class ScientificDocumentFormatter
{/// <summary>/// 格式化化学方程式/// </summary>/// <param name="document">Word文档</param>public void FormatChemicalEquations(IWordDocument document){try{// 查找所有化学方程式(假设用[chem]标记)var range = document.Content.Duplicate;while (range.FindAndReplace("[chem]", "", WdReplace.wdReplaceNone)){// 获取方程式内容var equationRange = document.Range(range.Start, range.End);// 格式化为下标equationRange.Font.Subscript = true;equationRange.Font.Size = 10;equationRange.Font.Name = "Cambria Math";}}catch (Exception ex){Console.WriteLine($"格式化化学方程式时发生错误: {ex.Message}");}}/// <summary>/// 格式化数学公式/// </summary>/// <param name="document">Word文档</param>public void FormatMathematicalFormulas(IWordDocument document){try{// 查找所有数学公式(假设用[math]标记)var range = document.Content.Duplicate;while (range.FindAndReplace("[math]", "", WdReplace.wdReplaceNone)){// 获取公式内容var formulaRange = document.Range(range.Start, range.End);// 设置字体为数学字体formulaRange.Font.Name = "Cambria Math";formulaRange.Font.Size = 12;// 处理上标(用^标记)var superscriptRange = formulaRange.Duplicate;while (superscriptRange.FindAndReplace("^", "", WdReplace.wdReplaceNone)){var supRange = document.Range(superscriptRange.Start, superscriptRange.End + 1);supRange.Font.Superscript = true;supRange.Font.Size = 8;}// 处理下标(用_标记)var subscriptRange = formulaRange.Duplicate;while (subscriptRange.FindAndReplace("_", "", WdReplace.wdReplaceNone)){var subRange = document.Range(subscriptRange.Start, subscriptRange.End + 1);subRange.Font.Subscript = true;subRange.Font.Size = 8;}}}catch (Exception ex){Console.WriteLine($"格式化数学公式时发生错误: {ex.Message}");}}/// <summary>/// 格式化代码片段/// </summary>/// <param name="document">Word文档</param>public void FormatCodeSnippets(IWordDocument document){try{// 查找所有代码片段(假设用[code]标记)var range = document.Content.Duplicate;while (range.FindAndReplace("[code]", "", WdReplace.wdReplaceNone)){// 获取代码内容var codeRange = document.Range(range.Start, range.End);// 设置等宽字体codeRange.Font.Name = "Consolas";codeRange.Font.Size = 10;codeRange.Font.Bold = false;// 设置背景色codeRange.Shading.BackgroundPatternColor = WdColor.wdColorGray25;// 添加边框codeRange.Borders.Enable = 1;}}catch (Exception ex){Console.WriteLine($"格式化代码片段时发生错误: {ex.Message}");}}
}

3.3 段落格式设置 (ParagraphFormat Object)

段落格式决定了文本的布局和视觉效果。通过IWordParagraphFormat接口,我们可以设置段落的对齐方式、缩进、行距等属性。

段落对齐方式

// 获取文档内容范围
var range = document.Content;// 设置段落对齐方式
range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter; // 居中对齐
// 其他选项包括:
// WdParagraphAlignment.wdAlignParagraphLeft    - 左对齐
// WdParagraphAlignment.wdAlignParagraphRight   - 右对齐
// WdParagraphAlignment.wdAlignParagraphJustify - 两端对齐

缩进设置

// 设置首行缩进(单位:磅)
range.ParagraphFormat.FirstLineIndent = 21; // 约等于2个字符宽度// 设置左缩进
range.ParagraphFormat.LeftIndent = 36; // 约等于3个字符宽度// 设置右缩进
range.ParagraphFormat.RightIndent = 18; // 约等于1.5个字符宽度

行距和间距设置

// 设置行距规则
range.ParagraphFormat.LineSpacingRule = WdLineSpacing.wdLineSpaceDouble; // 双倍行距
// 其他选项包括:
// WdLineSpacing.wdLineSpaceSingle     - 单倍行距
// WdLineSpacing.wdLineSpace1pt5       - 1.5倍行距
// WdLineSpacing.wdLineSpaceExactly    - 固定值行距
// WdLineSpacing.wdLineSpaceMultiple   - 多倍行距// 设置段前间距(单位:磅)
range.ParagraphFormat.SpaceBefore = 12;// 设置段后间距(单位:磅)
range.ParagraphFormat.SpaceAfter = 12;

应用场景:文档样式统一化

在企业环境中,为了保持文档风格的一致性,经常需要对文档进行样式统一化处理。

// 文档样式统一化工具
public class DocumentStyleUnifier
{/// <summary>/// 统一文档标题样式/// </summary>/// <param name="document">Word文档</param>public void UnifyHeadingStyles(IWordDocument document){try{// 处理一级标题(以#开头的段落)var heading1Range = document.Content.Duplicate;while (heading1Range.FindAndReplace("# ", "", WdReplace.wdReplaceNone)){// 获取标题段落var para = heading1Range.Paragraphs.First();var paraRange = para.Range;// 设置一级标题样式paraRange.Font.Name = "黑体";paraRange.Font.Size = 16;paraRange.Font.Bold = true;paraRange.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;paraRange.ParagraphFormat.SpaceBefore = 18;paraRange.ParagraphFormat.SpaceAfter = 12;// 移除标记符号paraRange.Text = paraRange.Text.Replace("# ", "");}// 处理二级标题(以##开头的段落)var heading2Range = document.Content.Duplicate;while (heading2Range.FindAndReplace("## ", "", WdReplace.wdReplaceNone)){// 获取标题段落var para = heading2Range.Paragraphs.First();var paraRange = para.Range;// 设置二级标题样式paraRange.Font.Name = "微软雅黑";paraRange.Font.Size = 14;paraRange.Font.Bold = true;paraRange.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphLeft;paraRange.ParagraphFormat.SpaceBefore = 12;paraRange.ParagraphFormat.SpaceAfter = 6;// 移除标记符号paraRange.Text = paraRange.Text.Replace("## ", "");}}catch (Exception ex){Console.WriteLine($"统一标题样式时发生错误: {ex.Message}");}}/// <summary>/// 统一文档正文样式/// </summary>/// <param name="document">Word文档</param>public void UnifyBodyTextStyles(IWordDocument document){try{// 获取文档正文范围var bodyRange = document.Content;// 设置正文样式bodyRange.Font.Name = "仿宋_GB2312";bodyRange.Font.Size = 12;bodyRange.ParagraphFormat.FirstLineIndent = 28; // 首行缩进2字符bodyRange.ParagraphFormat.LineSpacingRule = WdLineSpacing.wdLineSpace1pt5; // 1.5倍行距bodyRange.ParagraphFormat.SpaceBefore = 0;bodyRange.ParagraphFormat.SpaceAfter = 0;}catch (Exception ex){Console.WriteLine($"统一正文样式时发生错误: {ex.Message}");}}/// <summary>/// 统一列表样式/// </summary>/// <param name="document">Word文档</param>public void UnifyListStyles(IWordDocument document){try{// 处理无序列表(以-开头的行)var bulletRange = document.Content.Duplicate;while (bulletRange.FindAndReplace("- ", "", WdReplace.wdReplaceNone)){var listRange = document.Range(bulletRange.Start, bulletRange.End);// 应用项目符号列表格式listRange.ListFormat.ApplyBulletDefault();// 设置列表项格式listRange.ParagraphFormat.LeftIndent = 36;listRange.ParagraphFormat.FirstLineIndent = -18;}// 处理有序列表(以数字.开头的行)for (int i = 1; i <= 9; i++){var numberedRange = document.Content.Duplicate;while (numberedRange.FindAndReplace($"{i}. ", "", WdReplace.wdReplaceNone)){var listRange = document.Range(numberedRange.Start, numberedRange.End);// 应用编号列表格式listRange.ListFormat.ApplyNumberDefault();// 设置列表项格式listRange.ParagraphFormat.LeftIndent = 36;listRange.ParagraphFormat.FirstLineIndent = -18;}}}catch (Exception ex){Console.WriteLine($"统一列表样式时发生错误: {ex.Message}");}}
}

3.4 实战:创建一个格式规范的商业信函模板

现在,让我们综合运用前面学到的知识,创建一个格式规范的商业信函模板。

using MudTools.OfficeInterop;
using MudTools.OfficeInterop.Word;
using System;public class BusinessLetterTemplate
{public void CreateBusinessLetter(){try{// 创建一个新的空白文档using var wordApp = WordFactory.BlankWorkbook();var document = wordApp.ActiveDocument;// 隐藏Word应用程序以提高性能wordApp.Visibility = WordAppVisibility.Hidden;// 禁止显示警告wordApp.DisplayAlerts = WdAlertLevel.wdAlertsNone;// 设置文档整体字体document.Content.Font.Name = "仿宋_GB2312";document.Content.Font.Size = 12;// 插入发信人信息(右对齐)var senderRange = document.Range(0, 0);senderRange.Text = "发信人公司名称\n地址\n电话:XXX-XXXXXXX\n邮箱:xxxx@xxxx.com\n\n";senderRange.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphRight;// 插入日期(右对齐)var dateRange = document.Range(document.Content.End - 1, document.Content.End - 1);dateRange.Text = DateTime.Now.ToString("yyyy年MM月dd日") + "\n\n";dateRange.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphRight;// 插入收信人信息(左对齐)var recipientRange = document.Range(document.Content.End - 1, document.Content.End - 1);recipientRange.Text = "收信人姓名\n收信人职位\n收信人公司名称\n收信人地址\n\n";recipientRange.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphLeft;// 插入信件正文标题(居中,加粗)var titleRange = document.Range(document.Content.End - 1, document.Content.End - 1);titleRange.Text = "商务合作邀请函\n\n";titleRange.Font.Bold = true;titleRange.Font.Size = 16;titleRange.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;// 重置字体大小titleRange.Font.Size = 12;// 插入正文内容(首行缩进)var contentRange = document.Range(document.Content.End - 1, document.Content.End - 1);string content = "尊敬的合作伙伴:\n\n" +"    首先感谢您一直以来对我们公司的关注与支持。我们诚挚地邀请您参与我们的新项目合作。" +"该项目旨在通过双方的优势资源整合,实现互利共赢的目标。\n\n" +"    我们相信,通过双方的精诚合作,必将开创更加美好的未来。期待您的积极回应," +"并希望能尽快与您展开深入的交流与探讨。\n\n" +"    如有任何疑问,请随时与我们联系。\n\n" +"此致\n敬礼!\n\n\n";contentRange.Text = content;// 设置正文段落格式(首行缩进2字符)contentRange.ParagraphFormat.FirstLineIndent = 28; // 约等于2个字符宽度// 插入发信人签名var signatureRange = document.Range(document.Content.End - 1, document.Content.End - 1);signatureRange.Text = "发信人姓名\n发信人职位\n发信人公司名称";signatureRange.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphLeft;// 保存文档string outputPath = @"C:\Temp\BusinessLetterTemplate.docx";document.SaveAs(outputPath, WdSaveFormat.wdFormatXMLDocument);Console.WriteLine($"商业信函模板已创建: {outputPath}");}catch (Exception ex){Console.WriteLine($"创建商业信函模板时发生错误: {ex.Message}");}}public void CreateFormattedBusinessLetter(string senderCompany, string senderAddress, string senderPhone, string senderEmail,string recipientName, string recipientTitle,string recipientCompany, string recipientAddress,string letterSubject, string letterContent){try{// 基于模板创建文档using var wordApp = WordFactory.BlankWorkbook();var document = wordApp.ActiveDocument;wordApp.Visibility = WordAppVisibility.Hidden;wordApp.DisplayAlerts = WdAlertLevel.wdAlertsNone;// 设置文档整体字体document.Content.Font.Name = "仿宋_GB2312";document.Content.Font.Size = 12;// 插入发信人信息var senderRange = document.Range(0, 0);senderRange.Text = $"{senderCompany}\n{senderAddress}\n电话:{senderPhone}\n邮箱:{senderEmail}\n\n";senderRange.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphRight;// 插入日期var dateRange = document.Range(document.Content.End - 1, document.Content.End - 1);dateRange.Text = DateTime.Now.ToString("yyyy年MM月dd日") + "\n\n";dateRange.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphRight;// 插入收信人信息var recipientRange = document.Range(document.Content.End - 1, document.Content.End - 1);recipientRange.Text = $"{recipientName}\n{recipientTitle}\n{recipientCompany}\n{recipientAddress}\n\n";recipientRange.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphLeft;// 插入信件标题var titleRange = document.Range(document.Content.End - 1, document.Content.End - 1);titleRange.Text = $"{letterSubject}\n\n";titleRange.Font.Bold = true;titleRange.Font.Size = 16;titleRange.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;titleRange.Font.Size = 12;// 插入正文内容var contentRange = document.Range(document.Content.End - 1, document.Content.End - 1);contentRange.Text = letterContent;contentRange.ParagraphFormat.FirstLineIndent = 28;// 插入发信人签名占位符var signatureRange = document.Range(document.Content.End - 1, document.Content.End - 1);signatureRange.Text = "\n\n发信人签名:___________\n发信人姓名\n发信人职位\n发信人公司名称";signatureRange.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphLeft;// 保存文档string outputPath = $@"C:\Temp\{letterSubject}.docx";document.SaveAs(outputPath, WdSaveFormat.wdFormatXMLDocument);Console.WriteLine($"格式化的商业信函已创建: {outputPath}");}catch (Exception ex){Console.WriteLine($"创建格式化的商业信函时发生错误: {ex.Message}");}}
}

应用场景:企业文档自动化系统

基于我们学到的知识,可以构建一个完整的企业文档自动化系统:

// 企业文档自动化系统
public class EnterpriseDocumentAutomationSystem
{/// <summary>/// 商务信函生成服务/// </summary>public class BusinessLetterService{/// <summary>/// 生成商务信函/// </summary>/// <param name="request">信函请求参数</param>/// <returns>生成的文档路径</returns>public string GenerateBusinessLetter(BusinessLetterRequest request){try{using var wordApp = WordFactory.BlankWorkbook();var document = wordApp.ActiveDocument;wordApp.Visibility = WordAppVisibility.Hidden;wordApp.DisplayAlerts = WdAlertLevel.wdAlertsNone;// 应用标准模板样式ApplyStandardStyles(document);// 填充信函内容FillLetterContent(document, request);// 保存文档string outputPath = $@"C:\Documents\BusinessLetters\{request.LetterId}.docx";document.SaveAs(outputPath, WdSaveFormat.wdFormatXMLDocument);document.Close();return outputPath;}catch (Exception ex){throw new DocumentGenerationException($"生成商务信函时发生错误: {ex.Message}", ex);}}private void ApplyStandardStyles(IWordDocument document){// 设置全局字体document.Content.Font.Name = "仿宋_GB2312";document.Content.Font.Size = 12;// 设置页面边距document.PageSetup.TopMargin = 72;    // 1英寸document.PageSetup.BottomMargin = 72; // 1英寸document.PageSetup.LeftMargin = 90;   // 1.25英寸document.PageSetup.RightMargin = 90;  // 1.25英寸}private void FillLetterContent(IWordDocument document, BusinessLetterRequest request){// 插入发信人信息InsertSenderInfo(document, request.SenderInfo);// 插入日期InsertDate(document, request.LetterDate);// 插入收信人信息InsertRecipientInfo(document, request.RecipientInfo);// 插入信函标题InsertLetterTitle(document, request.Subject);// 插入正文内容InsertLetterContent(document, request.Content);// 插入签名InsertSignature(document, request.SenderInfo);}private void InsertSenderInfo(IWordDocument document, SenderInfo senderInfo){var range = document.Range(0, 0);range.Text = $"{senderInfo.Company}\n{senderInfo.Address}\n电话:{senderInfo.Phone}\n邮箱:{senderInfo.Email}\n\n";range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphRight;}private void InsertDate(IWordDocument document, DateTime date){var range = document.Range(document.Content.End - 1, document.Content.End - 1);range.Text = date.ToString("yyyy年MM月dd日") + "\n\n";range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphRight;}private void InsertRecipientInfo(IWordDocument document, RecipientInfo recipientInfo){var range = document.Range(document.Content.End - 1, document.Content.End - 1);range.Text = $"{recipientInfo.Name}\n{recipientInfo.Title}\n{recipientInfo.Company}\n{recipientInfo.Address}\n\n";range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphLeft;}private void InsertLetterTitle(IWordDocument document, string subject){var range = document.Range(document.Content.End - 1, document.Content.End - 1);range.Text = $"{subject}\n\n";range.Font.Bold = true;range.Font.Size = 16;range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;range.Font.Size = 12;}private void InsertLetterContent(IWordDocument document, string content){var range = document.Range(document.Content.End - 1, document.Content.End - 1);range.Text = content;range.ParagraphFormat.FirstLineIndent = 28;}private void InsertSignature(IWordDocument document, SenderInfo senderInfo){var range = document.Range(document.Content.End - 1, document.Content.End - 1);range.Text = $"\n\n发信人签名:___________\n{senderInfo.Name}\n{senderInfo.Title}\n{senderInfo.Company}";range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphLeft;}}// 数据模型类public class BusinessLetterRequest{public string LetterId { get; set; }public SenderInfo SenderInfo { get; set; }public RecipientInfo RecipientInfo { get; set; }public DateTime LetterDate { get; set; }public string Subject { get; set; }public string Content { get; set; }}public class SenderInfo{public string Company { get; set; }public string Address { get; set; }public string Phone { get; set; }public string Email { get; set; }public string Name { get; set; }public string Title { get; set; }}public class RecipientInfo{public string Name { get; set; }public string Title { get; set; }public string Company { get; set; }public string Address { get; set; }}public class DocumentGenerationException : Exception{public DocumentGenerationException(string message, Exception innerException) : base(message, innerException){}}
}

小结

本文详细介绍了使用MudTools.OfficeInterop.Word库操作Word文档文本和格式的方法:

  1. 文本插入方式:介绍了通过Range.Text属性、Selection对象和文档集合属性等多种方式插入文本,并提供了相应的应用场景和代码示例
  2. 字体格式设置:演示了如何使用IWordFont接口设置字体名称、大小、颜色、加粗、斜体等属性,并展示了在科学文档格式化中的应用
  3. 段落格式设置:展示了如何使用IWordParagraphFormat接口设置段落对齐方式、缩进、行距等属性,并提供了文档样式统一化的实际应用
  4. 实战应用:通过创建商业信函模板和企业文档自动化系统,综合运用了所学的文本和格式操作知识

掌握这些文本和格式操作技巧,可以帮助我们创建更加专业和美观的Word文档,为后续的文档自动化处理奠定坚实基础。

在下一篇文章中,我们将探讨更高级的主题,包括表格操作、图片插入和文档样式设置等内容。敬请期待!

相关文章:

.NET驾驭Word之力:玩转文本与格式

在前面的文章中,我们已经了解了Word对象模型的核心组件,包括Application、Document和Range对象。掌握了这些基础知识后,我们现在可以进一步深入到文档内容的处理,特别是文本的插入和格式化操作。本文将详细介绍如何使用MudTools.OfficeInterop.Word库来操作Word文档中的文本…...

读书笔记:白话解读位图索引:什么时候该用,什么时候千万别用?

我们的文章会在微信公众号IT民工的龙马人生和博客网站( www.htz.pw )同步更新 ,欢迎关注收藏,也欢迎大家转载,但是请在文章开始地方标注文章出处,谢谢! 由于博客中有大量代码,通过页面浏览效果更佳。本文为个人学习《Expert Oracle Database Architecture Techniques and…...

泰克CT-6交流电流探头测量原理

泰克 CT-6 交流电流探头是一款在电气测量领域广泛使用的专业工具。其测量原理基于电磁感应定律,通过精巧的设计实现对交流电流的精确测量。 从结构上看,泰克 CT-6 交流电流探头主要由磁芯、线圈和信号处理电路等部分构成。当交流电流通过导线时,会在导线周围产生变化的磁场,…...

结构体成员赋值问题

在函数里这样写对吗stCalc->stStitchingRule={.segment_count = 3, .segment_starts = {0, 336, 900}, .segment_lengths = {300, 100, 112}, .stitched_total_length = 512}; 问题分析 在C语言中,直接在函数内对结构体成员(如 stCalc->stStitchingRule)使用​​复合字…...

RepositoryItemGridLookUpEdit 使用 ok

private void Form1_Load(object sender, EventArgs e){下拉初始化();gridControl1.DataSource = DemoData.GetGridData();}private void 下拉初始化(){GridView view = rep_Grid.View;view.Columns.Add(new GridColumn { Caption = "货号", FieldName = "Goods…...

wso2~系统端口总结

好的,这是 WSO2 API Manager 中这些常见端口的详细总结。了解这些端口对于部署、运维和故障排查至关重要。 我将它们分为 API 流量端口、管理/控制平面端口 和 内部通信端口 三类。一、API 流量端口 (API Traffic Ports) 这些端口用于处理实际的 API 调用(数据平面流量)。端…...

故障处理:19C RAC改私网IP后重建集群时报网络找不到

我们的文章会在微信公众号IT民工的龙马人生和博客网站( www.htz.pw )同步更新 ,欢迎关注收藏,也欢迎大家转载,但是请在文章开始地方标注文章出处,谢谢! 由于博客中有大量代码,通过页面浏览效果更佳。今天在回复23年安装的ARM环境的19C的集群时,将服务器的私有网络和共有…...

谈谈程序猿的职业方向

大学生在校期间可能会有这样的疑问:将来就业干啥好呢? 如果你是学计算机的,将来想进入软件和互联网行业,恭喜,这是个好行业,薪水很高, 也不需靠关系,一切靠实力说话,不需要有个好爸爸。 坏处是,这个行业需要极为繁重的脑力和体力劳动,加班也是司空见惯的事情。 接下…...

Flash Attention详解

Flash Attention 并没有减少 Attention 的计算量,也不影响精度,但是却比标准的Attention运算快 2~4 倍的运行速度,减少了 5~20 倍的内存使用量。究竟是怎么实现的呢? Attention 为什么慢? 此处的“快慢”是相对而言的。严格意义上来说,相比于传统的 RNN,Transformer中的…...

eclipse插件调用保护后的jar包流程

jar包如何调用使用 导入jar包创建好项目后,进入项目后,创建libs文件夹,将jar包放入libs文件夹内; 选中项目,点击Runtime->Add选项,添加libs里的jar包;项目配置 当jar包导入成功后,对此项目进行配置。选中Build,将libs目录下所需要的jar包勾选上;添加成功后,点击b…...

通义上线 FunAudio-ASR,噪声场景幻觉率降 70%;盒智科技推出 AI 口语练习陪伴设备 Lookee 丨日报

开发者朋友们大家好:这里是 「RTE 开发者日报」,每天和大家一起看新闻、聊八卦。我们的社区编辑团队会整理分享 RTE(Real-Time Engagement) 领域内「有话题的技术」、「有亮点的产品」、「有思考的文章」、「有态度的观点」、「有看点的活动」,但内容仅代表编辑的个人观点…...

reLeetCode 热题 100-11 盛最多的谁 - MKT

reLeetCode 热题 100-11 盛最多的谁 1 bu 不合格答案 暴力// 时间超时int my_1(vector<int>& height){// x * hign_minint max_=0;for(int i=0; i<height.size()-1;i++){for(int j=i+1; j<height.size();j++){int high_= std::min(height[i],height[j]);int …...

AI 视频生成网站 Viddo AI 的 SEO 分析和优化建议

AI 视频生成网站 Viddo AI 的 SEO 分析和优化建议有个朋友的新网站 Viddo AI - AI 生成图片和视频上线了,我提了一些 SEO 和前端方面的问题和修改意见,顺便记录到蓝星空的 Blog,希望对其他朋友也有一点帮助,可能也有一些考虑不周的地方,欢迎大家指正!SEO方面的问题和修改…...

k3s 离线部署流程(内网环境)

k3s 离线部署流程(内网环境) 一、准备工作 1. 下载 k3s 安装相关文件(在有外网的跳板机上)k3s 安装脚本curl -sfL https://get.k3s.io -o install_k3s.shk3s 二进制文件curl -LO https://github.com/k3s-io/k3s/releases/download/<k3s版本>/k3sk3s 镜像包wget https…...

GPS简单模拟

注册回调 LocationListener,listener 被封装在 receiver 中@Overridepublic void requestLocationUpdates(LocationRequest request, ILocationListener listener,PendingIntent intent, String packageName) {...Receiver receiver;if (intent != null) {receiver = getRecei…...

C# Avalonia 15- Animation- XamlAnimation

C# Avalonia 15- Animation- XamlAnimation同样用两种方式实现动画,各位自行选择。实现了一个ArithmeticConverter类。 ArithmeticConverter.cs类using Avalonia.Data.Converters; using System; using System.Collections.Generic; using System.Globalization; using System…...

多个表格汇总到一个表格不同的sheet,vba宏

`Sub MergeWorkbookToSheets()Dim Path As StringDim Filename As StringDim Wb As WorkbookDim ws As WorksheetDim ThisWb As WorkbookDim Newsheet As Worksheet设置目标文件夹路径,请修改为您的实际路径Path = "C:\Users\haifeng\OneDrive\桌面\测试bom\" 注意:…...

python读取Excel表合并单元格以及清除空格符

读取合并单元格并保留合并信息 当我们只是使用 pandas 的 read_excel 方法读取 Excel 文件时,我们可能会遇到一个很棘手的问题:合并单元格的信息将会丢失,从而导致我们的数据出现重复或缺失的情况。 在本篇文章中将介绍使用 pandas 正确地读取包含合并单元格的 Excel 表格,…...

算法作业第一周

大厂代码规范代码格式大括号的使用约定。 如果是大括号内为空,则简洁地写成{}即可,不需要换行; 如果是非空代码块则:左大括号前不换行。左大括号后换行。右大括号前换行。右大括号后还有 else 等代码则不换行;表示终止的右大括号后必须换行。 任何二目、三目运算符的左右两…...

域名购买方案

https://linux.do/t/topic/963151/21...

Anby_の模板题集

洛谷版。 博客备份版。 普及- B3647 【模板】Floyd #include<bits/stdc++.h> #define x first #define y second using namespace std; const int N=2e2+10,inf=0x3f3f3f3f,mod=1e9+7; typedef unsigned long long ull; typedef pair<int,int> pii; typedef long l…...

AI 编程的“最后一公里”:当强大的代码生成遇上模糊的需求

随着AI编程工具的崛起,代码生成效率极大提升,但AI与实际项目需求间的“鸿沟”却日益凸显。本文探讨了在AI驱动的开发流程中,结构化、高质量的开发文档如何成为连接“模糊想法”与“精准代码”的关键桥梁,有效打通AI编程的“最后一公里”。引言:AI 编程时代的“新瓶颈” 20…...

ctfshowWeb应用安全与防护(第四章)wp

Session固定攻击 登录test账号,给admin发送消息回到主页发现用户名变成了admin,获得了flagJWT令牌伪造 先随便输入一个用户名,获得jwt tokenJWT伪造网站 JSON Web Tokens - jwt.io 由于没有校验签名, 我们可以采用 None 攻击,将alg改为none,admin改为True修改cookie,刷新…...

创建sshkey并链接git

以 Hugging Face 账户为示例: 生成ssh key到指定文件 ssh-keygen -t rsa -C "email.com" -f C:\Users\Administrator\.ssh\huggingface将生成的key放到hugging_face上 https://huggingface.co/settings/keyswindow powershell: Get-Service ssh-agent | Set-Servic…...

使用bash脚本检测网站SSL证书是否过期 - sherlock

#!/bin/bash# 加载环境变量 . /etc/profile . ~/.bash_profile . /etc/bashrc# 脚本所在目录即脚本名称 script_dir=$( cd "$( dirname "$0" )" && pwd ) script_name=$(basename ${0}) readFile="${script_dir}/domain_ssl.info"# 检查…...

Python 2025:低代码开发与自动化运维的新纪元 - 教程

Python 2025:低代码开发与自动化运维的新纪元 - 教程pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco", "Courier New", monos…...

为什么Claude Code放弃代码索引,使用50年前的grep技术

为什么Claude Code放弃代码索引,使用50年前的grep技术? https://mp.weixin.qq.com/s/Fa15GoM3_2CUnjdHQ3I7Nw 为什么Claude Code放弃代码索引,使用50年前的grep技术? 原创 余志臻 腾讯云开发者2025年09月16日 08:45 北京 👉目录1 引言:一个看似倒退的选择2 理解状态的本…...

【QT】使用QT编写一款自己的串口助手

步骤一:ui界面设计 控件 接收框控件: (需要将接收框设置为只读 read only) 属性选择控件: 发送框控件: 按钮控件: 外框控件: 文本控件: 界面设计 最终设计结果布局解析程序设计 第一步 在.pro文件中修改增加: QT += core gui serialport // 增加 serialp…...

一句话让AI帮你搞营销?火山引擎Data Agent说:这事儿可以的~

本文为火山引擎数据产品总监刘峰的演讲分享,介绍了在过去的半年中,火山引擎Data Agent在智能营销Agent领域的一些新思考、新能力以及落地实践。 各位线上的朋友,大家好!今天主要跟大家聊聊四个关键主题: 首先,面对用户和业务增长挑战,结合大模型我们有哪些新解法? 其次…...

debian11 使用 podman 部署 n8n

拉取镜像podman pull docker.n8n.io/n8nio/n8n:latest创建目录和启动脚本mkdir -p /root/n8n/ touch run.shrun.sh #!/bin/bash name=n8n data_dir=/root/n8n/data ssl_dir=/root/n8n/ssl cart_file=$ssl_dir/cert.pem key_file=$ssl_dir/key.pemif [ ! -d $data_dir ]; thenmk…...

网络安全反模式:无效工作生成器的根源与解决方案

本文深入探讨网络安全中常见的“无效工作生成器”反模式,通过真实案例解析其成因,并提出基于根本原因分析的解决方案,包括优先级策略、机制构建及实际应用案例,帮助团队避免资源浪费并提升安全效能。网络安全反模式:无效工作生成器 2025年4月19日 3025字 15分钟阅读 本文…...

Excel处理控件Aspose.Cells教程:如何将Excel区域转换为Python列表

在 Python 中处理 Excel 数据通常需要将特定的行和列提取为列表格式。在本教程中,我们将逐步学习如何借助Aspose.Cells在 Python 中将定义的 Excel 范围转换为列表。在 Python 中处理 Excel 数据通常需要将特定的行和列提取为列表格式。将 Excel 范围转换为 Python 列表对于以…...

alpine安装docker以及docker-compose

alpine安装docker以及docker-compose1. 开启community仓库,vim /etc/apk/repositories 2. apk add docker docker compose 3. docker 添加到自启动 rc-update add docker boot 4. 启动docker:service docker start...

运筹学

运筹学绪论 运筹学主要分支划分方法:一般数学规划模型/特定问题的数学模型。前者划分出线性规划/整数规划/非线性规划/DP/网络流/...,后者划分出网络计划/排队论/存储论/决策论/对策论/... 人工智能的许多问题均与运筹学密不可分 核心:建模与求解 e.g.线性规划:给定基函数和…...

[CF848D] Shake It!

\(f(i, j)\):\(S \to T\) 除去 \(S, T\) 有 \(i\) 个点,最大流为 \(j\) 的方案数。 \(g(i, j)\):\(S \to U \to T\) 除去 \(S, T\) 有 \(i\) 个点,最大流为 \(j\) 的方案数。 \(f\) 向 \(g\) 转移:\(f(a, b) \times f(c, d) \to g(a + c + 1, \min(b, d))\)。 当前 \(a + …...

国产化Excel开发组件Spire.XLS教程:使用 Python 设置 Excel 格式,从基础到专业应用

与在 Excel 中手动调整样式相比,使用 Python 进行 Excel 格式设置 并自动化操作,能够帮助我们节省宝贵的时间。本文将演示如何借助 Spire.XLS for Python 通过 Python 设置 Excel 样式。 在处理电子表格时,数据本身固然重要,但可读性同样关键。一个拥有优秀格式设置的 Exc…...

计算机辅助筛选抗菌/抗病毒肽:以SARS-CoV-2为例,解析靶标突破与筛选策略

抗菌药物耐药性(AMR)已成为全球公共卫生的重大威胁 —— 抗生素在农牧业的滥用、临床不合理使用,导致手术、移植等领域的感染治疗难度陡增;而病毒(如 SARS-CoV-2)的变异与耐药风险,进一步加剧了疾病防控压力。在此背景下,抗菌 / 抗病毒肽(AMPs)凭借 “多作用机制(膜…...

c++国外学习视频心得4-opengl

向量有方向,没有位置,有大小,比如力的大小,速度在大小等。归一化:(x/向量长度, y/向量长度, z/向量长度)。纯粹的方向计算就是只有方向上的影响,大小是1所以不影响大小。 向量长度向量点乘向量叉乘...

LOJ #3835. 「IOI2022」千岛 题解

Description 千岛是爪哇海里一组美丽的岛屿,其中有 \(N\) 个岛屿,编号为从 \(0\) 到 \(N - 1\)。 有 \(M\) 艘独木舟在岛屿之间航行,编号为从 \(0\) 到 \(M - 1\)。对于满足 \(0 \le i \le M - 1\) 的所有 \(i\),独木舟 \(i\) 可以停靠在岛屿 \(U_i\) 或 \(V_i\),并且在岛…...

(附源码)高校拼车管理系统的设计与实现 - 实践

(附源码)高校拼车管理系统的设计与实现 - 实践pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco", "Courier New", monospace …...

Ubuntu取消vim自动对齐

方法一:在 Vim 中临时关闭自动对齐 在 Vim 编辑文件时,进入命令模式(按 Esc),然后输入以下命令: :set paste这会进入“粘贴模式”,关闭所有自动缩进和格式化功能,适合粘贴代码或手动编辑。 要重新开启自动功能,输入: :set nopaste方法二:修改或创建用户配置文件 vim…...

AI产品测试学习路径全解析:从业务场景到代码实践

深入AI测试领域,掌握核心技能与学习路线 在AI技术日益普及的今天,AI产品的质量保障成为关键环节。如何系统学习AI测试并掌握其核心技能?本文基于一线专家的实战经验,为你梳理出一条清晰的学习路径,涵盖业务理解、指标计算与性能测试三大阶段。 一、先理解业务场景,再制定…...

代码随想录算法训练营第一天 | leetcode 704 27 977

第一题二分查找 简答回答:经典的二分查找,采用的是左闭右闭区间,主要需要注意的就是右区间的下标 代码如下:class Solution { public int search(int[] nums, int target) { int left = 0;//左下标 int right = nums.length-1;//右下标 //循环条件 …...

中文医学基准测试题库数据集:28万条标准化JSON格式医师考试题目与临床案例分析,覆盖28个医学专业领域,用于医学AI模型训练、临床决策支持系统开发、医学知识问答系统构建、医学教育辅助工具优化

获取更多高质量数据可以访问典枢平台 https://dianshudata.com 引言与背景 在人工智能技术快速发展的今天,医疗健康领域正迎来前所未有的变革机遇。医学人工智能系统的研发与应用已成为推动医疗服务质量提升、降低医疗成本、提高诊疗效率的重要途径。然而,构建高质量的医学AI…...

GNSS终端授时方式

GNSS终端授时方式介绍了为什么GNSS接收机能够授时 为什么需要四颗星才能够定位?应该还有很多朋友不太了解 GNSS卫星定位的基本原理。 第二是我最近构思了后续文章的主题,后续文章需要用到GNSS定位的基本原理,所以今天提前介绍一下,算是给后续文章做一个铺垫。 理想情况下两…...

SpringAI接入DeepSeek大模型实现流式对话

SpringAl接入DeepSeek大模型,可实现对话模型(deepseek-chat)和推理模型(deepseek-reasoner)的交互。 ChatClienti适用于复杂功能开发,而ChatModel更适合简单场景。一、 环境配置 Spring AI 支持 Spring Boot 3.4.x,JDK支持需要17以上 添加快照存储库 <repositories><…...

函数计算的云上计费演进:从请求驱动到价值驱动,助力企业走向 AI 时代

函数计算的演进史,其实也是一部计费方式的演化史。透过计费这一窗口,我们可以一管窥全豹,清晰地看到背后产品形态在技术与体验上的深刻变化,以及技术架构随应用场景不断演化的能力。作者:砥行 在云计算的发展过程中,计费方式往往是开发者最直观的感知。最初,用户需要直接…...

【SPIE出版】第五届计算机图形学、人工智能与数据处理国际学术会议

第五届计算机图形学、人工智能与数据处理国际学术会议 2025 5th International Conference on Computer Graphics, Artificial Intelligence and Data Processing (ICCAID 2025) 在这里看会议官网详情 大会时间:2025年10月31-11月2日 大会地点:中国-南昌-南昌航空大学 截稿时…...

通知语音播报功能,解锁全新体验

在触达用户的多种途径中,推送通知消息凭借其高效性和便捷性,成为一种高性价比的营销手段。然而由于各应用推送频率过高,导致重要通知消息常被淹没在海量信息中,难以及时触达用户。比如商家的新订单提醒或者是收款到账通知等重要提醒,往往会因为消息过多而被用户忽视。 为解…...

使用AI容器镜像部署Qwen大语言模型

场景简介 在本实验场景中,将使用Alibaba Cloud AI Containers(AC2)容器镜像服务,通过Docker容器镜像部署Qwen系列大语言模型。本实验场景基于第八代Intel实例,使用Alibaba Cloud Linux 3作为实验系统,使能Intel最新的 AI 加速指令集,提供完整的容器生态支持。 本实验场景…...