Previously we have been using SheetToImageByPage. Because of CELLSNET-16744, we now have to switch to using SheetRender and we are finding problems that do not exist in SheetToImageByPage. <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
While Aspose.Cells update 4.9.1.4 fixed the SheetRender problem reported in 16744, we have found that blank pages are not properly ignored by SheetRender.
Using code like this:
Workbook book = new Workbook();
book.Open(fullPath);
imgOptions = new ImageOrPrintOptions();
imgOptions.ImageFormat = ImageFormat.Tiff;
imgOptions.HorizontalResolution = 200;
imgOptions.VerticalResolution = 200;
imgOptions.TiffCompression = TiffCompression.CompressionCCITT4;
imgOptions.PrintingPage = PrintingPageType.IgnoreBlank;
int bookPageCount = 0;
for (int i = 0; i < book.Worksheets.Count; i++)
{
Worksheet sheet = book.Worksheets[i];
if (settingOrientation) sheet.PageSetup.Orientation = orientation;
if (settingZoom) sheet.PageSetup.Zoom = zoom;
if (settingPrintGridlines) sheet.PageSetup.PrintGridlines = printGridlines;
if (settingAutoFitColumns) sheet.AutoFitColumns();
if (settingAutoFitRows) sheet.AutoFitRows();
if (imgOptions.TiffCompression == TiffCompression.CompressionCCITT4)
{
foreach (Cell cell in sheet.Cells)
{
cell.Style.Font.Color = Color.Empty;
cell.Style.ForegroundColor = Color.Empty;
cell.Style.BackgroundColor = Color.Empty;
cell.Style.Pattern = BackgroundType.None;
}
}
SheetRender sr = new SheetRender(sheet, imgOptions);
int sheetPageCount = sr.PageCount;
string subPageName = string.Empty;
for (int j = 0; j < sheetPageCount; j++)
{
sr.ToImage(j, "image" + i.ToString() + "_" + j.ToString() + ".tif");
}
bookPageCount += sheetPageCount;
}
With this code, blank pages are being created. If you print the XLS directly from Excel, blank pages do not appear. Using the SheetToImageByPage method, blank pages do not appear.
I have attached sample XLS files and the resulting TIF files when converted by SheetRender.
With the first XLS file, MS Excel prints only 1 page. SheetRender creates 2 pages. The second page contains one empty cell.
With the second XLS file, Excel prints only 5 pages. SheetRender creates 6 pages. The last page is blank.
Please review.
Thank you,
Robert.