We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Printing in black and white

Hello Aspose support!

I’m trying to set the “Printer Properties” -> paper quality -> Colour setting to either black & white or colour.

The only thing I can find is to do this.

public void SetPrintPageColourSetting(string filePath)
{
Workbook wb = new Workbook(filePath);

foreach (Worksheet ws in wb.Worksheets)
{
PageSetup pageSetup = ws.PageSetup;
pageSetup.BlackAndWhite = !Properties.Settings.Default.PrintInColour;
}

wb.Save(filePath);
}

However, this isn’t doing what I expect, it’s removing all the colour out of the excel document. Instead I just wanted to print in black and white, not remove all the shadings.

I can’t find any documentation that would allow me to do this.

Dan

Hi Dan,

Thank you for using Aspose products.

We have evaluated your presented scenario against latest version of Aspose.Cells for .NET 7.7.2.2, and we have received expected results. After setting the PageSetup.BlackAndWhite property to true and saving the workbook does not remove the colors from worksheet. Moreover, the PageSetup properties remain intact (set as BlackAndWhite). We would suggest you to give a try to the latest build on your end. In case the problem persists, please provide us a runnable sample application along with your template file for our review.

C#


Workbook wb = new Workbook(myDir + “input.xls”);
foreach (Worksheet ws in wb.Worksheets)
{
PageSetup pageSetup = ws.PageSetup;
pageSetup.BlackAndWhite = true;
}
wb.Save(myDir + “output.xls”);

The code snippet is all that it does. Your code snippet should be fine. I’m attaching a few screenshots to explain the scenario better.

1) Create a workbook template, fill a cell with a colour such as orange.
2) Feed the template into Aspose and set it to black and white using the code above.
3) Go to Print -> Print preview (I’m using Excel 2012). You’ll see that the header is now black and white instead of being shaded.(as if you are printing with a black and white setting)

Anyway, what I’m after is the setting shown in the screenshot that is attached.

Cheers,

Dan

Hi Dan,

Thank you for writing back.

I am able to observe the problem of PageSetup settings lost after saving the workbook to file. Please note, I have used the same code as provided in my previous reply on Excel 2013 spreadsheets and on a few samples from other clients to verify this anomaly. When resultant spreadsheets are loaded with Excel 2010 & 2013, the Black & White settings are lost. A ticket (CELLSNET-42420) has been logged in our bug tracking system to properly investigate this matter, and to provide a fix at earliest. As soon as we receive any updates in this regard, we will post here for your kind reference.

Hi Dan,

Thanks for using Aspose.Cells.

PageSetup.BlackAndWhite means Page Layout ->Sheet Options -> Black
and White.

We do not support to set the printer setting now. We will look into
whether we could support it later.

Hi,

Thanks for using Aspose.Cells.

We have closed this issue as Won’t Fix, We are sorry for inconvenience. If you want to request any other feature or report any other issue, you are most welcome.