1.通过IceBlue进行word导出,默认开启修订,如果可行的话,试一下修订模式不让用户关闭
云端默认开启修订模式后,下载前设置文档只开启批注和和修订权限,或者在生成的时候设置限定
参考API:https://www.e-iceblue.cn/security/protect-word-document.html
2.用户在拿到word文件后,再次上传时,精准读取表格的内容和数据库的映射关系
使用书签生成表格,然后再获取书签中的表格信息。
标签相关操作API:https://www.e-iceblue.cn/bookmark/add-replace-and-remove-word-bookmark.html
操作表格API:https://www.e-iceblue.cn/table/working-with-rows-and-columns-of-word-table.html
3、需要知道用户对哪个Activety的书签加了批注,见如下代码:
书签ID是CUS_TEST,内容是:123456789,其中345做了批注,程序运行效果
实现代码:
using Spire.Doc;
using Spire.Doc.Documents;
using Spire.Doc.Fields;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
//创建实例,加载文档
Document doc = new Document();
doc.LoadFromFile("C:\\Users\\Administrator\\Desktop\\合同模板.docx");
//获取第一个批注
Comment comment = doc.Comments[0];
//批注的源
Paragraph para = comment.OwnerParagraph;
//源的位置
CommentMark start = comment.CommentMarkStart;
CommentMark end = comment.CommentMarkEnd;
//获取开始标记和结束标记在段落中的索引
int indexOfStart = para.ChildObjects.IndexOf(start);
int indexOfEnd = para.ChildObjects.IndexOf(end);
//获取标记的书签
BookmarkStart bk = (BookmarkStart)para.ChildObjects[0];
Console.WriteLine("批注源头的书签:"+ bk.Name);
//BookmarkEnd bk1 = (BookmarkEnd)para.ChildObjects[10];
//根据索引获取批注的开始标记和结束标记之间的文字
for (int i = indexOfStart + 1; i < indexOfEnd; i++)
{
TextRange range = (TextRange)para.ChildObjects[i];
Console.WriteLine("批注的文字:"+range.Text);
}
//标记的内容
Console.WriteLine("批注的内容:" + comment.Body.Paragraphs[0].Text);
Console.WriteLine("批注的整段文字:");
//源头的文本
foreach (Paragraph p in comment.OwnerParagraph.OwnerTextBody.Paragraphs)
{
Console.WriteLine(p.Text);
}
}
}
}