Nex*_*xas 5 c# excel openxml threaded-comments office365
我正在运行最新的Office 365 Excel版本1901。我已经更新到最新的OpenXml SDK,但是由于我看到的是完整的摘要注释,因此无法弄清楚如何以编程方式读取有关线程注释的信息。即使使用最新的OpenXml Nuget软件包。
如果将Excel文档转换为.zip文件,则可以看到具有所需内容的“ threadedComments.xml”文件,但不知道如何在C#.NET中以编程方式进行处理。
Art*_*fin -1
如果您知道 .zip 存档中的确切位置,您可以通过编程方式访问内容:
static class Program
{
static void Main(string[] args)
{
using (var archive = ZipFile.OpenRead(args[0]))
{
var entry = archive.Entries.Where(_ => _.FullName.Equals("xl/comments1.xml", StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
if (entry != null)
{
var stopwatch = new Stopwatch();
stopwatch.Start();
var data = new List<string>(Decompress(entry.Open()));
var graph = new Graph(data);
stopwatch.Watch();
Console.ReadLine();
}
}
}
public static IEnumerable<string> Decompress(Stream stream)
{
using (var reader = new StreamReader(stream, Encoding.ASCII))
{
string line;
while ((line = reader.ReadLine()) != null)
{
yield return line;
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
256 次 |
| 最近记录: |