Pdf Viewing problem

Hi,

I have an excel file .I converted my file to pdf .As I see my file format was corrupted.Excel columns appears in a small area in pdf. I attached my original file. And I am usind opts.OnePagePerSheet method.Maybe it can help you

Hi,


Thank you for using Aspose.Cells.

Please download and use this latest version: Aspose.Cells for .NET v7.3.0.1. I have converted your source file into PDF using this version, and it is working fine.

I have attached the output PDF file here for your reference. My sample code for conversion to PDF is as follows:

<span style=“font-size:
10.0pt;font-family:“Courier New”;color:#2B91AF;mso-no-proof:yes”>Workbook<span style=“font-size:10.0pt;font-family:“Courier New”;mso-no-proof:yes”> workbook =
new Workbook(“Test.xls”);

PdfSaveOptions optns = new PdfSaveOptions();

optns.OnePagePerSheet = true;

workbook.Save("Test.pdf", optns);

I tried but the result is same.I think it is a PrintArea problem.Please check with the following code

foreach (Worksheet sheet in workbook.Worksheets)

{

maxCol = sheet.Cells.MaxDisplayRange.ColumnCount - 1;

maxRow = sheet.Cells.MaxDisplayRange.RowCount - 1;

if (maxCol > 0 && maxRow > 0)

{

Aspose.Cells.

PageSetup pageSetup = sheet.PageSetup;

pageSetup.PrintArea =

"A1:" + CellsHelper.CellIndexToName(maxRow, maxCol);

}

}

Hi,

Please either just don’t specify printable area for your workbook sheet, it is already set. You may open PageSetup dialog box in MS Excel, click on Sheet tab to see the printable area. Or you may use Cells.MaxDataRow and Cells.MaxDataColumn attributes instead. See the sample codes below. Both will work fine for you.

Sample code:

1)

Workbook workbook = new Workbook(“e:\test2\test.xls”);
workbook.Save("e:\\test2\\output.pdf");


2)
Workbook workbook = new Workbook("e:\\test2\\test.xls");
foreach (Worksheet sheet in workbook.Worksheets)
{

int maxCol = sheet.Cells.MaxDataColumn;

int maxRow = sheet.Cells.MaxDataRow;

if (maxCol > 0 && maxRow > 0)
{

Aspose.Cells.PageSetup pageSetup = sheet.PageSetup;


pageSetup.PrintArea = "A1:" + CellsHelper.CellIndexToName(maxRow, maxCol);
}

}

workbook.Save("e:\\test2\\output.pdf");

Thank you.

Now I have another problem If I use

int maxCol = sheet.Cells.MaxDataColumn;

int maxRow = sheet.Cells.MaxDataRow;

My excel columns were cutting when I convert my file to pdf.You can test with attachement.I attach test file for u

Hi,


Thanks for sharing the Excel file.

Since you Excel template file contains extended formatting (border lines, merged styles, images, etc.) with data, so you should use Cells.MaxRow and CellsMaxColumn attributes instead. See the update sample code. I have tested it with your newly attached file and it works fine. I used our latest version/fix v7.3.0.2: Aspose.Cells for .NET v7.3.0.2

Sample code:

Workbook workbook = new Workbook(“e:\test2\DC-AS-PB3-001.xls”);
foreach (Worksheet sheet in workbook.Worksheets)
{

int maxCol = sheet.Cells.MaxColumn;

int maxRow = sheet.Cells.MaxRow;

if (maxCol > 0 && maxRow > 0)
{

Aspose.Cells.PageSetup pageSetup = sheet.PageSetup;
pageSetup.PrintArea = “A1:” + CellsHelper.CellIndexToName(maxRow, maxCol);
}

}

workbook.Save(“e:\test2\DC-AS-PB3-001.pdf”);



I have also attached the output PDF file here.

Thank you.

Hi ,

I am using following properties now.But when I want to print my pdf (I am converting my excel file to pdf)file ,I see that the print preview version has blank fields and it is smaller than the original format.Could you please check it.I attached original file and screen shot for u

int maxCol = sheet.Cells.MaxColumn;


int maxRow = sheet.Cells.MaxRow;

Hi,


Well, it absolutely works fine. I used your file to convert to PDF. If you could compare the Excel file’s print preview with PDF file (generated by Aspose.Cells), both are identical. I have done the comparison, please see the screen shot.

If you still find any issue, please give us comparison screen shot i.e.

Excel’s sheet’s print preview (taken in MS Excel) Vs Pdf file (generated by Aspose.Cells).

Also please highlight the problematic ares with red color.

Thank you.