# Track Export Progress

DsExcel allows you to track th progress of exporting a workbook to PDF. Also, you can skip pages or exit exporting whenever you like.

## Content

DsExcel provides [PagePrinting](/document-solutions/dot-net-excel-api/api/online/DS.Documents.Excel/GrapeCity.Documents.Excel.PdfSaveOptions.PagePrinting.html) and [PagePrinted](/document-solutions/dot-net-excel-api/api/online/DS.Documents.Excel/GrapeCity.Documents.Excel.PdfSaveOptions.PagePrinted.html) events in [PdfSaveOptions](/document-solutions/dot-net-excel-api/api/online/DS.Documents.Excel/GrapeCity.Documents.Excel.PdfSaveOptions.html) class to track the export progress of a workbook to PDF. The **PagePrinting** event occurs before printing a page and provides [SkipThisPage](/document-solutions/dot-net-excel-api/api/online/DS.Documents.Excel/GrapeCity.Documents.Excel.PagePrintingEventArgs.SkipThisPage.html) property to skip pages while exporting. Similarly, the **PagePrinted** event occurs after printing a page and provides [HasMorePages](/document-solutions/dot-net-excel-api/api/online/DS.Documents.Excel/GrapeCity.Documents.Excel.PagePrintedEventArgs.HasMorePages.html) property to exit PDF exporting.

## Display Export Progress

Refer to the following example code to display the export progress of a workbook to PDF.

```csharp
//create a pdf file stream
FileStream outputStream = new FileStream("pageprinteventstrackprogress.pdf", FileMode.Create);

//create a new workbook
var workbook = new Workbook();

var activeSheet = workbook.ActiveSheet;
activeSheet.Range["A1"].Value = 1;
activeSheet.Range["A2:A100"].FormulaR1C1 = "=R[-1]C+1";
var options = new PdfSaveOptions();
options.PagePrinting += (sender, e) =>
Console.WriteLine($"Printing page {e.PageNumber} of {e.PageCount}");
activeSheet.PageSetup.CenterHeader = "Page &P of &N";
workbook.Save(outputStream, options);

//close the pdf stream
outputStream.Close();
```

## Skip a Page while Exporting

Refer to the following example code to skip second page while exporting a workbook to PDF.

```csharp
//create a pdf file stream
FileStream outputStream = new FileStream("pageprinteventsskippage.pdf", FileMode.Create);

//create a new workbook
var workbook = new GrapeCity.Documents.Excel.Workbook();

var activeSheet = workbook.ActiveSheet;
activeSheet.Range["A1"].Value = 1;
activeSheet.Range["A2:A100"].FormulaR1C1 = "=R[-1]C+1";
var options = new PdfSaveOptions();

//skip second page
options.PagePrinting += (sender, e) =>
{
    if (e.PageNumber == 2)
    {
        e.SkipThisPage = true;
    }
};
activeSheet.PageSetup.CenterHeader = "Page &P of &N";
workbook.Save(outputStream, options);

//close the pdf stream
outputStream.Close();
```

## Exit Exporting

Refer to the following example code to exit PDF exporting after second page.

```csharp
//create a pdf file stream
FileStream outputStream = new FileStream("pageprinteventsexitprinting.pdf", FileMode.Create);

//create a new workbook
var workbook = new GrapeCity.Documents.Excel.Workbook();

var activeSheet = workbook.ActiveSheet;
activeSheet.Range["A1"].Value = 1;
activeSheet.Range["A2:A100"].FormulaR1C1 = "=R[-1]C+1";
var options = new PdfSaveOptions();

//exit printing after second page
options.PagePrinted += (sender, e) =>
{
    if (e.PageNumber == 2)
    {
        e.HasMorePages = false;
    }
};
activeSheet.PageSetup.CenterHeader = "Page &P of &N";
workbook.Save(outputStream, options);

//close the pdf stream
outputStream.Close();
```