update 20241214
This commit is contained in:
@@ -10,6 +10,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Syncfusion.DocIO;
|
||||
using Syncfusion.DocIO.DLS;
|
||||
|
||||
using Syncfusion.Pdf;
|
||||
using Syncfusion.XlsIO;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
@@ -25,6 +26,7 @@ using System.Data;
|
||||
using Helper;
|
||||
using Syncfusion.XlsIO.Parser.Biff_Records;
|
||||
using System.Buffers.Text;
|
||||
using Syncfusion.ExcelToPdfConverter;
|
||||
|
||||
|
||||
namespace DOCGEN
|
||||
@@ -444,6 +446,35 @@ namespace DOCGEN
|
||||
|
||||
public string Convert_Excel_To_PDF(string document)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (ExcelEngine excelEngine = new ExcelEngine())
|
||||
{
|
||||
IApplication application = excelEngine.Excel;
|
||||
application.DefaultVersion = ExcelVersion.Xlsx;
|
||||
var streamexcel = new MemoryStream(Convert.FromBase64String(document));
|
||||
IWorkbook workbook = application.Workbooks.Open(streamexcel);
|
||||
|
||||
//Initialize ExcelToPdfConverter
|
||||
ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook);
|
||||
|
||||
|
||||
//Initialize PDF document
|
||||
PdfDocument pdfDocument = new PdfDocument();
|
||||
|
||||
//Convert Excel document into PDF document
|
||||
pdfDocument = converter.Convert();
|
||||
|
||||
//Save the converted PDF document
|
||||
|
||||
MemoryStream outputStream = new MemoryStream();
|
||||
pdfDocument.Save(outputStream);
|
||||
byte[] bytes;
|
||||
bytes = outputStream.ToArray();
|
||||
return Convert.ToBase64String(bytes);
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user