[C#] Convert Excel to PDF
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Web; using Spire.Xls; namespace ToPDF { class Program { static void Main(string[] args) { string tempPath = HttpRuntime.AppDomainAppPath.ToString() + "\\Report\\"; Workbook workbook = new Workbook(); workbook.LoadFromFile(tempPath + "Sample.xlsx", ExcelVersion.Version2010); for(int i = 0; i < workbook.Worksheets.Count; i++) { workbook.Worksheets[i].PageSetup.Orientation = PageOrientationType.Landscape; workbook.Worksheets[i].PageSetup.IsFitToPage = true; } workbook.SaveToFile(tempPath + "result.pdf", Spire.Xls.FileFormat.PDF); } } } 參考網址 By Hao★












留言
張貼留言
歡迎留言