We are using a patched version of Aspose.Cells (18.11.6) to convert an xlsx to tiff.
We find with this new version, what used to be converted to a 1 page tif, now converts to a 4 page tif. The older version was 18.10.0. There are extra blank pages at the end
Below is a zip with the original xlsx.
out.tif is the output with 18.11.6
Olderversionofaspose.tif is how 18.10.0 rendered the same xlsx with the code below.
Issue17-Original.zip (102.9 KB)
private void button1_Click(object sender, EventArgs e)
{
Aspose.Cells.License cellsLicense = new Aspose.Cells.License();
cellsLicense.SetLicense(“C:\interfax\Interfax20\OfficeRenderer\Service\License\Aspose.Total.lic”);
Aspose.Imaging.License imagingLicense = new Aspose.Imaging.License();
imagingLicense.SetLicense("C:\\interfax\\Interfax20\\OfficeRenderer\\Service\\License\\Aspose.Total.lic");
int numPages = 0;
var asposeWorkbook = new Aspose.Cells.Workbook("c:\\dtemp\\Issue17-Original.xlsx");
numPages = asposeWorkbook.Worksheets.Count;
Aspose.Cells.Worksheet selectedWS = null;
selectedWS = asposeWorkbook.Worksheets[0];
foreach (Aspose.Cells.Worksheet w in asposeWorkbook.Worksheets)
{
if (w.IsSelected)
{
bool anySelected = true;
selectedWS = w;
// rcalc cells size
w.AutoFitRows(true);
// recalc formulas
foreach (Aspose.Cells.Cell cell in w.Cells)
{
try
{
if (cell.IsFormula)
cell.Calculate(false, null);
}
catch { }
}
// recalc pivot tables
foreach (Aspose.Cells.Pivot.PivotTable pt in w.PivotTables)
{
try { pt.RefreshData(); }
catch { }
try { pt.CalculateData(); }
catch { }
try { pt.CalculateRange(); }
catch { }
}
}
else
//mark this worksheet as NOT saveable
w.IsVisible = false;
}
bool flipresizeWS = false;
Aspose.Cells.Rendering.ImageOrPrintOptions CellsSaveOptions = null;
Aspose.Cells.Rendering.ImageOrPrintOptions cellRenderoptions = CellsSaveOptions;
if (cellRenderoptions == null)
{
Aspose.Cells.PageSetup setup = selectedWS.PageSetup;
int horizDpi = 170;
int vertDpi = 170;
flipresizeWS = setup.Orientation == Aspose.Cells.PageOrientationType.Landscape;
cellRenderoptions = new Aspose.Cells.Rendering.ImageOrPrintOptions();
// Set Horizontal Resolution
cellRenderoptions.SaveFormat = Aspose.Cells.SaveFormat.TIFF;
cellRenderoptions.TiffCompression = Aspose.Cells.Rendering.TiffCompression.CompressionCCITT3;
// Set Vertical Resolution
cellRenderoptions.VerticalResolution = vertDpi;
cellRenderoptions.HorizontalResolution = horizDpi;
cellRenderoptions.Quality = 100;
cellRenderoptions.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
cellRenderoptions.PixelFormat = System.Drawing.Imaging.PixelFormat.Format32bppArgb;
// If you want entire sheet as a single image
cellRenderoptions.OnePagePerSheet = false;
// Render to image
Aspose.Cells.Rendering.SheetRender sr = new Aspose.Cells.Rendering.SheetRender(selectedWS, cellRenderoptions);
sr.ToTiff("c:\\dtemp\\out.tiff");
}
}