Free Support Forum - aspose.com

Evaluating Excel to PDF

Hi, I’m evaluating Aspose.Excel and Aspose.PDF together. My problem is that a key feature I need is Excel->PDF Export. However, there’s no way I can evaluate this using the the evaluation version: even the intermediate XML generated by FileFormatType.AsposePdf does not contain the Excel data, it contains some copyright text instead.

I need to put some large text blocks in my spreadsheet and since (judging by forum posts) a lot of people have had trouble with the merged cell/row auto fit feature, I want to verify that things work before I choose Aspose for my project.

Is there a way to get a time-limited licence for the actual product so that I can do this?

Thanks

How do you test the xls2pdf feature? The following is the sample code:

Excel excel = new Excel();
excel.Open("c:\\book1.xls");
excel.Save("c:\\book1.xml", FileFormatType.AsposePdf);

Pdf pdf = new Pdf();
pdf.BindXML("c:\\book1.xml", null);
pdf.Save("c:\\book1.pdf");

You may find some random text. It's license marks. Please check http://www.aspose.com/Wiki/default.aspx/Aspose.Excel/GarbageTextInWorksheet.html.

This is what I was using:



Excel excel = new Excel();
excel.Open(@"C:\Designer.xls");



// ... processing ...
// removing this line solves the problem
excel.Save(@"C:\__ExcelDemo.xls", FileFormatType.Default);


excel.Save(@"C:\__ExcelDemo.xml", FileFormatType.AsposePdf);
Aspose.Pdf.Pdf pdf = new Aspose.Pdf.Pdf(); 
pdf.BindXML(@"C:\__ExcelDemo.xml", null);
pdf.Save(@"C:\__ExcelDemo.pdf");



This produced the XML file I've attached below, which as you can see does not contain any information from the Excel sheet, only a copyright notice. Seems like a minor bug to me.

I've removed the line now and things work fine

Thanks

D’oh - the attachment’s vanishes if you post from the preview screen. Retrying…

After you call Excel.Save method, the Excel object is re-initilized. If you want to save a file as an Excel file and a pdf file, please try:



Excel excel = new Excel();
excel.Open(@"C:\Designer.xls");



// ... processing ...

Excel excel2= new Excel();
excel2.Copy(excel);












excel2.Save(@"C:\__ExcelDemo.xls", FileFormatType.Default);



excel.Save(@"C:\__ExcelDemo.xml", FileFormatType.AsposePdf);
Aspose.Pdf.Pdf pdf = new Aspose.Pdf.Pdf(); 
pdf.BindXML(@"C:\__ExcelDemo.xml", null);
pdf.Save(@"C:\__ExcelDemo.pdf");

hi,

does it work in cells 4.0.0.0 and pdf 3.1.4.0?

On pdf.Save( @"c:\mypdf.pdf" ); i allways get "Index was outside the bounds of the array.". This exception is thrown for both for xls and doc conversion to pdf.

thanx

Workbook xls = new Workbook();
xls.Open( xlsfile );
xls.Save(xmlfile, FileFormatType.AsposePdf);

Pdf pdf = new Pdf();
pdf.BindXML(xmlfile, null);
pdf.Save( pdffile );

Could you please post your xls file here?

hi.

here is attachment. I get this "out of bounds" exc even if I open blank xls file :(. If I try to open book1.xls (see previeous post), in the line xls.Open( xlsfile ); i get exc:

A first chance exception of type 'System.ArgumentException' occurred in system.drawing.dll Additional information: Cannot find font '??'.

I have downloaded dll's (no installation package) from your download site. Do I need any aditional configuration?

.Net version 1.1; Excel 2003 sp1. Both files can be opened in excel sucessfully.

Any ideas?

I don’t find the problem. Please try this attached version and check the output pdf file.

Hi aspose team.

I have discovered the problem and I want to tell you where the problem was.

I work with visual studio with option “break into the debugger” for “Common Language Runtime Exceptions” set to TRUE (see Debug->Exceptions in menu). I am always stopped when exception is thrown inside Aspose library. That is why I thought that there is something wrong (maybe there is something wrong?). If I set the option to FALSE, I am not stopped anymore and pdf file is created successfully. I am not sure if it is correct to throw and ignore internal exceptions what stops my source execution every time I try to convert xls to pdf. It happens multiple times for single document :(

Best regards,

rimas

Do these exceptions happen within Aspose.Cells or Aspose.Pdf?

In Aspose.Cells exc happen when I open blank XLS (see previous post). In Aspose.Pdf it always happens.

i5riza:

In Aspose.Cells exc happen when I open blank XLS (see previous post).

sorry, in book1.xls, not in the blank xls.

I tried with your test.xls and don’t find exception. Please try my fix in the output.zip.

I have latest cell from output.zip; Have you tried to set "break into the debugger" for CRL Exceptions (see previous posts)?

P.S. As I told, I have got PDF created, but my code execution stops on every conversion because of “stop on exc” setting.

This is a konwn issue in Aspose.Pdf. I have planed to remove the internal exceptions but I don’t think we can finish this task in short time. As a workaround please turn off the “stop on exc” setting.

I use the same option as yours and only get internal exception in Aspose.Pdf, not in Aspose.Cells.

Your support is great!

> I have planed to remove the internal exceptions

Good, I believe you will get performance benefit also

> I use the same option as yours and only get internal exception in Aspose.Pdf, not in Aspose.Cells.

I have tried with 3 different XLS, all of them were exported to XML successfully. The only failed (internal exc) export was book1.xls from this forum.[on method .Save(..)].

xls.Save(xmlfile, FileFormatType.AsposePdf);

I have another question related to Excel to PDF in web environment. Can I spool out PDF directly to httpResponse instead of writing to a XML file first? since it involve security on server and housekeeping task to remove that file. Thanks a lot. Smile [:)]

XML file is a must. But you don’t need to write the XML file to disk. You can write it to a MemoryStream.