Back to Devexpress

WorksheetPrintOptions.PrintGridlines Property

officefileapi-devexpress-dot-spreadsheet-dot-worksheetprintoptions-4d7928cd.md

latest7.5 KB
Original Source

WorksheetPrintOptions.PrintGridlines Property

Gets or sets whether worksheet gridlines are printed.

Namespace : DevExpress.Spreadsheet

Assembly : DevExpress.Spreadsheet.v25.2.Core.dll

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
bool PrintGridlines { get; set; }
vb
Property PrintGridlines As Boolean

Property Value

TypeDescription
Boolean

true , to print worksheet gridlines; otherwise, false.

|

Property Paths

You can access this nested property as listed below:

Object TypePath to PrintGridlines
Worksheet

.PrintOptions .PrintGridlines

|

Remarks

Use the PrintGridlines property to specify whether or not the worksheet gridlines should be printed. To control the visibility of gridlines in the worksheet view, use the WorksheetView.ShowGridlines property of the object that is returned by Worksheet.ActiveView.

Example

This example demonstrates how to specify print options.

Note

The WorksheetPrintOptions.Draft, WorksheetPrintOptions.NumberOfCopies and WorksheetPrintOptions.CommentsPrintMode options are not supported when you print a document from the Spreadsheet. However, they are saved to a file, so you can use Microsoft® Excel® or another spreadsheet application to load and print a document.

View Example

csharp
worksheet.ActiveView.Orientation = PageOrientation.Landscape;
// Display row and column headings.
worksheet.ActiveView.ShowHeadings = true;
worksheet.ActiveView.PaperKind = DevExpress.Drawing.Printing.DXPaperKind.A4;
// Access an object that contains print options.
WorksheetPrintOptions printOptions = worksheet.PrintOptions;
// Do not print gridlines.
printOptions.PrintGridlines = false;
// Scale the print area to fit to the width of two pages.
printOptions.FitToPage = true;
printOptions.FitToWidth = 2;
// Print in black and white.
printOptions.BlackAndWhite = true;
// Print a dash instead of a cell error message.
printOptions.ErrorsPrintMode = ErrorsPrintMode.Dash;
vb
worksheet.ActiveView.Orientation = PageOrientation.Landscape
' Display row and column headings.
worksheet.ActiveView.ShowHeadings = True
worksheet.ActiveView.PaperKind = DevExpress.Drawing.Printing.DXPaperKind.A4
' Access an object that contains print options.
Dim printOptions As WorksheetPrintOptions = worksheet.PrintOptions
' Do not print gridlines.
printOptions.PrintGridlines = False
' Scale the print area to fit to the width of two pages.
printOptions.FitToPage = True
printOptions.FitToWidth = 2
' Print in black and white.
printOptions.BlackAndWhite = True
' Print a dash instead of a cell error message.
printOptions.ErrorsPrintMode = ErrorsPrintMode.Dash

The following code snippets (auto-collected from DevExpress Examples) contain references to the PrintGridlines property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

wpf-spreadsheet-chart-api/CS/SpreadsheetWPFChartAPISamples/MainWindow.xaml.cs#L56

csharp
foreach (Worksheet sheet in workbook.Worksheets)
    sheet.PrintOptions.PrintGridlines = true;

wpf-spreadsheet-pivot-table-api-examples/CS/SpreadsheetWPFPivotTableExamples/MainWindow.xaml.cs#L48

csharp
foreach (Worksheet sheet in workbook.Worksheets)
    sheet.PrintOptions.PrintGridlines = true;

winforms-spreadsheet-chart-api/CS/SpreadsheetChartAPISamples/Form1.cs#L114

csharp
foreach (Worksheet sheet in workbook.Worksheets)
    sheet.PrintOptions.PrintGridlines = true;

winforms-spreadsheet-pivot-table-api/CS/SpreadsheetPivotTableExamples/Form1.cs#L103

csharp
foreach (Worksheet sheet in workbook.Worksheets)
    sheet.PrintOptions.PrintGridlines = true;

wpf-spreadsheet-chart-api/VB/SpreadsheetWPFChartAPISamples/MainWindow.xaml.vb#L57

vb
For Each sheet As Worksheet In workbook.Worksheets
    sheet.PrintOptions.PrintGridlines = True
Next sheet

wpf-spreadsheet-pivot-table-api-examples/VB/SpreadsheetWPFPivotTableExamples/MainWindow.xaml.vb#L46

vb
For Each sheet As Worksheet In workbook.Worksheets
    sheet.PrintOptions.PrintGridlines = True
Next sheet

winforms-spreadsheet-chart-api/VB/SpreadsheetChartAPISamples/Form1.vb#L109

vb
For Each sheet As Worksheet In workbook.Worksheets
    sheet.PrintOptions.PrintGridlines = True
Next sheet

winforms-spreadsheet-pivot-table-api/VB/SpreadsheetPivotTableExamples/Form1.vb#L97

vb
For Each sheet As Worksheet In workbook.Worksheets
    sheet.PrintOptions.PrintGridlines = True
Next sheet

See Also

WorksheetPrintOptions Interface

WorksheetPrintOptions Members

DevExpress.Spreadsheet Namespace