ExcelTechnology

Workbook.Open Method and How to Open Workbook in C#

As is known, Excel object includes four common classes, Application, Workbook, Worksheet and Range. Each class has lots of methods, properties and events.

Workbook object is used to represent a Microsoft Excel workbook, which is a member of the Workbooks collection. All Workbook objects open in Microsoft Excel is contained in Workbooks collection. And there are three properties which can return a Workbook object: Workbooks Property, ActiveWorkbook property and ThisWorkbook property.

Besides property, there are lots of events of Workbook object. Workbook.Open is one of them, which occurs when the workbook is opened. This article introduces something about Workbook.Open Event and how to open Workbook in C#.

The namespace of Workbook.Open event is Microsoft.Office.Tools.Excel and assembly is Microsoft.Office.Tools.Excel which is in Microsoft.office.tools.excel.dll. In C#, the syntax of Workbook.Open event is public event WorkbookEvents_OpenEventHandler Open.

The following example by using C# shows the Open event handler, which maximizes the Microsoft Office Excel application window when the current workbook is opened.

private void WorkbookOpen()
{
this.Open +=
new Excel.WorkbookEvents_OpenEventHandler(
ThisWorkbook_Open);
}

void ThisWorkbook_Open()
{
this.Application.WindowState = Excel.XlWindowState.xlMaximized;
}
How to use C# to open Excel Workbook

If we want to open an Excel workbook in C#, it is necessary to use the Open methods of the Workbooks collection, which makes it possible to work with all open workbooks and to open workbooks. The following code shows you the method to open the workbooks under specified path in C#.

this.Application.Workbooks.Open(@ “YourPathYopurWorkbook.xls”,
missing, missing, missing, missing, missing, missing, missing,
missing, missing, missing, missing, missing, missing, missing);

22.12.2010. u 08:59 | 0 Komentara | Print | # | ^

<< Arhiva >>

Creative Commons License
Ovaj blog je ustupljen pod Creative Commons licencom Imenovanje-Dijeli pod istim uvjetima.

  prosinac, 2010 >
P U S Č P S N
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    

Kolovoz 2011 (2)
Srpanj 2011 (2)
Lipanj 2011 (2)
Svibanj 2011 (2)
Travanj 2011 (3)
Ožujak 2011 (2)
Veljača 2011 (2)
Siječanj 2011 (5)
Prosinac 2010 (5)

Dnevnik.hr
Gol.hr
Zadovoljna.hr
Novaplus.hr
NovaTV.hr
DomaTV.hr
Mojamini.tv

Opis bloga

something about Excel Technology in VB.Net and C#

Linkovi

Dnevnik.hr
Video news portal Nove TV

Blog.hr
Blog servis

Igre.hr
Najbolje igre i igrice

Forum.hr
Monitor.hr