C# 、VB 将Excel转为PDFA/1B
以下经验内容分享通过C#及VB程序将Excel转为PDF A/1B。
工具/原料
Spire.XLS for .NET hotfix 10.10.6
工具包下载及dll添加引用:
1、可通过E-iceblue中文官网下载10.10.6版本的hotfix,下载后,解压到指定路径,完成解压后,将文件夹Bin下的Spire.Xls.dll和Spire.Pdf.dll文件添加引用到VS程序(如下图):
C# 代码示例
1、using Spire.Xls;namespace ExceltoPDFA1B{ class Pr泠贾高框ogram { static void Main(string[] args) { //加载Excel测试文档 Workbook wb = new Workbook(); wb.LoadFromFile("sample.xlsx", ExcelVersion.Version2013); //将Excel保存为Pdf_A1B格式 wb.ConverterSetting.PdfConformanceLevel = Spire.Pdf.PdfConformanceLevel.Pdf_A1B; wb.SaveToFile("result.pdf", Spire.Xls.FileFormat.PDF); System.Diagnostics.Process.Start("result.pdf"); } }}
2、文档转换结果:
VB.NET代码
1、Imports Spire.XlsNamespace ExceltoPDFA1B Class Program Private Shared Sub Main(ar爿讥旌护gs As String()) '加载Excel测试文档 Dim wb As New Workbook() wb.LoadFromFile("sample.xlsx", ExcelVersion.Version2013) '将Excel保存为Pdf_A1B格式 wb.ConverterSetting.PdfConformanceLevel = Spire.Pdf.PdfConformanceLevel.Pdf_A1B wb.SaveToFile("result.pdf", Spire.Xls.FileFormat.PDF) System.Diagnostics.Process.Start("result.pdf") End Sub End ClassEnd Namespace