Hi,
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
If you want to print the whole worksheet, you don’t need to set the print area. We will auto check the print area.<?xml:namespace prefix = u1 /> Also, please change your “unhide” code. Please check the following codes:
public static void ToTiff(String input, String output)
{
// Configure the print options before doing anything.
ImageOrPrintOptions printOptions = new ImageOrPrintOptions();
printOptions.HorizontalResolution = 300;
printOptions.VerticalResolution = 300;
printOptions.ImageFormat = System.Drawing.Imaging.ImageFormat.Tiff;
printOptions.TiffCompression = TiffCompression.CompressionCCITT4;
printOptions.PrintingPage = PrintingPageType.IgnoreBlank;
// Create a new workbook to use.
Workbook book = new Workbook();
// Open the input file.
book.Open(input);
book.ShowTabs = true;
foreach (Worksheet sheet in book.Worksheets)
{
Console.WriteLine(" - Processing sheet #{0} ({1})", sheet.Index, sheet.Name);
// Sheet options
sheet.IsVisible = true;
//// Unhide/Ungroup rows and columns
int maxRow = sheet.Cells.MaxRow;
int maxColumn = sheet.Cells.MaxColumn;
//sheet.Cells.UngroupRows(0, maxRow);
//sheet.Cells.UngroupColumns(0, maxColumn);
foreach (Row row in sheet.Cells.Rows)
{
//Why you want to set the row height as 1 pt
//sheet.Cells.UnhideRow(row.Index, 1);
if (row.IsHidden)
row.IsHidden = false;
}
foreach (Column column in sheet.Cells.Columns)
{
//sheet.Cells.UnhideColumn(column.Index, 1);
if (column.IsHidden)
column.IsHidden = false;
}
// Sheet settings
sheet.AutoFitColumns();
sheet.AutoFitRows();
sheet.PageSetup.BlackAndWhite = true;
sheet.PageSetup.PrintComments = PrintCommentsType.PrintNoComments;
sheet.PageSetup.PrintErrors = PrintErrorsType.PrintErrorsDisplayed;
sheet.PageSetup.Zoom = 80;
sheet.PageSetup.Orientation = PageOrientationType.Landscape;
//Aspose.Cells.Cell cell = sheet.Cells[sheet.Cells.MaxRow, sheet.Cells.MaxColumn];
//sheet.PageSetup.PrintArea = "A1:" + cell.Name;
sheet.PageSetup.PrintArea = "A1:" + CellsHelper.CellIndexToName(maxRow,maxColumn);
}
WorkbookRender wbr = new WorkbookRender(book, printOptions);
wbr.ToImage(String.Format(@"{0}\{1}.tiff", output, Path.GetFileNameWithoutExtension(input)));
}
Thank You & Best Regards,