/// <summary> /// Disconnect Data Source from Mail Merge and fill merge field with current query fro doc and also data source from doc /// </summary> /// <param name="sourceDoc"></param> /// <param name="targetDoc"></param> /// <returns></returns> public DocPropertiey FillData(ISourceDoc sourceDoc, ITargetDoc targetDoc, string connectionString = null) { var dataAfterModified = sourceDoc.GetBuffer(); var dataAfterChange = FillDataToDocCP(dataAfterModified, true, connectionString); DocPropertiey targetPath = targetDoc.Save(dataAfterChange); return(targetPath); }
/// <summary> /// 1. Change Data SOurce /// 2. Change SQL Query /// 3. Replace path of macro dotm template /// 4. Add custom property for server name and port which connect from macro client side to server api side /// </summary> public DocPropertiey Merge(string connStr, string query, ISourceDoc sourceDoc, ITargetDoc targetDoc, string udlPath, string macroTemplatePath = "", Dictionary <string, string> customProperties = null) { var buffer = sourceDoc.GetBuffer(); var dataAfterModified = Modified(connStr, buffer, query, udlPath, macroTemplatePath, customProperties); DocPropertiey targetPath = targetDoc.Save(dataAfterModified); return(targetPath); }
/// <summary> /// Convert Docm To Docx (By package because ChangeDocumentType not working well) /// </summary> /// <param name="sourceDoc"></param> /// <param name="targetDoc"></param> public void ChangeDocmToDocx(ISourceDoc sourceDoc, ITargetDoc targetDoc) { var buffer = sourceDoc.GetBuffer(); using (MemoryStream ms = new MemoryStream()) { ms.Write(buffer, 0, buffer.Length); ChangeDocmToDocxUsingPackage(ms); RemoveMacroOpenXml(ms); DocPropertiey targetPath = targetDoc.Save(ms.ToArray()); } }
public DocPropertiey FillDataAndConvertDocx(ISourceDoc sourceDoc, ITargetDoc targetDoc, string connectionString = null) { var dataAfterModified = sourceDoc.GetBuffer(); var dataAfterChange = FillDataToDocCP(dataAfterModified, true, connectionString); using (MemoryStream ms = new MemoryStream()) { ms.Write(dataAfterChange, 0, dataAfterChange.Length); ChangeDocmToDocxUsingPackage(ms); RemoveMacroOpenXml(ms); DocPropertiey targetPath = targetDoc.Save(ms.ToArray()); return(targetPath); } }