public static void saveSlides(Microsoft.Office.Interop.PowerPoint.Presentation presentation) { string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); //string path = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); string filePath = desktopPath + "\\Slides.pptx"; // Microsoft.Office.Interop.PowerPoint.FileConverter fc = new Microsoft.Office.Interop.PowerPoint.FileConverter(); // if (fc.CanSave) { } //https://msdn.microsoft.com/en-us/library/system.windows.forms.savefiledialog(v=vs.110).aspx //Browse Files Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog(); dlg.InitialDirectory = desktopPath+"\\Scano"; dlg.DefaultExt = ".pptx"; dlg.Filter = "PPTX Files (*.pptx)|*.pptx"; Nullable<bool> result = dlg.ShowDialog(); // Get the selected file name and display in a TextBox if (result == true) { // Open document filePath = dlg.FileName; //textBox1.Text = filename; } else { System.Console.WriteLine("Couldn't show the dialog."); } presentation.SaveAs(filePath, Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsOpenXMLPresentation, Microsoft.Office.Core.MsoTriState.msoTriStateMixed); System.Console.WriteLine("PowerPoint application saved in {0}.", filePath); }
/// <summary> /// 另存为html文件 /// </summary> /// <param name="CurBook">Workbook</param> /// <param name="strFilePath">文件路径</param> public void SaveHtml(Microsoft.Office.Interop.Excel._Workbook CurBook, string strFilePath) { CurBook.SaveAs(strFilePath, Microsoft.Office.Interop.Excel.XlFileFormat.xlHtml, mValue, mValue, mValue, mValue, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange, mValue, mValue, mValue, mValue, mValue); }
private bool ProcessMailSynchronously(bool bSendAndProtect, Microsoft.Office.Interop.Outlook.MailItem mailItem) { if (_lcfm == null) _lcfm = new LocalCopyOfFileManager(true); mailItem.SaveAs(_lcfm.GetLocalCopyOfFileTarget(Guid.NewGuid().ToString())); Logger.LogInfo("[WORKSHARE PROTECT ASYNCH-MODE] - Processing mail synchronously."); OutlookHookWorker outlookHookWorker = new OutlookHookWorker(); outlookHookWorker.SendAndProtect = bSendAndProtect; outlookHookWorker.ProtectSimple = this.UsingProtectSimple; outlookHookWorker.IsDeterministicSendEnabled = IsDeterministicSendEnabled(); outlookHookWorker.IsOutlookSecurityDisabled = DisableOutlookSecurity(); bool result = outlookHookWorker.NotifyOfItemSend(mailItem); m_bIsProtectDisabledForCurrentRouting = outlookHookWorker.IsProtectDisabledForCurrentRouting; m_bIsSendLink = outlookHookWorker.IsSendLink; m_bFormattedMsgText = outlookHookWorker.FormattedMsgText; CleanUpForInterwovenEMM(); if (outlookHookWorker.IsOutlookSecurityDisabled) { EnableOutlookSecurity(); } return result; }
/// <summary> /// 保存文件 /// </summary> /// <param name="CurBook">Workbook</param> /// <param name="strFilePath">文件路径</param> public void SaveAs(Microsoft.Office.Interop.Excel._Workbook CurBook, string strFilePath) { CurBook.SaveAs(strFilePath, mValue, mValue, mValue, mValue, mValue, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlShared, mValue, mValue, mValue, mValue, mValue); }
void CloseWorkBook(Microsoft.Office.Interop.Excel.Workbook ExcelWb, String TargetDirectory, String SaveName) { String ExcelFileName = Path.Combine(TargetDirectory, SaveName); if (File.Exists(ExcelFileName)) File.Delete(ExcelFileName); ExcelWb.SaveAs(ExcelFileName, Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookDefault, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value); ExcelWb.Close(Missing.Value, Missing.Value, Missing.Value); ExcelApplication.Quit(); ExcelWb = null; ExcelApplication = null; }
public static void saveSlidesInBackground(Microsoft.Office.Interop.PowerPoint.Presentation presentation, String fileName) { String filePath = folderPath+fileName+".pptx"; presentation.SaveAs(filePath, Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsOpenXMLPresentation, Microsoft.Office.Core.MsoTriState.msoTriStateMixed); System.Console.WriteLine("PowerPoint application saved in {0}.", filePath); }
private void exportToExcel_Saving(object sender, Microsoft.Office.Interop.Excel.Workbook e) { LotCardExport exportToExcel = sender as LotCardExport; //待保存工作簿的文件名 string fileName = exportToExcel.SaveFileName; //实际文件物理路径 string sNewFullFile = HttpContext.Current.Server.MapPath(exportToExcel.SaveFileName); //删除该目录下所有excel文件 foreach (var itm in ( new FileInfo(sNewFullFile)).Directory.GetFiles("*.xls", SearchOption.TopDirectoryOnly) ) { itm.Delete(); } //检测指定文件是否存在 if (File.Exists(sNewFullFile)) { //新文件名 exportToExcel.SaveFileName = exportToExcel.SaveFileName.Replace(".xls", Guid.NewGuid().ToString() + ".xls"); //新物理文件名 sNewFullFile = HttpContext.Current.Server.MapPath(exportToExcel.SaveFileName); } //保存到临时文件 e.SaveAs(sNewFullFile); //虚拟路径 string urlPath = HttpContext.Current.Request.FilePath; int index = urlPath.LastIndexOf('/'); if (index >= 0) { //获取除文件名件外的虚拟路径 urlPath = urlPath.Substring(0, index+1); } //文件保存位置的虚拟路径和名称 exportToExcel.SaveFileName = urlPath + exportToExcel.SaveFileName; }
private void SaveDocument(Microsoft.Office.Interop.Word.Document wordDocument, Microsoft.Office.Interop.Word.ApplicationClass wordApp, string filePath) { object Visible = false; object missing = System.Reflection.Missing.Value; Object Nothing = System.Reflection.Missing.Value; object Save_FileName = filePath; //保存模板文件 wordDocument.SaveAs(ref Save_FileName, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref Visible, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing); //关闭wordDoc文档对象 wordDocument.Close(ref Nothing, ref Nothing, ref Nothing); wordDocument = null; //关闭wordApp组件对象 wordApp.Quit(ref Nothing, ref Nothing, ref Nothing); }