PrintGridlines set to true and saving as pdf shows cell outside of print area and print preview is broken

In the attached pdf, you can see that there is a random cell being displayed with gridlines outside of the necessary area.


The code used:
				worksheet.AutoFitColumns();
worksheet.PageSetup.PrintTitleColumns = “$A:$N”;
worksheet.PageSetup.PrintTitleRows = “$1:$2”;
worksheet.PageSetup.Orientation = PageOrientationType.Landscape;
worksheet.PageSetup.PrintGridlines = true;
worksheet.PageSetup.FitToPagesTall = (int) Math.Ceiling((decimal)analysis.Tables[i].Rows.Count / 35);
}
workbook.Worksheets.ActiveSheetIndex = 0;
string finalFilePath = Path.Combine(_workingDirectory, fileName);
workbook.Save(finalFilePath+".xlsx");
workbook.Save(finalFilePath+".pdf", SaveFormat.Pdf);
Also, the excel spreadsheet does not print correctly as shown by the images.
Although the FitToPagesTall is set correctly, the table is being previewed and printed to 1 page tall.

Hi,

I can see the difference in the PDF file generated from your template TX.xlsx file. Comparing the print preview of the sheets in the Excel file is different with the PDF pages. I just opened and saved your Excel file to PDF. I have logged the issue with an id: CELLSNET-30250. We will look into it soon.

Regarding your issue with generated Excel file for PageSetup options, please see your other thread:
<span class=“Apple-style-span” style="font-size: 12px; background-color: rgb(255, 255, 255); http://www.aspose.com/community/forums/325389/fittopagestall-not-working-properly/showthread.aspx#325389


Thank you.

Hi,

Please download: Aspose.Cells for .NET v7.0.0.2

We have fixed the grid line issues but we think the page break is odd in Excel.

We will need more time to investigate page break issue and fix it.

I was not able to locate version 7.0.0.2 but I did update to v7.0.0.0 and when I ran my code again, the grid lines did not print at all.

Attached is a screenshot demonstrating the result of the following code:

private void InsertData(DataSet analysis, IList<string> worksheetNames, string fileName)
{
Workbook workbook = CreateWorkbook();
workbook.Worksheets.RemoveAt(0);
for (int i = 0; i < analysis.Tables.Count; i++)
{
Worksheet worksheet = workbook.Worksheets.Add(worksheetNames[i]);
Cells cells = worksheet.Cells;
cells.Merge(0, 0, 1, 14);
cells.Merge(1, 0, 1, 14);
Cell titleCell = cells[“A1”];
titleCell.PutValue(“Medicare Advantage Information (Non-Employer)”);
Cell subTitleCell = cells[“A2”];
subTitleCell.PutValue(worksheetNames[i]);
Style style = subTitleCell.GetStyle();
style.HorizontalAlignment = TextAlignmentType.Center;
style.VerticalAlignment = TextAlignmentType.Center;
titleCell.SetStyle(style);
subTitleCell.SetStyle(style);
cells.ImportDataTable(analysis.Tables[i], true, “A3”);
cells.SetColumnWidth(0, 20);
for (int col = 1; col < 14; col++)
{
Cell headerCell = cells[2, col];
Style headerCellStyle = headerCell.GetStyle();
headerCellStyle.IsTextWrapped = true;
headerCell.SetStyle(headerCellStyle);
if (headerCell.StringValue.Length <= 17)
{
cells.SetColumnWidth(col, 11.22);
}
else
{
cells.SetColumnWidth(col, 13.5);
}
if (headerCell.StringValue.Length <= 10)
{
cells.SetColumnWidth(col, 9);
}
}
cells.SetRowHeight(2, 28.8);
PageSetup pageSetup = worksheet.PageSetup;
pageSetup.PrintTitleRows = “$2:$3”;
pageSetup.PaperSize = PaperSizeType.PaperLetterRotated;
pageSetup.Orientation = PageOrientationType.Landscape;
pageSetup.PrintGridlines = true;
pageSetup.FitToPagesTall = (int) Math.Ceiling((decimal)analysis.Tables[i].Rows.Count / 60);
pageSetup.BottomMargin = 1.27;
pageSetup.LeftMargin = 1.27;
pageSetup.RightMargin = 1.27;
pageSetup.TopMargin = 1.27;
pageSetup.FooterMargin = .635;
pageSetup.SetFooter(0, “&D”);
pageSetup.SetFooter(1, “Page &P of &N”);
pageSetup.FirstPageNumber = 1;
}
workbook.Worksheets.ActiveSheetIndex = 0;
string finalFilePath = Path.Combine(_workingDirectory, fileName);
workbook.Save(finalFilePath+".xlsx");
workbook.Save(finalFilePath+".pdf", SaveFormat.Pdf);
}
Hi,

Well, we provided the link for the version/fix v7.0.0.2 in the previous post. I have attached the latest fixed version v7.0.0.3 here now. Please try it and let us know if it works fine.

Thank you.

Amjad,

I have attached the XLSX file and the resulting PDF.
You can see in the Page Setup of the Print Preview that “Print Gridlines” is checked. Yet, the PDF does not display any gridlines.
This is the problem.

Thank you.

Hi,


We requested you to kindly try Aspose.Cells for .NET v7.0.0.3 (also attached in my previous reply as well here). Please do it. I have tested the conversion using v7.0.0.3, it works fine. Please find attached the output PDF here for your reference.

Thank you.

Sorry, I missed updating the reference.

It is printing the gridlines but not completely correct. You can see with the attached file.

Hi,


Yes, we know and noticed the difference b/w the rendered PDF and the print preview of the Excel sheets in the template file. There are a few differences. As we already shared we have not resolved your issue completely. We will look into it soon.

Thank you.

Hi,

We have fixed this issue. Please download Aspose.Cells for .NET v7.0.1