Convertion from Excel file to pdf is not working

Hi,

I'm having an issue with some excel files when I try to convert to pdf, never finish the convertion.

I really apreciarte any help with this issue.

Regards,
Thanks,

Hi,

Please provide your Excel file so that we could test your file and if it is a bug, we will report it to development team for fixing it.

Please also test your issue with the latest version: Aspose.Cells
for .NET v6.0.1.3

Hi,

Sorry for the delay sending the example with the issue, I was out of the office the weekend,

Attached the example with the issue, I hope this will help you to reproduce it.

Thanks,

Regards,

Hi,

Please download the latest version: Aspose.Cells
for .NET v6.0.1.3


It is working fine. You can see the attached converted pdf.

Please see the code below.

C#


string path = @“F:\Shak-Data-RW\Downloads\D8B58807-B886-11E0-AE1C-0026B9570A9B.xls”;


Workbook workbook = new Workbook(path);


workbook.Save(path + “.out.pdf”, SaveFormat.Pdf);


Hi,
Thanks for the quick response, the issue was solved.

Thank you
Best Regards,

Hi,

I found more excel files that have and issue, maybe is a new one, but this files never finish the convertion

Here is the example file, if you need more example files, just let me know,

Regards,

Thanks,

Hi,


Thanks for the template file.

I think I can notice the issue as you have mentioned. I have tried converting your newly attached template file to PDF but it looks like the process would never be completed, I waited and then terminated the process manually.

I have logged a ticket with an id: CELLSNET-29839. We will look into it soon.

By the way, when opening your file into MS Excel also takes some time, especially when you take the preview of the sheet that has huge list of pages.

Thank you.

Hi,

We found there are a lot of check box in worksheet e.g row 983044

worksheet 1 , CELL name : TLQ983044

Please set reasonable printarea to convert to pdf.

We found excel print preview shows that there are 34600000 pages need to be rendered if no print area is set.

Hi,

This is the code that we use to generate the pdf file, could you show how to set the print area.

Workbook doc = new Workbook(inputFile);

int workSheetIndex = 0;
int workSheetCount = doc.Worksheets.Count;
Worksheet worksheet = null;

for (workSheetIndex = 0; workSheetIndex < workSheetCount; workSheetIndex++)
{
worksheet = doc.Worksheets[workSheetIndex];
worksheet.IsVisible = true;
worksheet.PageSetup.BottomMargin = bottomMargin;
worksheet.PageSetup.LeftMargin = leftMargin;
worksheet.PageSetup.RightMargin = rightMargin;
worksheet.PageSetup.TopMargin = topMargin;
worksheet.PageSetup.HeaderMargin = headerMargin;
worksheet.PageSetup.FooterMargin = footerMargin;
worksheet.PageSetup.PaperSize = paperSize;
worksheet.PageSetup.Orientation = orientation;
worksheet.PageSetup.Zoom = zoom;
worksheet.PageSetup.PrintGridlines = printGridlines;
if (!allowColumnHidden)
{
foreach (Column column in worksheet.Cells.Columns)
{
column.IsHidden = false;
}
}
if (!allowRowHidden)
{
foreach (Row row in worksheet.Cells.Rows)
{
row.IsHidden = false;
}
}

if (!allowFormula)
{
foreach (Cell cell in worksheet.Cells)
{
if (cell.IsFormula)
{
cell.Value = cell.Formula; // change the value of formula by
}
}
}
} // end foreach (Worksheet worksheet in doc.Worksheets)

doc.Save(pdfFileName, SaveFormat.Pdf);

Regards,

Thanks,

Hi,

I'm using now this code that reduce the number of pages,

for (int i = 0; i < doc.Worksheets.Count - 1; i++)<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

{

Worksheet ws = doc.Worksheets[i];

int maxdatacol = ws.Cells.MaxDataColumn+5;

int maxdatarow = ws.Cells.MaxDataRow+5;

//Get the last cellCell

Aspose.Cells.Cell lastCell = ws.Cells[maxdatarow,maxdatacol];

//If last cell is merged then calculate last cell again

if (lastCell.IsMerged)

{

Aspose.Cells.Range rng = lastCell.GetMergedRange();

int idxCol = lastCell.Column + rng.ColumnCount;

int idxRow = lastCell.Row + rng.RowCount;

string mycell = CellsHelper.CellIndexToName(idxRow, idxCol);

lastCell = ws.Cells[mycell];

}

Aspose.Cells.PageSetup pgSetup = ws.PageSetup;

pgSetup.PrintArea = "A1:" + lastCell.Name;

//Final Print Area//Set the margins to remove white spacing

}

Hi,

Please try this code to calculate the print area of page setup. The code is generic and there is no hardcoding. Let me know your feedback.

C#



CellArea[] areas = worksheet.GetPrintingPageBreaks(options);


CellArea area = areas[0];

area.EndRow = area.EndRow +2;

area.EndColumn = area.EndColumn +2;


string r1c1 = “R” + area.EndRow + “C” + area.EndColumn;


string s = CellsHelper.ConvertR1C1FormulaToA1(r1c1, 0, 0);


string printArea = “A1:” + s.Replace("$", “”);


worksheet.PageSetup.PrintArea = printArea;

Hi, i'm coworkers of etito.

i'm trying the code but, what option select in:

options = new ImageOrPrintOptions();

because areas.Count is returning me zero.

Thanks.

Hi,

I'm trying to use the code but, aparently this line does not work:

CellArea[] areas = worksheet.GetPrintingPageBreaks(options);


Could you provide us, the code to create an instance of the options class,

Thanks,

Regards,

Hi,

We have tested and found no issue using the latest version:
Aspose.Cells for .NET v7.0.2.0

If you still find an issue, then please provide us your simple runnable demo project replicating the issue. We will look into it and fix it asap.