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,
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#
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,
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#
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.