当前位置: 首页>>代码示例>>C#>>正文


C# Workbook.ExportAsFixedFormat方法代码示例

本文整理汇总了C#中Workbook.ExportAsFixedFormat方法的典型用法代码示例。如果您正苦于以下问题:C# Workbook.ExportAsFixedFormat方法的具体用法?C# Workbook.ExportAsFixedFormat怎么用?C# Workbook.ExportAsFixedFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Workbook的用法示例。


在下文中一共展示了Workbook.ExportAsFixedFormat方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ConverteerBestand

        /// <summary>
        /// Methode die het excel sheet opslaat als PDF bestand.
        /// </summary>
        /// <param name="excelBestand">Excel bestand om te zetten</param>
        public void ConverteerBestand(FileInfo excelBestand)
        {
            try
            {
                string bestandsnaam = excelBestand.Name;
                string bestandsPad = excelBestand.FullName;
                string doelPad = String.Format("{0}.pdf", bestandsPad.Substring(0, bestandsPad.LastIndexOf('.')));

                // Het excel bestand openen
                excelWorkBook = excel.Workbooks.Open(bestandsPad,
                    paramMissing, paramMissing, paramMissing, paramMissing,
                    paramMissing, paramMissing, paramMissing, paramMissing,
                    paramMissing, paramMissing, paramMissing, paramMissing,
                    paramMissing, paramMissing);

                // Opslaan als PDF-bestand
                if (excelWorkBook != null)
                {
                    excelWorkBook.ExportAsFixedFormat(paramExportFormat,
                        doelPad, paramExportQuality,
                        true, true, Type.Missing,
                        Type.Missing, false,
                        paramMissing);
                    //Het ophalen van de gewichten en bandenspanning
                    if (bestandsnaam.Equals("TestBandingspanningGewichten.xlsx"))
                    {
                        string currentSheet = "Sheet1";
                        Excel.Sheets excelSheets = excelWorkBook.Worksheets;
                        Excel.Worksheet xlws = (Excel.Worksheet)excelSheets.get_Item(currentSheet);
                        lijstGewichten = new List<string>();
                        lijstGewichten.Add(((Excel.Range)xlws.Cells[12, 4]).Value2.ToString());
                        lijstGewichten.Add(((Excel.Range)xlws.Cells[13, 4]).Value.ToString());
                        lijstGewichten.Add(((Excel.Range)xlws.Cells[15, 4]).Value.ToString());
                        lijstGewichten.Add(((Excel.Range)xlws.Cells[16, 4]).Value.ToString());
                        lijstGewichten.Add(((Excel.Range)xlws.Cells[17, 4]).Value.ToString());

                        lijstGewichten.Add(((Excel.Range)xlws.Cells[3, 4]).Value.ToString());
                        lijstGewichten.Add(((Excel.Range)xlws.Cells[4, 4]).Value.ToString());
                        lijstGewichten.Add(((Excel.Range)xlws.Cells[6, 4]).Value.ToString());
                        lijstGewichten.Add(((Excel.Range)xlws.Cells[7, 4]).Value.ToString());
                    }

                    excelWorkBook.Close(false, paramMissing, paramMissing);
                    excelWorkBook = null;
                }
            }
            catch (Exception)
            {
                Logging.log.WriteLine(applicatieNaam, String.Format("{0} kon niet geconverteerd worden", excelBestand.Name));
            }
        }
开发者ID:EusebiusVD,项目名称:Stage,代码行数:55,代码来源:ExcelNaarPDF.cs

示例2: GeneratePdf

        private static bool GeneratePdf(string xlFilePath, XlPaperSize paperSize, Workbook wkb, out string path)
        {
            foreach (Worksheet ws in wkb.Worksheets.OfType<Worksheet>())
            {
                ws.PageSetup.Orientation = XlPageOrientation.xlLandscape;
                if (!paperSize.Equals(null))
                {
                    ws.PageSetup.PaperSize = paperSize;
                }

                ws.PageSetup.Zoom = false;
                ws.PageSetup.FitToPagesWide = 1;
                ws.PageSetup.FitToPagesTall = false;

            }

            string pdfFilePthe = xlFilePath.Contains(".xls")
                ? xlFilePath.Replace(".xls", ".pdf")
                : xlFilePath.Replace(".xlsx", ".pdf");
            string physicalPDfPath = System.Web.HttpContext.Current.Server.MapPath(pdfFilePthe);
            wkb.ExportAsFixedFormat(XlFixedFormatType.xlTypePDF, physicalPDfPath);

            path = pdfFilePthe;
            return true;
            return false;
        }
开发者ID:mehedicse,项目名称:formiginationNET,代码行数:26,代码来源:AzExportExcelToPdf.cs


注:本文中的Workbook.ExportAsFixedFormat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。