Change background color of headings in SheetRender image

With Aspose.Cells it is possible to generate worksheet images. For example, with the following code:

var workbook = new Workbook();
var worksheet = workbook.Worksheets[0];

worksheet.PageSetup.PrintArea = "A1:E12";
worksheet.PageSetup.LeftMargin = 0;
worksheet.PageSetup.RightMargin = 0;
worksheet.PageSetup.TopMargin = 0;
worksheet.PageSetup.BottomMargin = 0;
worksheet.PageSetup.PrintGridlines = false;
worksheet.PageSetup.PrintHeadings = true;

var options = new ImageOrPrintOptions
{
    OnePagePerSheet = true,
    OnlyArea = true,
    ImageType = ImageType.Png,
    HorizontalResolution = 192,
    VerticalResolution = 192,
    IsOptimized = true
};

var sr = new SheetRender(worksheet, options);
sr.ToImage(0, "test.png");

The resulting image is:

test.png (3.0 KB)

We explicitly set the property worksheet.PageSetup.PrintHeadings to true to include the row and column headings. We’re wondering, is it possible to change the background color of the headings? Currently the background color is white (#FFFFFF) but we want to change it to grey (#F0F0F0), just like in Excel.

Expected image:

test2.png (2.9 KB)

@perfectxl,

Thanks the image files.

I tested it in MS Excel manually. I input some data into a worksheet and open the Page Setup dialog to check the option “Row and column headings” in “Sheet” tab. I found MS Excel too shows white background color for the row/col headings. So, apparently Aspose.Cells follows MS Excel standards. Could you try using MS Excel option if you get expected results in print preview or not?

Yes, you’re right, MS Excel also generates row and column headings with a white background. We never checked the output of MS Excel print preview.

What we’re trying to do is to generate pictures that are most similar to the MS Excel interface. If the background color of the headings is not adjustable in Aspose.Cells, I think we will have to manipulate the output image ourselves to adjust the background color.

Thank you for your response!

@perfectxl,

Generally, we follow MS Excel standards and specifications when rendering spreadsheets to PDF/image. We rarely go against it. Anyways, we will still discuss this matter and check if this is feasible enough and worthwhile to customize the background color (for row/col headings) or not.

@perfectxl

You may try to add a row and a column to simulate the output of PrintHeadings, where you can change background and borders of cells in added row/column.

We will modify the output image for our specific requirements. Thanks for your response!

@perfectxl,

Alright! you may do as per your convenience.