Free Support Forum -

XLS to PDF conversion difference by using Aspose.Cells for .NET in C#

Again, the subject line says it all. I can save as xls just fine, but saving as pdf throws an exception:

Aspose.Cells.CellsException was unhandled
Message=“Unsupported sfnt version.”
at Aspose.Cells.PdfFD.xd285aa8659b8b74e.x0acd3c2012ea2ee8(String xafe2f3653ee64ebc)
at Aspose.Cells.Workbook.Save(String fileName, FileFormatType fileFormatType)
at ConsoleApplication1.Module1.Main() in C:\Documents and Settings\User\My Documents\Visual Studio 2008\Projects\ConsoleApplication1\Module1.vb:line 52
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

Here’s the VB console app code to reproduce the problem:

Imports System.IO
Imports Aspose.Cells

Module Module1

Const numOfColumns As Integer = 5
Const numOfRows As Integer = 5
Dim outputDir As String = My.Application.Info.DirectoryPath

Sub Main()

’ set Aspose Cells license
Dim asposeCellsLicense As New Aspose.Cells.License
asposeCellsLicense.SetLicense(New MemoryStream(My.Resources.Aspose_Total_License))

Console.WriteLine(“Getting DataTable…”)
Dim dt As DataTable = GetSampleData()
Console.WriteLine(String.Format(“Done! ({0} columns, {1} rows)”, dt.Columns.Count, dt.Rows.Count))

Dim wb As New Aspose.Cells.Workbook
wb.Worksheets(0).Cells.ImportDataTable(dt, True, “A1”)

Dim fileName As String = Now.Ticks.ToString
Dim fileNamepdf As String = Path.Combine(outputDir, fileName & “.pdf”)
Dim fileNamexls As String = Path.Combine(outputDir, fileName & “.xls”)

Console.WriteLine(“output directory:”)

’ this doesn’t work:
Console.WriteLine(“Saving workbook in pdf format…”)
wb.Save(fileNamepdf, FileFormatType.Pdf)
Dim filepdf As New FileInfo(fileNamepdf)
Dim fileSizepdf As Decimal = filepdf.Length / 1000000
Console.WriteLine(String.Format(“Done! filesize = {0} MB, filename = {1}”, filepdf.Length / 1000000, filepdf.Name))

’ but this does:
'Console.WriteLine(“Saving workbook in xls format…”)
'wb.Save(fileNamexls, FileFormatType.Excel2003)
'Dim filexls As New FileInfo(fileNamexls)
'Dim fileSizexls As Decimal = filexls.Length / 1000000
'Console.WriteLine(String.Format(“Done! filesize = {0} MB, filename = {1}”, filexls.Length / 1000000, filexls.Name))

Console.Write(“Press any key to continue . . .”)

End Sub

Function GetSampleData() As DataTable

Dim dt As New DataTable
For c As Integer = 0 To numOfColumns - 1
dt.Columns.Add(“column” & c)

For rowCount As Integer = 0 To numOfRows - 1
Dim dr As DataRow = dt.Rows.Add
For i As Integer = 0 To numOfColumns - 1

Return dt

End Function

End Module

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for considering Aspose.

After checking your issue, we think that this issue may be caused by using high version truetype fonts. Those fonts may be installed manually after Windows OS setup. Please provide us with further information regarding the truetype fonts you are using. We will check it soon.

Thank You & Best Regards,

What information do you need again? I’ve attached a list of my installed fonts. I’m running Windows XP and I haven’t manually installed any extra fonts… Any extra fonts I have installed were probably automatically installed by either the Microsoft Office 2007 Compatibility Pack SP2 for Office 2003 or the open source PDFCreator ( Is there any more information that I could give you that would be of use? Thanks!

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for considering Aspose.

Please try the attached latest version of Aspose.Cells. We have fixed you mentioned issue. If you still face any problem, please feel free to contact us.

Thank You & Best Regards,

I am also getting the sfnt exception.

I believe it is being caused by the hyperlink. Here is sample code to replicate.

I am attaching sample code to replicate.


Hi Alan,

I have used your code in sample.cs file (from the project you posted) with the latest version/fix but could not reproduce the issue you have mentioned. I don't get sfnt exception.

Could you try the attached version and let us know if it works fine.

Thank you.

It works. Thanks much.


The issues you have found earlier (filed as CELLSNET-8988) have been fixed in this update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.

Note: Just for your knowledge. In the new release v4.8.0, we have merged Aspose.Grid suite to Aspose.Cells for .NET msi installer as Aspose.Grid would be no longer offered as a separate product now. You need to install the installer (uninstall older one first if you have) and use only Aspose.Cells.dll library in your project for your need. You may also take advantage using Aspose.Cells Grid suite though.