private bool ReadCustomXmlPart(Microsoft.Office.Core.CustomXMLPart xmlPart) { if (xmlPart != null) { string content = xmlPart.XML; if (content.Contains(MarkupInternal)) { _internalBm = content; return(true); } else { return(ProcessXmlObject(content)); } } return(false); }
private Microsoft.Office.Core.CustomXMLPart GetCustomXLPart(WorkbookModel workbook, string id) { Microsoft.Office.Core.CustomXMLPart resultPart = null; foreach (Microsoft.Office.Core.CustomXMLPart part in workbook.Workbook.CustomXMLParts) { try { var xml = XElement.Parse(part.XML); if (xml.Name == XName.Get(id)) { resultPart = part; break; } } catch (Exception e) { Console.WriteLine(e.Message); } } return(resultPart); }
private void RemovePdwFormat(string docxFilePath, ref Exception ex) { object missing = System.Type.Missing; Application wApp = new Application(); try { wApp.Visible = false; wApp.Documents.Open(_filePath); Services.WordHeper.RemoveProtectPassword(wApp.ActiveDocument, ProntoDoc.Framework.CoreObject.PdwxObjects.ProtectLevel.All); List <string> partIds = new List <string>(); foreach (Microsoft.Office.Core.CustomXMLPart xmlPart in wApp.ActiveDocument.CustomXMLParts) { if (!xmlPart.BuiltIn) { partIds.Add(xmlPart.Id); } } foreach (string partId in partIds) { Microsoft.Office.Core.CustomXMLPart xmlPart = wApp.ActiveDocument.CustomXMLParts.SelectByID(partId); if (xmlPart != null) { xmlPart.Delete(); } } wApp.ActiveDocument.SaveAs(docxFilePath); } catch (Exception exception) { ex = exception; } finally { ((_Application)wApp).Quit(missing, missing, missing); System.Runtime.InteropServices.Marshal.ReleaseComObject(wApp); } }