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

Free Support Forum - aspose.com

Formula fileds data issue while Convert from Aspose GridWeb excel file to PDF

Hi Team,

Excel Formula field data's are not available in PDF file while convert from Aspose GridWeb saved excel to PDF using the below code.

Used code:Saved excel from aspose GridWeb and convert to pdf directly

string filename = System.IO.Path.GetTempPath() + Session.SessionID + ".xls";

this.ReportGrid.WebWorksheets.SaveToExcelFile(@"c://test.xls");

Workbook wb = new Workbook(@"c://test.xls");

wb.Save((@"c://test.pdf", SaveFormat.Pdf);

But formula fields data's are display in PDF if i manually open and save the converted excel file and convert to PDF using the below code

Used Code:After manulay open and saved excel file

Workbook wb = new Workbook(@"c://test.xls");

wb.Save(pdfFilepath, SaveFormat.Pdf);

Please check and provide us the solution for the above issue.

Thanks and Regards

Saravanan.l

Hi,


Please add a line to your code before saving to PDF:
wb.CalculateFormula();

Thank you.

Hi Team,

Thanks for the solution.Now all formula filed data's are displayed properly in PDF Properly.

Can you please provide the same code for the below

1.How to copy the 4 sheets data's from one workbook to another workbook including formula fileds data.Our requirements is excel file contains 15 sheets and all sheets having formula filed data's.we need to copy only 4 sheets data to another workbook instead of copy the 15 sheets.4 sheets sholud contains only the data's including formula fileds data's not formula's.

Used code:

this.ReportGrid.WebWorksheets.SaveToExcelFile(filename);

Workbook wb = new Workbook(filename);

2.How to save the 4 sheets data's from Aspose GridWeb to excel including formula fileds data's not formula's.Asspose GridWeb contains 15 sheets and all sheets contains formula field data's.We need save only 4 sheets data's to excel not formula's instead of save the 15 sheets.

Used code for save to GridWebt to Excel

this.ReportGrid.WebWorksheets.SaveToExcelFile(filename);

Thanks and Regards

Saravanan.l

Hi,


Well, I think for your needs, you may copy the worksheets by using Worksheet.Copy() method to copy one worksheet from one book to other book. Also, you may copy ranges’ data (for sheets) for your needs, see the sample code below:

Sample code:

string filePath = @“e:\test2\Book1.xlsx”;
Workbook workbook = new Workbook(filePath);
Workbook destWorkbook = new Workbook();

workbook.CalculateFormula();

//Get the first worksheet of the source file
Worksheet sourceSheet = workbook.Worksheets[0];

destWorkbook.Worksheets.Clear();
int i = destWorkbook.Worksheets.Add();
Worksheet destSheet = destWorkbook.Worksheets[i];
//Create range based on the whole sheet;s data/formatting
//We will only copy the data from first sheet to other book’s first sheet.
//You may do it similar for other desired sheets.
Aspose.Cells.Range sourceRange = sourceSheet.Cells.MaxDisplayRange;
Aspose.Cells.Range destRange = destSheet.Cells.CreateRange(sourceRange.FirstRow, sourceRange.FirstColumn, sourceRange.RowCount, sourceRange.ColumnCount);

//Copy only values/data… formulas would not be exported but their values.
destRange.CopyValue(sourceRange);


destWorkbook.Save(“e:\test2\outputfile.xlsx”);

Thank you.