本文整理汇总了C#中Worksheet.ExportAsFixedFormat方法的典型用法代码示例。如果您正苦于以下问题:C# Worksheet.ExportAsFixedFormat方法的具体用法?C# Worksheet.ExportAsFixedFormat怎么用?C# Worksheet.ExportAsFixedFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Worksheet
的用法示例。
在下文中一共展示了Worksheet.ExportAsFixedFormat方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveBillAsPDF
public void SaveBillAsPDF(Worksheet worksheet)
{
string directory = string.Format("{0}\\{1}", billsDirectory, clientName);
string fullName = string.Format("{0}\\{1}{2}", directory, billName, ".pdf");
fileManager.CreateDirectoryIfDoesNotExist(directory);
fileManager.CreateFileIfDoesNotExist(fullName);
worksheet.ExportAsFixedFormat(XlFixedFormatType.xlTypePDF, fullName);
}
示例2: Main
//.........这里部分代码省略.........
//string newfilePath = filePaths[i].DocumentPath.Replace("D:\\", "E:\\");
string newfilePath = filePaths[i].DocumentPath.Replace("D:\\", "\\\\192.168.190.161\\");
// newfilePath = newfilePath.Replace("\\\\", "\\");
theFileName = GetFileName(newfilePath);
LogWithoutPath("file path: D: " + theFileName);
LogWithoutPath("end get file name");
LogWithoutPath("start open work book");
//wkb = app.Workbooks.Open(copyExcellTo + theFileName + ".xls");
try
{
//wkb = app.Workbooks.Open(filePaths[i].DocumentPath);
wkb = app.Workbooks.Open(newfilePath);
LogWithoutPath("end open work book");
//Workbook wkb = app.Workbooks.Open("C:\\temp3\\2004107065.xls");
//\\hmdn-srseds\SRSServer\Storage\16\1627369463\2004108635
//Workbook wkb = app.Workbooks.Open(filePaths[i].DocumentPath);
LogWithoutPath("start get work sheet");
sheet = (Worksheet)wkb.Worksheets[1];
LogWithoutPath("end get work sheet");
//sheet.PageSetup.FitToPagesWide = 1;
sheet.Select(Type.Missing);
//wkb.set.ActiveSheet = sheet;
LogWithoutPath("start save to pdf");
}
catch (Exception er)
{
string s1 = er.ToString();
}
try
{
sheet.ExportAsFixedFormat(XlFixedFormatType.xlTypePDF, savePDFTo + theFileName + ".pdf", XlFixedFormatQuality.xlQualityStandard, false, false, 1, 1, true);
}
catch
{ }
LogWithoutPath("end save to pdf");
Console.WriteLine("finished with number: " + i.ToString());
LogWithoutPath("start close resources");
try
{
wkb.Close(false);
app.Application.Quit();
app.Quit();
}
catch { }
try
{
Marshal.ReleaseComObject(sheet);
Marshal.ReleaseComObject(wkb);
Marshal.ReleaseComObject(app);
Marshal.ReleaseComObject(wkb);
Marshal.ReleaseComObject(app);
}
catch { }
try
{
Process[] excelProcess = Process.GetProcessesByName("Excel");
excelProcess[0].Kill();
}
示例3: Excel2pdfProc
protected virtual int Excel2pdfProc(Worksheet sheet, int idx, int file_c)
{
if (this.Fails.Count > 0)
{
return 0;
}
var pdf = Path.GetTempFileName() + ".pdf";
try
{
if (this.ShowLog)
{
L.D("excel2pdf parsing file({0},{1}) to {1}", this.AsSrc, idx, pdf);
}
sheet.ExportAsFixedFormat(XlFixedFormatType.xlTypePDF, pdf);
var images = new MagickImageCollection();
this.Images.Add(images);
var added = this.Pdf2imgProc(images, pdf, idx, file_c);
return added;
}
catch (Exception e)
{
this.Result.Code = 500;
this.Fails.Add(e);
return 0;
}
finally
{
try
{
File.Delete(pdf);
}
catch (Exception)
{
}
}
}