Excel to pdf does not export chart and pdf has line artifacts

I downloaded Aspose.Cells (evaluation version) earlier tonight under the presumption that it can handle both modifying excel documents as well as converting excel workbooks to pdf’s. I presumed this would include charts and such.

I’m using an Visual Web Developer 2008 Express Edition. I loaded the site located at C:\Program Files\Aspose\Aspose.Cells\Demos\Aspose.Cells.Demos (the default install directory). From here I generated the workbooks titled CostPareto.xls and FinancialPlan.xls.

The CostPareto.pdf that was generated from the corresponding xls file, does not have the chart. An empty page is all that’s there. There are also 2 extra pages at the end of the pdf. Page 4 in the pdf is giberish and page 5 is a copy of the evaluation worksheet that already exists on page 3.

The FinancialPlan.pdf was generated mostly correctly. There is an issue with the Loan Payment Calculator sheet where the page ratio to text seems to have been shrunk. There are also double bolded lines in the first column between items 12 & 13, 23 & 24, 26 & 27, 37 & 38 and others. This was not fixed by adjusting the zoom level to 100 on the pdf viewer. At 100% zoom, the text on this particular page of the pdf seems disproportionally small.

Please see attached files. Note that I am using a trial version of office 2007. It has a lot of functionality crippled; however, I was under the impression excel wasn’t necessary for the Aspose.Cells .Net functionality to work.

Here is the code I am using for the conversion:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Aspose.Cells;

public partial class _Default : System.Web.UI.Page 
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void btnConvert_Click(object sender, EventArgs e)
{
try
{
Workbook workbook = new Workbook();
workbook.Open(@“C:\Dev\ExcelToPdf\Worksheets\CostPareto.xls”);
//workbook.Worksheets[0].Cells[“A1”].PutValue(“Hello World!”);
workbook.Save(“exportpdf” + “.pdf”, SaveType.OpenInExcel, FileFormatType.Pdf, Response);
lblStatus.Text = “SUCCESS”;
//Response.End();
}
catch (Exception ex)
{
lblStatus.Text = ex.Message;
}

}
}

Hi,

Thank you for considering Aspose.

jbaisden:

The CostPareto.pdf that was generated from the corresponding xls file, does not have the chart. An empty page is all that’s there. There are also 2 extra pages at the end of the pdf. Page 4 in the pdf is giberish and page 5 is a copy of the evaluation worksheet that already exists on page 3.

Please try the attached latest version of Aspose.Cells. I have tested your shared template file and it works fine with the latest version of Aspose.Cells. As far as the issue regarding the Extra Evaluation Pages the first evaluation page is in the template excel file and the last evaluation page is added when you converted your template file to PDF using Aspose, I think that issue will not occur in the license version. Please change your code abit as mentioned below,

workbook.Save(“Cost” + “.pdf”, SaveType .OpenInBrowser , FileFormatType.Pdf, Response);

jbaisden:

The FinancialPlan.pdf was generated mostly correctly. There is an issue with the Loan Payment Calculator sheet where the page ratio to text seems to have been shrunk. There are also double bolded lines in the first column between items 12 & 13, 23 & 24, 26 & 27, 37 & 38 and others. This was not fixed by adjusting the zoom level to 100 on the pdf viewer. At 100% zoom, the text on this particular page of the pdf seems disproportionally small.

Well, the shrinking text & double bolded lines are basically due to the zoom only as I checked it by increasing the zoom and they look fine (Please see the attached generated file with the latest version attached)

jbaisden:

Please see attached files. Note that I am using a trial version of office 2007. It has a lot of functionality crippled; however, I was under the impression excel wasn’t necessary for the Aspose.Cells .NET functionality to work.

Yes, you don’t need to have MS Excel installed on your system to use Aspose.Cells.

Thank You & Best Regards,


Thank you for your prompt reply. Your attached version of the Aspose.Cells product fixed the issues mentioned except for the aspect ratio of the text on the FinancialPlan pdf. Beginning on page 5 at 100% zoom, the text doesn’t really use the full realestate of the page. If I print it without modifying the aspect ratio (such as not selecting a “fit to printable area” or “shrink to printable area”) the text is still too small to read without putting the printed page right in front of my eyes.

Is there a way to adjust this? Even if I have to programatically adjust it just for one sheet, that would be fine as the workbook I’m using will be mostly static content with some formulas. As seen on page 5 of the pdf, the 5 columns are printed in the middle of the page with a good 2-3 inches on either side. I really need this expanded to use more of the page and I think that will fix this.

If this can be done programatically for this specfic worksheet, a code example would be great.

Thank you for your time and prompt service. You’ve got a great product and I hope to buy in the near future provided I can get a proof of concept demonstration for my client.

@jbaisden,
Thank you for considering Aspose.

Well, you may try to change the Page Setup options of the “” worksheet to make it more readable in exported PDF. If you see the Page Setup options of the “” worksheet, the scaling is set as “Fit to 1 Page(s) width and 4 Pages Tall” and its preview is also showing the data in the same manner as exported PDF. Now if you change the scaling to as “Fit to 1 Page(s) width and 6 Pages Tall” , I think it will make data more readable in Excel Print out as well as PDF Export.Please see the following sample code to achieve this result,

Sample Code:

//Create a Workbook.

Workbook workbook = new Workbook();

//Open a file into the first book.

workbook.Open(@"C:\FinancialPlan.xls");

Worksheet sheet = workbook.Worksheets["Loan Payment Calculator"];

//Obtaining the reference of the PageSetup of the worksheet

PageSetup pageSetup =sheet.PageSetup;

//Setting the number of pages to which the length of the worksheet will be spanned

pageSetup.FitToPagesTall = 6;

//Setting the number of pages to which the width of the worksheet will be spanned

pageSetup.FitToPagesWide = 1; 

workbook.Save(@"C:\FinancialPlan.pdf", FileFormatType.Pdf);

Also, please see the following documentation link for further information regarding Page Setup options,
Setting Page Options

Also, you can see our online tutorial regarding Page Setup Options at the following link,
Page Setup and Printing Options

Thank You & Best Regards,


Man…your support is just astounding. I’ll give this a try when I get home. I think this will definitely fix the issue.

You rock man. There’s not another word for it.