We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Convert Excel file to PDF via Aspose.Cells APIs


I am using aspose PDF V
I am having trouble converting this xlsx document to PDF.
Herewith i have attached sample xlsx. I am getting error message as “Item has already been added. Key in dictionary: 141 Key being added: 141” while converting to pdf.

Code snippet:
Dim xmlFile As String = inpath & ".xml"
Dim wb As Aspose.Cells.Workbook = New Aspose.Cells.Workbook
wb.Open(inpath, FileFormatType.Excel2007Xlsx, “”)
wb.Save(xmlFile, FileFormatType.AsposePdf)
Dim pdf As Aspose.Pdf.Pdf = New Aspose.Pdf.Pdf
pdf.BindXML(xmlFile, Nothing)


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

I've tested the scenario and I'm able to notice the same problem. In fact the issue is occurring when Aspose.Cells is saving the contents of Excel worksheet into XML format. So, it seems to be an issue over Aspose.Cells end. As per my observation, even if you comment out the code in which Aspose.Pdf is used to convert the XML file into PDF format, you would be able to notice the same issue. Therefore, for the sake of correction, I'm moving this thread to Aspose.Cells forum.

Besides this, one strange thing that I've also noticed is that, when using the Direct-to-PDF save method of Aspose.Cells, the issue is not occurring, but the formatting of the resultant PDF is not correct. I think, Aspose.Cells team would be in better position to answer both the queries.

We apologize for your inconvenience.


Please try our latest version v4.8.2, see the download link: http://www.aspose.com/community/files/51/.net-components/aspose.cells-for-.net/entry215207.aspx
Please try our Direct conversion method for converting Excel spreadsheets to pdf files, see the document for reference: Convert Excel Workbook to PDF

I have tested it and if you want to save each worksheet should be rendered in pdf format with a single page, you may try: PdfOptions.OnePagePerSheet to set it to True.

Sample code:

Dim wb As Aspose.Cells.Workbook = New Aspose.Cells.Workbook
wb.Open(inpath, FileFormatType.Excel2007Xlsx, “”)
PdfOptions.OnePagePerSheet = True
wb.Save(outpath, FileFormatType.Pdf)

Note: there might be some other issues too, e.g not all the shapes and objects in xlsx files are supported. We are already working on the features.

Moreover, I have tested to convert your file to pdf with old indirect conversion method (as you are doing) using Aspose.Cells for .NET and Aspose.Pdf for .NET and I can find the issue as you have mentioned. But we do appreciate if you could try our direct conversion method because it is more stable, reliable and efficient.
If you still persists with old way of conversion, let us know and we can look into it soon.

Thank you.