How to hide the row‑ and column‑headings when exporting a worksheet to a TIF image with Aspose.Cells
Worksheet.PageSetup.IsRowColumnHeadersVisible only affects Excel’s print‑preview UI.
The image renderer uses its own option – ImageOrPdfSaveOptions.IsRowColumnHeadersVisible.
Set this flag (and, if you like, clear the page‑setup PrintHeadings flag) before calling Workbook.Save.
Minimal C# example
using Aspose.Cells;
using Aspose.Cells.Rendering; // ImageOrPdfSaveOptions lives here
// 1. Load the workbook
Workbook wb = new Workbook(@"C:\Input\Sample.xlsx");
// 2. Configure the image‑export options
ImageOrPdfSaveOptions imgOpts = new ImageOrPdfSaveOptions(SaveFormat.Tiff)
{
// Export each worksheet as a single page (optional)
IsOnePagePerSheet = true,
// Hide the row/column headings in the exported image
IsRowColumnHeadersVisible = false,
// Optional – keep the workbook “clean” for other exports
// (does not affect the image when the renderer flag is set)
// wb.Worksheets[0].PageSetup.PrintHeadings = false;
};
// 3. Save the workbook as a TIF image
wb.Save(@"C:\Output\Sheet1.tif", imgOpts);
When the workbook contains several worksheets
The same ImageOrPdfSaveOptions instance can be reused for all sheets:
foreach (Worksheet ws in wb.Worksheets)
{
ws.PageSetup.PrintHeadings = false; // optional, for consistency
}
wb.Save(@"C:\Output\AllSheets.tif", imgOpts);
@Viral84
This is our test result. It can be observed that the headings of rows and columns (A, B, C… and 1,2,3…) have not been exported. Please refer to the attachment. tiff.zip (165.2 KB)
Is your goal to avoid exporting the first row of data from the worksheet? If so, please hide the first row before exporting. Please add the following sample code. Please check the attachment. tiff_hidden.zip (134.7 KB)
ws.Cells.Rows[0].IsHidden = true;
If you still have questions, please provide your expected results. We will check it soon.
@Viral84
Of course, you can also specify the printing area of the worksheet to filter data more flexibly. Please refer to the following example code and check the attachment. tiff_area.zip (139.2 KB)
Workbook book = new Workbook(filePath + "6615_NEW.xls");
var imgOptions = new ImageOrPrintOptions
{
ImageType = Aspose.Cells.Drawing.ImageType.Tiff,
OnePagePerSheet = true,
PrintingPage = PrintingPageType.Default,
HorizontalResolution = 300,
VerticalResolution = 300,
OutputBlankPageWhenNothingToPrint = false,
OnlyArea = true
};
foreach (Worksheet ws in book.Worksheets)
{
int maxDataRow = ws.Cells.MaxDataRow;
int maxDataColumn = ws.Cells.MaxDataColumn;
if (maxDataRow < 0 || maxDataColumn < 0)
{
continue;
}
string area = CellsHelper.CellIndexToName(1, 0) + ":" + CellsHelper.CellIndexToName(maxDataRow, maxDataColumn);
ws.PageSetup.PrintArea = area;
ws.PageSetup.PrintHeadings = false;
SheetRender render = new SheetRender(ws, imgOptions);
for (int pageIndex = 0; pageIndex < render.PageCount; pageIndex++)
{
string fileName = filePath + ws.Name + "_area.tiff";
// Ensure overwriting old images
if (File.Exists(fileName))
File.Delete(fileName);
render.ToImage(pageIndex, fileName);
}
}
@Viral84
Thank you for your feedback. I’m glad you found a solution through the previous suggestions. If you have any questions, please feel free to contact us at any time.
Please note, the property Worksheet.IsRowColumnHeadersVisible | Aspose.Cells for .NET API Reference is used to set whether the worksheet will display row and column headers when viewing the output Excel file (e.g., XLSX) into MS Excel manually. It does not do anything when rendering the data range to image format.
So just to confirm if there are multiple tables then there is no direct option to set ColumnHeader visiblity,right ? here column is refer to actual data column not ABC columns.
and will there any option to show or hide Top Header part heading text in export Image ?
@Viral84
We can not simply detect which row is column header row of the table as they are normal data of the worksheet. So please find a way to check which row is column header according your business by yourself, then hide row with Cells.HideRow() method.
We supported search data as Find or Search Data|Documentation
or iterate all cells as How and Where to Use Enumerators|Documentation