Remove Existing Printer Settings of Worksheets in an Excel File

Possible Usage Scenarios

Sometimes developers want to prevent Excel from including .bin files of printer settings in the saved XLSX files. Printer settings files are located under “[file “root”]\xl\printerSettings”. This document explains how to remove existing printer settings using Aspose.Cells APIs.

Remove Existing Printer Settings of Worksheets in an Excel File

Aspose.Cells allows you to remove existing printer settings specified for different sheets in the Excel file. The following sample code illustrates how to remove existing printer settings for all the worksheets in the workbook. Please see its sample Excel file, output Excel file, console output as well as a screenshot for reference.

Screenshot

todo:image_alt_text

Sample Code

Console Output

PrinterSettings for this worksheet exist.
Sheet Name: Sheet1
Paper Size: 5
Printer settings of this worksheet are now removed by setting it to null.

PrinterSettings for this worksheet exist.
Sheet Name: Sheet2
Paper Size: 34
Printer settings of this worksheet are now removed by setting it to null.

PrinterSettings for this worksheet exist.
Sheet Name: Sheet3
Paper Size: 70
Printer settings of this worksheet are now removed by setting it to null.

PrinterSettings for this worksheet exist.
Sheet Name: Sheet4
Paper Size: 8
Printer settings of this worksheet are now removed by setting it to null.