using Aspose.Cells;
using Bowin.Common.Utility;
using System;
using System.Collections.Generic;
using System.IO;
using System.Security.Cryptography;
using System.Text;
namespace Bowin.Common.Office
{
public static class ExcelToPDF
{
public static MemoryStream Export(Stream excelStream)
{
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
Workbook wb = new Workbook(excelStream, new LoadOptions(LoadFormat.Auto));
var pdfStream = new MemoryStream();
wb.Save(pdfStream, new PdfSaveOptions(SaveFormat.Pdf) {
});
return pdfStream;
}
///
///
///
///
/// 相对路径
///
public static string ExportToFile(MemoryStream excelStream, string filePath)
{
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
var pdfFileName = Guid.NewGuid().ToString() + ".pdf";
var fullPath = filePath + (!filePath.EndsWith("/") ? "/" : "") + pdfFileName;
var physicalFullPath = HttpHelper.MapPath(fullPath);
Workbook wb = new Workbook(excelStream, new LoadOptions(LoadFormat.Auto));
wb.Save(physicalFullPath, SaveFormat.Pdf);
return fullPath;
}
}
}