Exemplo n.º 1
0
 public void SaveAsPDF(MSExcel._Workbook _excelDoc, string targetPath, string tempPath, out bool success)
 {
     object missing = Type.Missing;
     try
     {
         string temp = Util.PathExt.PathChangeDirectory(targetPath, tempPath);
         _excelDoc.ExportAsFixedFormat(MSExcel.XlFixedFormatType.xlTypePDF, temp, MSExcel.XlFixedFormatQuality.xlQualityStandard, true, false, missing, missing, false, missing);
         success = PDFEncrypt(temp, targetPath, true);
     }
     catch (Exception ex)
     {
         Log.LogHelper.AddException(ex.Message, true);
         success = false;
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// WorkbookをPDFファイルとして別名保存
 /// </summary>
 /// <param name="book">Workbook</param>
 /// <param name="oPath">保存先のファイルパス</param>
 public void SaveAsPdfAs(Excel.Workbook book, string oPath)
 {
     // http://msdn.microsoft.com/ja-jp/library/microsoft.office.tools.word.document.exportasfixedformat.aspx
     // http://msdn.microsoft.com/en-us/library/bb412305.aspx
     try {
         book.ExportAsFixedFormat(
             Type: Excel.XlFixedFormatType.xlTypePDF,
             Filename: oPath,
             Quality: Excel.XlFixedFormatQuality.xlQualityMinimum,
             IncludeDocProperties: true,
             IgnorePrintAreas: false,
             OpenAfterPublish: false);
     } catch (Exception e) {
         System.Diagnostics.Debug.WriteLine(e.Message);
         throw e;
     }
 }