Free Support Forum - aspose.com

Converting spreadsheet from the Gridweb to a PDF

Visual Studio 2005, C#, ASP.net 2.0, Aspose.Cells 4.8.0.16

My goal:Generate a PDF (with images) from an excel spreadsheet edited on the web.

The issue: I'm unable to translate what I see in the web grid to the PDF.

Here's the scenario. The user enters in data via Gridweb (including formulas) and wants to save the resulting spreadsheet to a PDF file. They have images that they want to insert as well. GridWeb does neither of these, but Aspose.Cells does. So I save as an Excel file and open with Aspose.Cells like this:

Workbook book = new Workbook();

DataSet DS = new DataSet();

clsTemplate oTemplate = new clsTemplate();

grdExcel.WebWorksheets.SaveToExcelFile("c:/example.xls");

book.Open("c:/example.xls");

Sure enough, I can insert my images and save as a PDF:

book.Worksheets[0].Pictures.Add(0, 0, Server.MapPath("App_Data/EImages/") + "U" + Session["PersonID"].ToString().Trim() + ".jpg");

book.Save("Preview.pdf", Aspose.Cells.FileFormatType.Pdf, SaveType.OpenInExcel, System.Web.HttpContext.Current.Response);

But there's a problem. My calculations aren't showing up in the PDF. I do a little research and figure out that the formulas (not the results) are what saved to the excel file so I need to fire the calculation engine. Okay, easy enough:

book.CalculateFormula();

Problem solved? Not quite. It turns out that the supported formulas are not the same between Gridweb and Aspose.cells. Most notably I'm missing the LOG function (though I have LOG10 for some reason). I get an error stating I have an "Unsuported Formula" and the remaining calculations do not execute.

so.. Short of manually (looping) copying the calcuated values from the Gridweb Excel spreadsheet to the Aspose.Cells spreadsheet. Is there a better solution to this?

Hi,

Well, I think your steps are fine. For your information Aspose.Cells component has big supported formulas list, see the topic: http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/supported-formulas-functions.html
and Aspose.Cells.GridWeb control has different supported list of formulas, see the topic: http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/list-of-supported-functions.html

Could you tell which functions/formulas are not in the list for Aspose.Cells or Aspose.Cells.GridWeb control for your requirement and we will check and try to support them for you.

And, I think one of the unsupported function/formula is LOG for Aspose.Cells, is not it?



Thank you.