本文整理汇总了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));
}
}
示例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;
}