C# Class Smrf.AppLib.ExcelActiveWorksheetRestorer

Saves and restores the active worksheet of an Excel workbook.
Writing to a worksheet that isn't active causes problems with the selection in Excel. To avoid such problems, use this class to activate the worksheet that needs to be written to and then restore the original active worksheet when you're done writing. The activations are done with Excel's screen updating turned off, so they are not visible to the user.

Call ActivateWorksheet to activate the worksheet that needs to be written to. Call Restore when you're done writing.

If you activate a worksheet by other means but still want to use this class to save and restore the original active worksheet, call to save the active worksheet state and call Restore when you're done writing.

Inheritance: Object
Afficher le fichier Open project: 2014-sed-team3/term-project Class Usage Examples

Protected Properties

Свойство Type Description
m_oWorkbook Workbook

Méthodes publiques

Méthode Description
ActivateWorksheet ( Worksheet worksheet ) : ExcelActiveWorksheetState
ExcelActiveWorksheetRestorer ( Microsoft workbook ) : System

Initializes a new instance of the class.

GetActiveWorksheetState ( ) : ExcelActiveWorksheetState
Restore ( ExcelActiveWorksheetState excelActiveWorksheetState ) : void

Private Methods

Méthode Description
AssertValid ( ) : void

Method Details

ActivateWorksheet() public méthode

public ActivateWorksheet ( Worksheet worksheet ) : ExcelActiveWorksheetState
worksheet Worksheet
Résultat ExcelActiveWorksheetState

ExcelActiveWorksheetRestorer() public méthode

Initializes a new instance of the class.
public ExcelActiveWorksheetRestorer ( Microsoft workbook ) : System
workbook Microsoft /// Workbook containing the worksheet that will be activated. ///
Résultat System

GetActiveWorksheetState() public méthode

public GetActiveWorksheetState ( ) : ExcelActiveWorksheetState
Résultat ExcelActiveWorksheetState

Restore() public méthode

public Restore ( ExcelActiveWorksheetState excelActiveWorksheetState ) : void
excelActiveWorksheetState ExcelActiveWorksheetState
Résultat void

Property Details

m_oWorkbook protected_oe property

protected Workbook m_oWorkbook
Résultat Workbook