Word插件开发

复制docx到剪贴板并获取html数据

                    if (Clipboard.ContainsText(TextDataFormat.Html))
                    {
                        strHtml = Clipboard.GetDataObject().ToString();
                        /*String returnHtmlText = null;
                        MemoryStream vMemoryStream = Clipboard.GetData(DataFormats.Html) as MemoryStream;
                        vMemoryStream.Position = 0;
                        byte[] vBytes = new byte[vMemoryStream.Length];
                        vMemoryStream.Read(vBytes, 0, (int)vMemoryStream.Length);
                        returnHtmlText = Encoding.UTF8.GetString(vBytes);*/
                        strHtml = strHtml = Clipboard.GetText(TextDataFormat.Html);
                    }

用HAP删除注释

                    //remove comment node
                    var commentNodes = saveDoc.DocumentNode.SelectNodes("//comment()");
                    if (commentNodes != null)
                    {
                        foreach (var comment in commentNodes)
                        {
                            if (comment.InnerText.StartsWith("

你可能感兴趣的:(Word插件开发)